Christopher Deckers wrote:
One thing you might want to do is to get the backing array for each of
the images. I've found reading/writing pixels directly to be a lot
faster than the getRGB()/setRGB() calls.
e.g.
int[] pixels = ((DataBufferInt)
newImage.getRaster().getDataBuffer()).getData();
I have to admit I am a bit lost in all those Image-related APIs. Image
handling (rasters, color models, etc.) is an area where I need to
learn a bit more. Any pointers to resources to learn about all these
internal details?
Good places for info are the java2d forums on java.net and the
javagaming.org 2D forums.
In the call you describe, I guess I can modify the ARGB values
directly in the array of pixels, but how do I apply my new array?
That array (for a TYPE_INT_ARGB or TYPE_INT_RGB BufferedImage) is the
actual array of pixels the BufferedImage uses as its backing store, so
changing the values in the array is the same as the setRGB() call - but
much faster.
The only caveat is that getting the Raster for the BufferedImage
unmanages it - i.e. it can't be accelerated (put into VRAM) anymore, so
if you draw from it a lot (e.g. uses it as the first param in a
Graphics.drawImage() call), then you might want to draw it into a new
BufferedImage or VolatileImage once you have done bit twiddling it.
Usually you don't need to worry about that though.