wood burning stoves 2.0*
The moose likes Other JSE/JEE APIs and the fly likes create image from rgb values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "create image from rgb values" Watch "create image from rgb values" New topic

create image from rgb values

shihab K Bava

Joined: Oct 03, 2004
Posts: 12

Please check my above code. I have taken rgb values of a set of images to a 3 dimentional array. Is it possible to create the buffered images from this array? That is converting the rgb values to original images? Is it possible? Please help.

Thanks aand Regards
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41141
It's not possible directly, but not hard, either. Assuming that the images are of type TYPE_INT_RGB, then the steps are roughly like this: BufferedImage.getRaster() gets you a java.awt.image.WriteableRaster which has a number of setPixel and setPixels methods you can use for filling in the RGB values.

Integer values are made up of the red value in bits 16-23, the green value in bits 8-15 and the blue value in bits 0-7. So a call to setPixel would include something like:

color.getRed() << 16 | color.getGreen() << 8 | color.getBlue()

Ping & DNS - my free Android networking tools app
It is sorta covered in the JavaRanch Style Guide.
subject: create image from rgb values
Similar Threads
Image Resizing Woes
Displaying witrh respect to path in an Applet
Is there a better way to blend colors when painting with Graphics2D?
Displaying witrh respect to path..
Displaying witrh respect to path in an Applet