彩色照片转化为黑白照片
来源:互联网 发布:单片机小车制作 编辑:程序博客网 时间:2024/06/12 01:15
/** * 将彩色图转换为纯黑白二色 * * @param bmp 位图 * @return 返回转换好的位图 */ public static Bitmap convertToBlackWhite(Bitmap bmp) { int width = bmp.getWidth(); // 获取位图的宽 int height = bmp.getHeight(); // 获取位图的高 int[] pixels = new int[width * height]; // 通过位图的大小创建像素点数组 bmp.getPixels(pixels, 0, width, 0, 0, width, height); int alpha = 0xFF << 24; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { int grey = pixels[width * i + j]; //分离三原色 int red = ((grey & 0x00FF0000) >> 16); int green = ((grey & 0x0000FF00) >> 8); int blue = (grey & 0x000000FF); //转化成灰度像素 grey = (int) (red * 0.3 + green * 0.59 + blue * 0.11); grey = alpha | (grey << 16) | (grey << 8) | grey; pixels[width * i + j] = grey; } } //新建图片 Bitmap newBmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); //设置图片数据 newBmp.setPixels(pixels, 0, width, 0, 0, width, height); Bitmap resizeBmp = ThumbnailUtils.extractThumbnail(newBmp, 380, 460); return resizeBmp; }
1 0
- 彩色照片转化为黑白照片
- 将彩色照片变成黑白照片
- ps彩色照片变黑白照片
- 【PS】黑白照片改为彩色照片
- Flex3学习轨迹:将彩色照片转换成黑白照片
- 彩色图片转换为黑白照片
- 黑白照片
- 在网页中利用css滤镜将彩色照片处理为黑白
- 给黑白照片上色!
- Python 把蓝底照片转化为白底照片
- C++ opencv把蓝底照片转化为白底照片
- [转帖]Photoshop为外国美女黑白照片上色
- [转帖]Photoshop为外国美女黑白照片上色
- JNI下使用AndroidBitmap_lockPixels修改位图为黑白照片
- 彩色证件照片背景RGB
- C#将照片或图片转化为byte[]存入数据库,从数据库中读照片
- 照片
- 照片
- 程序的调试
- Unix环境高级编程中头文件apue.h的问题
- PHP 销毁指定目录
- 001-021-merger two sorted List 归并两个已排序的链表
- ipython web server 配置
- 彩色照片转化为黑白照片
- centos7 配置java环境变量
- 【Java 源码技术】--Difference between HashMap and ConcurrentHashMap(165)
- 数据结构之字符串
- Java Graphics2D绘制验证码
- elasticsearch介绍之安装(一)
- vim filetype
- solr6的学习与使用(四):数据导入功能
- CodeForces723C Polycarp at the Radio 贪心