• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

create image from rgb values

 
shihab K Bava
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Shihab
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic