The method name ImageUtils.getPixelsBGR(...) is quite confusing since the returning data is in RGBA format. Reproducible with the following lines:
BufferedImage image= new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR);
image.setRGB(0, 0, (new Color(100, 0, 0, 255)).getRGB());
byte[] pixel = new byte[4];
ImageUtils.getPixelsBGR(image, 0, 1, pixel, null);
System.out.println(Arrays.toString(pixel));
I expected [-1,0,0,100] but got [100,0,0,-1]. Tested with Java 8u40 on Windows 8.1.
PS: The method does not work if the temp variable is null only for TYPE_BYTE. A structure like this would help: temp = (int[]) raster.getDataElements(x, y, w, h, temp);
The method name ImageUtils.getPixelsBGR(...) is quite confusing since the returning data is in RGBA format. Reproducible with the following lines:
I expected [-1,0,0,100] but got [100,0,0,-1]. Tested with Java 8u40 on Windows 8.1.
PS: The method does not work if the temp variable is null only for TYPE_BYTE. A structure like this would help: temp = (int[]) raster.getDataElements(x, y, w, h, temp);