hey guys
I’m stuck again
I’ve been using these lines to render an image from an array of integers and an indexcolormodel, not excactly what one would call efficient but it works:
BufferedImage bi = Display.createCompatibleImage(this.pcxwidth, this.pcxheight);
bi.createGraphics().drawImage(Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(pcxwidth, pcxheight,
getPalette(), this.imageData, 0, pcxwidth)), null, null);
should be self-explaining, first line creates a compatible image, second creates the image from the int[] and the colormodel, and draws it to the bufferedimage.
now, I recently noticed the WriteableRaster class and thought it might be better to store the imagebytes as an object of this class, so I tried this experimental code instead of the above:
model = new MultiPixelPackedSampleModel(DataBufferInt.TYPE_INT, this.pcxwidth, this.pcxheight, 8);
buffer = new DataBufferInt(this.imageData, this.imageBytes);
WritableRaster sup = WritableRaster.createWritableRaster(model, buffer, new Point(0, 0));
BufferedImage bi = new BufferedImage(getPalette(), sup, false, null);
it creates a multipixelpackedsamplemodel and a WriteableRaster from the imageData array, both are passed to the bufferedimage constructor. now, this has one big disadvantage: it doesn’t work. the image looks like every ~10th pixel is drawn.
ideas?