Jim -
Thanks for the hints on how to build a 216-colour IndexColorModel.
However, despite what I said in the original post what I actually
need to do is process an Image rather than a BufferedImage.
I've tried doing it this way:
First, using your code to make an IndexColorModel:
// Create a 6x6x6 color cube
int[] cmap = new int[256];
int i=0;
for (int r=0; r < 256; r += 51) {
for (int g=0; g < 256; g += 51) {
for (int b=0; b < 256; b += 51) {
cmap[i++] = (r<<16)|(g<<8)|b;
}
}
}
IndexColorModel cm = new IndexColorModel(8, 216, cmap, 0,
false, -1,DataBuffer.TYPE_BYTE);
Then reading the Image data out into a pixels array:
pixels = new int[imageWidth * imageHeight];
pg = new PixelGrabber(gifImage, 0, 0, imageWidth, imageHeight,
pixels, 0, imageWidth);
try {
pg.grabPixels();
}
catch (InterruptedException e) {
System.err.println("interrupted waiting for pixels");
}
And, finally, reconstituting it with the 216-colour IndexColorModel:
Image img216 = Toolkit.getDefaultToolkit().createImage(new
MemoryImageSource(imageWidth, imageHeight, cm, pixels, 0,
imageWidth));
However, this results in an invalid image file...
Is this the way to go or should I be using an ImageFilter?
Robbie
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 2D Home Page: http://java.sun.com/products/java-media/2D/