public static int[] getPixelData(BufferedImage img, int x, int y)
{
int argb = img.getRGB(x, y);
int rgb[] = new int[]
{
((argb >> 16) & 0xfe), //red
(argb >> 8) & 0xfe, //green
(argb ) & 0xfe //blue
};
System.out.println("rgb: " + Integer.toBinaryString(rgb[0]) + " " + Integer.toBinaryString(rgb[1]) + " " +Integer.toBinaryString(rgb[2]));
return rgb;
}
o/p
rgb: 10111000 11010010 11110110 rgb: 10111010 11011010 11111100 rgb: 10101110 11010100 11110010 rgb: 10100010 11010000 11100110 rgb: 10100000 11010100 11100000 rgb: 10011110 11010110 11010100 rgb: 10011110 11011000 11001110 rgb: 10011110 11011000 11001110
这是例外
线程“主”java.lang.ArrayIndexOutOfBoundsException 中的异常:坐标超出范围!在 sun.awt.image.ByteInterleavedRaster.getDataElements(Unknown Source) at java.awt.image.BufferedImage.getRGB(Unknown Source) at get_pixel_value.getPixelData(get_pixel_value.java:52) at get_pixel_value.get_pixel_info(get_pixel_value.java:28)在 Hash_Function2.main(Hash_Function2.java:26)
我怎么能删除这个异常