I am having RGB values of each pixel of an Image. Now I want to reconstruct the image using these values. How do I achieve it using java?
Asked
Active
Viewed 195 times
0
-
You utilize a graphics library. If you ask which graphics library you should use, this will become opinion based. – Ceiling Gecko Apr 01 '14 at 07:58
-
possible duplicate of [Create a buffered image from rgb pixel values](http://stackoverflow.com/questions/4617845/create-a-buffered-image-from-rgb-pixel-values) – Sorter Apr 01 '14 at 07:59
-
possible duplicate of [int array to BufferedImage](http://stackoverflow.com/questions/14416107/int-array-to-bufferedimage) – Harald K Apr 09 '14 at 22:05
1 Answers
0
There's hardly much more to say than this...
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
for (int x=0; x<w; x++)
{
for(int y=0; y<h; y++)
{
image.setRGB(x,y,rgbValueFor(x,y));
}
}
... and that you don't seem to have searched the Web or so...

Marco13
- 53,703
- 9
- 80
- 159