Hi all!
I have two questions concerning accelerated images:
1.) Currently Im doing my all gfx stuff in int arrays. I made a wrapper
around this which will use MemoryImageSource to create images
out of the arrays when BufferedImages are not available. If BufferedImages
are available I create a bufferedimage with graphicsconfiguration.createCompatibleImage(w, h, Transparency.OPAQUE)
I get the image data with (DataBufferInt)image.getRaster().getDataBuffer();
and get its int[] contents with getData();
Will this still be accelerated? I remember reading somewhere that using getRaster
and such would prevent the bufferedimage from being accelerated?
2.) For my backbuffer I thought using volatile images would be great (if available)
But im getting very bad fps when using a volatile image to draw to the screen (compared
to writing bufferedimages or plain images directly to screen, about half the fps).
A bufferedimage is created from a int[] (see situation in q1), this bufferedimage is then
drawn onto the volatileimage (by getting the volatileimage’s graphics context). Last the
volatile image is drawn to the applet’s screen graphics. Is it performance wise good
to draw the bufferdimage to the volatileimages graphics? or would it be just as fast or
maybe faster to draw this bufferedimage directly to the screen (lets assume the bufferedimage
is not accelerated, see question nr1).
Here’s how I draw the volatileimage to the screen (assume the surface in toFront is a
non accelerated bufferedimage):
public class VolatileBackBuffer extends BackBuffer
{
protected VolatileImage buffer;
protected static Component base;
protected GraphicsConfiguration gc;
protected Graphics volatileGraphics;
public VolatileBackBuffer(Component base)
{
this.base = base;
gc = base.getGraphicsConfiguration();
}
public void toFront(Surface s, Graphics g)
{
if (buffer == null) createBackBuffer(s.width,s.height);
do
{
int valCode = buffer.validate(gc);
if (valCode == VolatileImage.IMAGE_INCOMPATIBLE)
createBackBuffer(s.width,s.height);
volatileGraphics.drawImage(s.getImage(), 0, 0, null);
g.drawImage(buffer, 0, 0, null);
} while (buffer.contentsLost());
}
public void createBackBuffer(int width, int height)
{
gc = base.getGraphicsConfiguration();
buffer = gc.createCompatibleVolatileImage(width, height);
volatileGraphics = buffer.getGraphics();
}
}
Any help is greatly appreciated!


