0
得到RGB我从其他地方的代码,但我仍然混淆约使用移位寄存器的java
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值? 有人可以向我解释吗?像素是什么意思[pixel] & 0xff? thx很多之前:D
thx broo [已解决] – 2014-09-02 03:15:17
要将问题标记为已解决,请单击我答案上投票标志下方的复选标记。 – Pokechu22 2014-09-02 03:43:37