/2016/07/04///
/by xbw///
/环境 eclipse///
干点本专业的事情吧,嘿嘿
public BufferedImage filter(BufferedImage src) {
int width = src.getWidth();
int height = src.getHeight();
int[] inPixels = new int[width*height];
for(int row=0; row<height; row++) {
int ta = 0, tr = 0, tg = 0, tb = 0;
for(int col=0; col<width; col++) {
index = row * width + col;
ta = (inPixels[index] >> 24) & 0xff;
tr = (inPixels[index] >> 16) & 0xff;
tg = (inPixels[index] >> 8) & 0xff;
tb = inPixels[index] & 0xff;
}
}
}
首先,RGB格式的颜色格式为:高8位红色,中间8位绿色,低8位蓝色;
其次,A& 0xff的作用是只要A的低8位;
tr = (inPixels[index] >> 16) & 0xff;右移16位之后原来的高8位就在低8位的位置上了,再与0xff就只剩下了原来的高8位;
tg = (inPixels[index] >> 8) & 0xff;右移8位之后原来的中间8位就在低8位的位置上了,再与0xff就只剩下了原来的中间8位;
tb = inPixels[index] & 0xff;与0xff就直接得到了低8位。