Reputation: 103
I have an image with TYPE_3BYTE_BGR
and I want to convert it to a TYPE_INT_RGB
.
Though I have searched, I have not found a method to do this. I want to convert the image pixel by pixel. However, it seems that BufferedImage.getRGB(i, j)
doesn't work.
How can I get the RGB values in an image of type TYPE_3BYTE_BGR
?
Upvotes: 4
Views: 4027
Reputation: 27326
I'm not sure what you mean by "getRGB(i,j) doesn't work". getRGB returns a packed int; you need to decode it.
int color = image.getRGB(i,j);
int r = (argb)&0xFF;
int g = (argb>>8)&0xFF;
int b = (argb>>16)&0xFF;
int a = (argb>>24)&0xFF;
See How to convert get.rgb(x,y) integer pixel to Color(r,g,b,a) in Java?
Upvotes: 2