给定一个DataBuffer中的int值,其中包含使用以下掩码打包的ARGB数据
A = 0xFF000000 R = 0xFF0000 G = 0xFF00 B = 0xFF
我正在执行以下操作,但不知道Java中是否有更快的方法?
DataBuffer db1 = img1.getData().getDataBuffer();
DataBuffer db2 = img2.getData().getDataBuffer();
int x, y;
int totalDiff = 0;
for (int i = 0; i < WIDTH * HEIGHT; ++i) {
x = db1.getElem(i);
y = db2.getElem(i);
totalDiff += Math.abs((x & 0xFF) - (y & 0xFF))
+ Math.abs(((x & 0xFF00) >> 8) - ((y & 0xFF00) >> 8))
+ Math.abs(((x & 0xFF0000) >> 16) - ((y & 0xFF0000) >> 16 ));
}
0xFF000000
和0x00FF0000
之间应该有什么区别? - Joachim Sauer