ARGB中右移和按位与操作

/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位。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值