Reputation: 4472
We know that, we can get rgb of bitmap image with using the code as follow :
BufferedImage img = ImageIO.read(new File(bitmapURL));
int[] pixels = img.getRGB(0, 0, img.getWidth(), img.getHeight(), null, 0, img.getWidth());
And, after executing this parts of code, we have an array of integers that contains 4 bytes for Alpha, Red, Green and Blue
colors of any pixel. So, i want to know that how can we convert an array of integers like int [] myPixels;
to Bitmap ? Could any one please help me to reach this?
Thanks in advance :)
Upvotes: 1
Views: 4756
Reputation: 3967
You can directly use this :
image.setRGB(0, 0, width, height, pixels, 0, width);
Upvotes: 4
Reputation: 35011
BufferedImage im = new BufferedImage(width, height);
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
im.setRGB(...);
}
}
Upvotes: 0