Image or BufferedImage
807605Jul 25 2007 — edited Jul 25 2007Trying to write an application that displays a lot of images. Images would essentially be drawn onto JPanels. Was wondering what are the implications of using BufferedImage over Image. As far as I know BufferedImage are handy if you wanna gain access to the pixels. Is there any other good reason to consider using BufferedImage instead of Image? Would there be cost or benefit in performance when I have a class that holds and displays BufferedImage instead of just using Image?
Also, found that for relatively large images, using the following code to convert an Image to BufferedImage can take up to several minutes. Does anybody know a way to speed things up?
BufferedImage bi = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
tracker.addImage(bi, 0);
Graphics g = bi.createGraphics();
g.drawImage(image, 0, 0, null);
g.dispose();
tracker.waitForID(0);
Many thanks on any advice you can give.
Jeev