关于改变Bitmap透明度
2015-08-31 11:08
190 查看
/** 透明度为 0 -- 255 */
private Bitmap getAlphaBitmap(Bitmap bmp,int alpha){
Bitmap tempBmp = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), Config.ARGB_8888);
int[] oldPixes = new int[bmp.getWidth() * bmp.getHeight()];
int[] newPixes = new int[bmp.getWidth() * bmp.getHeight()];
// getPixels 颜色数组 ,起始偏移量,每行的长度,起始位置的x、y坐标,读取数组的总长度和总高度 该api目的为保存像素到数组中去
bmp.getPixels(oldPixes, 0, bmp.getWidth(), 0, 0, bmp.getWidth(), bmp.getHeight());
int color = 0;
for(int i = 1;i<oldPixes.length; i++){
color = oldPixes[i];
newPixes[i] = Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color));
}
tempBmp.setPixels(newPixes, 0, tempBmp.getWidth(), 0, 0, tempBmp.getWidth(), tempBmp.getHeight());
return tempBmp;
}
private Bitmap getAlphaBitmap(Bitmap bmp,int alpha){
Bitmap tempBmp = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), Config.ARGB_8888);
int[] oldPixes = new int[bmp.getWidth() * bmp.getHeight()];
int[] newPixes = new int[bmp.getWidth() * bmp.getHeight()];
// getPixels 颜色数组 ,起始偏移量,每行的长度,起始位置的x、y坐标,读取数组的总长度和总高度 该api目的为保存像素到数组中去
bmp.getPixels(oldPixes, 0, bmp.getWidth(), 0, 0, bmp.getWidth(), bmp.getHeight());
int color = 0;
for(int i = 1;i<oldPixes.length; i++){
color = oldPixes[i];
newPixes[i] = Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color));
}
tempBmp.setPixels(newPixes, 0, tempBmp.getWidth(), 0, 0, tempBmp.getWidth(), tempBmp.getHeight());
return tempBmp;
}
相关文章推荐
- jdbc连接postgresql
- SPOJ Optimal Marks(最小割的应用)
- 关于sd卡的读取权限
- Android中的内部类引起的内存泄露
- linux 命令汇总
- 读书笔记之UNIX环境高级编程(8)
- python 可变不可变类型
- Maven简介(三)——profile介绍
- 华为机试题
- windows服务程序
- Timer中schedule()的用法
- NSTimer
- C#日期函数使用大全
- Linux-《Linux命令行与shell脚本编程大全》阅读笔记
- 二级域名session 共享方案
- [经验总结]--关于socket通信传输非char型数组的解决方法
- HP-UNIX安装Oracle PHCO-40381
- jquery实现菜单栏选择效果
- 数据结构 时间复杂度 空间复杂度 一看就懂版本
- 基础