mortennobel / java-image-scaling

Automatically exported from code.google.com/p/java-image-scaling
Other
130 stars 41 forks source link

Confusing ImageUtils.getPixelsBGR(...) method name #38

Open Neiko2002 opened 9 years ago

Neiko2002 commented 9 years ago

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);