Search the forums, its been covered many times before.
but cos i'm nice, i'll summarise it here
Images returned from these methods are 'ManagedImages' (previously known as Automatic Images)
This means they are elligable for caching in VRAM, and hence are hardware accelerated.
These slides maybe helpful :-http://servlet.java.sun.com/javaone/resources/content/sf2003/conf/sessions/pdfs/1402.pdf
and also, this example program :-http://www.pkl.net/~rsc/downloads/Balls.jar
Images returned from ImageIO.read() are not accelerated (in the current java version, though I believe the intention is to make them so)
If you want to load images using ImageIO, you must then subsequently copy the image into a ManagedImage.
The code to do that will look something like this :-
public class ImageLoader
final GraphicsConfiguration gc;
public ImageLoader(GraphicsConfiguration gc)
gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
this.gc = gc;
public BufferedImage loadImage(String resource, int transparencyType)
BufferedImage src = javax.imageio.ImageIO.read(getClass().getResource(resource));
BufferedImage dst = gc.createCompatibleImage(src.getWidth(),src.getHeight(),transparencyType);
Graphics2D g2d = dst.createGraphics();
Currently accelerated Transparency is only possible using ManagedImages. (not with VolatileImages)
Also, currently only bitmask transparency is *by default* accelerated.
However, there are flags to enabled hardware acceleration for images with a full alpha channel (Translucent). These flags also make AlphaComposite operations hardware accelerated.
The code to set the flags is :-
This Thread covers the flags in more detailhttp://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=2D;action=display;num=1048663269;start=0#0