public static Color[][] byteArrayToColors(byte[] bytes){
BufferedImage paintImage=null;
try {
InputStream inputStream = new ByteArrayInputStream(bytes);
paintImage = ImageIO.read(inputStream);
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
Color[][] cols = new Color[paintImage.getWidth()][paintImage.getHeight()];
for(int z = 0;z < paintImage.getWidth();z++){
for(int a = 0;a < paintImage.getHeight();a++){
int color = paintImage.getRGB(z, a);
int red = (color & 0x00ff0000) >> 16;
int green = (color & 0x0000ff00) >> 8;
int blue = color & 0x000000ff;
int alpha = (color>>24) & 0xff;
Color col = new Color(red,green,blue,alpha);
cols[z][a] = col;
}
}
return cols;
}
# 1 楼答案
在Java中,您可以这样做