An IndexColorModel
is typically created from a GIF or a PNG with a PLTE (palette) chunk. BMP files with palette might also work.
Try reading a GIF file, using ImageIO.read(yourGIF)
, it should come out with an IndexColorModel
.
Another option would be to create a blank image like this, if you can live with the fixed color map:
input = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_INDEXED);
But I think for your use case, it's simpler to just create a new IndexColorModel
using predefined look-up tables. You don't need to get it from an input image.