How do I specify 16bit R5G6B5 pixels when creating a BufferedImage?
807588Jul 9 2009 — edited Jul 10 2009Hello All,
I'm trying to load raster data from an image file and it may contain different bit depths. I'm loading this data into a BufferedImage using the constructor
BufferedImage(ColorModel cm, WritableRaster raster, boolean isRasterPremultiplied, Hashtable<?,?> properties)
I'm trying to figure out how to specify the exact way the pixels are stored, but I'm having a really hard time. It seems that I would want to put this information in the ColorModel, but I can't find anything to specify that. The WritableRaster is another place I looked, but when I create that, it also doesn't ask for (or I don't know how to provide) the specific color info. I have a file that stores it's pixel data in 16 bits, but the colors are separated out by Red (5bits) Green(6bits) Blue(5bits). I have the hex color masks for the color, but I don't know how to use them without first creating a BufferedImage, then using a PixelGrabber or other such process for editing the pixels after the fact. I'd like to be able to specify the the info when I create the image. Can anybody help me?
Thank you!