0

Is there a way to make a file stored as a jpg image into a Shape? So, I have a image and an ArrayList and need a way to add that image to the list. The image is a rectangle so is there perhaps a way to store a Rectangle Shape and paint the image inside of the rectangle, maybe?

  • 1
    I think you can call the method `getRect()` on a loaded `ImageIcon`. – Mapsy Mar 23 '16 at 03:44
  • Thanks! Any way I could ask you for a quick example? – SupposedlySleeping Mar 23 '16 at 03:50
  • You cook create a wrapper class which associates a Rectangle and image together or use a Map of some kind – MadProgrammer Mar 23 '16 at 04:12
  • @AlexT. You have a link to the JavaDocs for that? – MadProgrammer Mar 23 '16 at 04:14
  • @MadProgrammer, can you explain that in more detail? Early on in my CS career? – SupposedlySleeping Mar 23 '16 at 04:23
  • @SupposedlySleeping What is it you are trying to achieve? – MadProgrammer Mar 23 '16 at 06:02
  • The core of it is that I have a PaintObject object that consists of a Shape and a Color. My project spec (Paint App for a CS course) specifies that I must be able to draw an ellipse, a rectangle, a line and a _scalable_ _jpg_. I have been using Recangle2D.Float (etc) for the Shapes. For the sake of functionality, I have added a boolean to the PaintObject class that specifies if a rectangle is in fact supposed to filled with its Color or filled with the jpg. If the boolean returns true, I basically paint a rectangle, then, over the rectangle, paint the scaled image. It's really messy though. – SupposedlySleeping Mar 23 '16 at 18:45

0 Answers0