Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I specify 16bit R5G6B5 pixels when creating a BufferedImage?

807588Jul 9 2009 — edited Jul 10 2009
Hello 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!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 7 2009
Added on Jul 9 2009
7 comments
977 views