• Post Reply Bookmark Topic Watch Topic
  • New Topic

IndexColorModel 255 Colors to BufferedImage  RSS feed

Vince Phillips
Posts: 1
Chrome Linux Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to write an image to a .png with a 255-color indexed color model. I know usually do it like this:

but that doesn't work with models with 255 colors (as opposed to 256 colors). I'm fairly sure it is the BufferedImage creation that is the problem, as when I call model.getMapSize(), it returns the correct size.

The extra color added to the image's index is 15,15,15. I am drawing the BufferedImage by drawing a regular (BufferedImage.TYPE_INT_RGB) BufferedImage, pixel by pixel, then transposing it onto the indexed BufferedImage by drawing on it with a Graphics2D object.

Should I be something other than a BufferedImage to write the image, or should I be using a different constructor for BufferedImage, or am I doing something else wrong?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!