I’m working on a game using AWT in which i’m importing Images from GIFs. My problem right now is that I need to grab a rectangular region of the offscreen image (the one used for double-buffered painting) and turn that into a separate image. But since the offscreen image is an Image and not a BufferedImage (BufferedImage made it run several times slower) there is no subimage method and I dont know how to create one. can anyone help?
Is the image that you’re going to paint into exactly the size of the section you want to copy? If so, just get the graphics of the destination image and paint the source image into it at an offset.
and if its not, just setup the appropriate clip rectangle on the destination image.
Incidentally, the reason the bufferedImage ran slowly was because it was not a managedImage (where as the Image returned from getImage/createImage was)
If you had created your BufferedImage with GraphicsConfiguration.createCompatibleImage() instead of using the BufferedImage constructor, the speed would not have been slower.