loading a jpeg into a BufferedImage?

is it possible to load a jpeg into a BufferedImage?
[58 byte] By [smremde] at [2007-9-27 22:27:13]
# 1
Try something like this comboImage is your JPGBufferedImage bi = gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT);Graphics g = bi.getGraphics();g.drawImage(comboImage,0,0,width,height,null);
zparticle at 2007-7-7 12:58:43 > top of Java-index,Other Topics,Java Game Development...
# 2

(and gc is a GraphicsConfiguration object)

Though that solution will not work for source images that contain transparent/translucent pixels (such as those obtained from gif and png files).

If you want to copy an Image containing transparency infomation into a BufferedImage, the code would be a little different :-

BufferedImage bi = gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT);

Graphics2D g = bi.createGraphics();

//the src image(and alpha channel) is simply copied

g.setComposite(AlphaComposite.Src);

g.drawImage(comboImage,0,0,width,height,null);

rob,

Abuse at 2007-7-7 12:58:43 > top of Java-index,Other Topics,Java Game Development...