【发布时间】:2014-08-30 02:34:24
【问题描述】:
我从其他地方得到了这段代码,但我仍然对
感到困惑 final byte[] pixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
int[][] result = new int[height][width];
int k = 0;
final int pixelLength = 3;
for (int pixel = 0, row = 0, col = 0; pixel < pixels.length; pixel += pixelLength) {
int argb = 0;
int blue= (((int) pixels[pixel] & 0xff));
argb = argb + blue;
int green = (((int) pixels[pixel + 1] & 0xff) << 8);
argb = argb + green; // green)
int red = (((int) pixels[pixel + 2] & 0xff) << 16);
argb = argb + red;
result[row][col] = argb;
k++;
col++;
if (col == width) {
col = 0;
row++;
}
}
当我打印红色、绿色、蓝色时,为什么不打印 rgb 值? 有人可以向我解释吗?像素[像素] & 0xff 是什么意思? 非常感谢:D
【问题讨论】:
标签: java image-processing rgb pixel bufferedimage