Old game developper not used to new APIs...
Hi all,
About 3 years ago I was working for Ubisoft building Java games. Back then (jdk 1.1.8), the fastest way to produce images with effects and all was to manipulate the image as an array of pixels (int[], ARGB) and to use a MemoryImageSource to produce the image.
Now I feel like building a game for the fun of it, but I'm lost in all the new stuff they added. First of all, I just wanted to have an image built on an array of pixels. So I tried the following code :
DirectColorModel model = new DirectColorModel(32,0x00ff0000,0x0000ff00,0x000000ff,0xff000000);
WritableRaster raster = model.createCompatibleWritableRaster(640, 480);
int[] array = new int[640 * 480];
for (int i = 0; i < array.length; i++)
array = 0x00ff0000;
raster.setPixels(0, 0, 640, 480, array);
BufferedImage img = new BufferedImage(model, raster, true, null);
panel.getGraphics().drawImage(img, 0, 0, this);
First, I get an ArrayIndexOutOfBounds on the setPixels() call. Why is that ? I mean, I specified the width and height to 640 * 480 but seems that the raster does not have the same widht and height ?
And second, if I use like setPixels(0,0,40,40,array), it displays some weird color scheme but in the array, I set all the pixels to 0x00ff0000 (red).
Could anyone help to get started ? I guess I am missing something here.
BTW, if anyone is interested in having a colloection of nice functions to manipulate arrays of pixels, I can send my old collection through e-mail.
Max, former game prog, but da** lost in all this...

