android调整图片的色相,饱和度,灰度
android调整图片的色相,饱和度,灰度
/*** 调整图片的色相,饱和度,灰度** @param srcBitmap* @param rotate* @param saturation* @param scale* @return*/public static Bitmap changeImageTheme(Bitmap srcBitmap, float rotate, float saturation, float scale) {//调整色相ColorMatrix rotateMatrix = new ColorMatrix();rotateMatrix.setRotate(0, rotate);rotateMatrix.setRotate(1, rotate);rotateMatrix.setRotate(2, rotate);//调整色彩饱和度ColorMatrix saturationMatrix = new ColorMatrix();saturationMatrix.setSaturation(saturation);//调整灰度ColorMatrix scaleMatrix = new ColorMatrix();scaleMatrix.setScale(scale, scale, scale, 1);//叠加效果ColorMatrix colorMatrix = new ColorMatrix();colorMatrix.postConcat(rotateMatrix);colorMatrix.postConcat(saturationMatrix);colorMatrix.postConcat(scaleMatrix);//创建一个大小相同的空白BitmapBitmap dstBitmap = Bitmap.createBitmap(srcBitmap.getWidth(), srcBitmap.getHeight(), Bitmap.Config.ARGB_8888);//载入Canvas,PaintCanvas canvas = new Canvas(dstBitmap);Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));//绘图canvas.drawBitmap(srcBitmap, 0, 0, paint);return dstBitmap;}/*** 通过更改图片像素点的RGBA值,生成底片效果** @param scrBitmap* @return*/public static Bitmap beautyImage(Bitmap scrBitmap) {int width = scrBitmap.getWidth();int height = scrBitmap.getHeight();int count = width * height;int[] oldPixels = new int[count];int[] newPixels = new int[count];scrBitmap.getPixels(oldPixels, 0, width, 0, 0, width, height);for (int i = 0; i < oldPixels.length; i++) {int pixel = oldPixels[i];int r = Color.red(pixel);int g = Color.green(pixel);int b = Color.blue(pixel);r = 255 - r;g = 255 - g;b = 255 - b;if (r > 255) {r = 255;}if (g > 255) {g = 255;}if (b > 255) {b = 255;}if (r < 0) {r = 0;}if (g < 0) {g = 0;}if (b < 0) {b = 0;}newPixels[i] = Color.rgb(r, g, b);}Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);bitmap.setPixels(newPixels, 0, width, 0, 0, width, height);return bitmap;}// 黑白public static final float colormatrix_heibai[] = {0.8f, 1.6f, 0.2f, 0,-163.9f, 0.8f, 1.6f, 0.2f, 0, -163.9f, 0.8f, 1.6f, 0.2f, 0,-163.9f, 0, 0, 0, 1.0f, 0};// 怀旧public static final float colormatrix_huaijiu[] = {0.2f, 0.5f, 0.1f, 0,40.8f, 0.2f, 0.5f, 0.1f, 0, 40.8f, 0.2f, 0.5f, 0.1f, 0, 40.8f, 0,0, 0, 1, 0};// 哥特public static final float colormatrix_gete[] = {1.9f, -0.3f, -0.2f, 0,-87.0f, -0.2f, 1.7f, -0.1f, 0, -87.0f, -0.1f, -0.6f, 2.0f, 0,-87.0f, 0, 0, 0, 1.0f, 0};// 淡雅public static final float colormatrix_danya[] = {0.6f, 0.3f, 0.1f, 0,73.3f, 0.2f, 0.7f, 0.1f, 0, 73.3f, 0.2f, 0.3f, 0.4f, 0, 73.3f, 0,0, 0, 1.0f, 0};// 蓝调public static final float colormatrix_landiao[] = {2.1f, -1.4f, 0.6f,0.0f, -71.0f, -0.3f, 2.0f, -0.3f, 0.0f, -71.0f, -1.1f, -0.2f, 2.6f,0.0f, -71.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f};// 光晕public static final float colormatrix_guangyun[] = {0.9f, 0, 0, 0, 64.9f,0, 0.9f, 0, 0, 64.9f, 0, 0, 0.9f, 0, 64.9f, 0, 0, 0, 1.0f, 0};// 梦幻public static final float colormatrix_menghuan[] = {0.8f, 0.3f, 0.1f,0.0f, 46.5f, 0.1f, 0.9f, 0.0f, 0.0f, 46.5f, 0.1f, 0.3f, 0.7f, 0.0f,46.5f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f};// 酒红public static final float colormatrix_jiuhong[] = {1.2f, 0.0f, 0.0f, 0.0f,0.0f, 0.0f, 0.9f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.8f, 0.0f, 0.0f,0, 0, 0, 1.0f, 0};// 胶片public static final float colormatrix_fanse[] = {-1.0f, 0.0f, 0.0f, 0.0f,255.0f, 0.0f, -1.0f, 0.0f, 0.0f, 255.0f, 0.0f, 0.0f, -1.0f, 0.0f,255.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f};// 湖光掠影public static final float colormatrix_huguang[] = {0.8f, 0.0f, 0.0f, 0.0f,0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.9f, 0.0f, 0.0f,0, 0, 0, 1.0f, 0};// 褐片public static final float colormatrix_hepian[] = {1.0f, 0.0f, 0.0f, 0.0f,0.0f, 0.0f, 0.8f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.8f, 0.0f, 0.0f,0, 0, 0, 1.0f, 0};// 复古public static final float colormatrix_fugu[] = {0.9f, 0.0f, 0.0f, 0.0f,0.0f, 0.0f, 0.8f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f,0, 0, 0, 1.0f, 0};// 泛黄public static final float colormatrix_huan_huang[] = {1.0f, 0.0f, 0.0f,0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f,0.0f, 0, 0, 0, 1.0f, 0};// 传统public static final float colormatrix_chuan_tong[] = {1.0f, 0.0f, 0.0f, 0,-10f, 0.0f, 1.0f, 0.0f, 0, -10f, 0.0f, 0.0f, 1.0f, 0, -10f, 0, 0,0, 1, 0};// 胶片2public static final float colormatrix_jiao_pian[] = {0.71f, 0.2f, 0.0f,0.0f, 60.0f, 0.0f, 0.94f, 0.0f, 0.0f, 60.0f, 0.0f, 0.0f, 0.62f,0.0f, 60.0f, 0, 0, 0, 1.0f, 0};// 锐色public static final float colormatrix_ruise[] = {4.8f, -1.0f, -0.1f, 0,-388.4f, -0.5f, 4.4f, -0.1f, 0, -388.4f, -0.5f, -1.0f, 5.2f, 0,-388.4f, 0, 0, 0, 1.0f, 0};// 清宁public static final float colormatrix_qingning[] = {0.9f, 0, 0, 0, 0, 0,1.1f, 0, 0, 0, 0, 0, 0.9f, 0, 0, 0, 0, 0, 1.0f, 0};// 浪漫public static final float colormatrix_langman[] = {0.9f, 0, 0, 0, 63.0f,0, 0.9f, 0, 0, 63.0f, 0, 0, 0.9f, 0, 63.0f, 0, 0, 0, 1.0f, 0};// 夜色public static final float colormatrix_yese[] = {1.0f, 0.0f, 0.0f, 0.0f,-66.6f, 0.0f, 1.1f, 0.0f, 0.0f, -66.6f, 0.0f, 0.0f, 1.0f, 0.0f,-66.6f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f};
android调整图片的色相,饱和度,灰度相关推荐
- python numpy opencv调整图片亮度对比度饱和度
python 调整图片亮度对比度饱和度 安装依赖库 亮度变换 对比度变换 综合调整(完整代码) (想要完整代码直接划到最后) 原理比较简单,本质上是对图像各个通道的每个像素点做线性变换,对超出范围[0 ...
- 修改图片颜色 色相 饱和度 亮度 ColorMatrix
Android开发中经常会遇到一些简单的图片处理,比如修改图片的颜色,饱和度,亮度等.今天就给大家介绍一下简单的图片处理. 基础知识 颜色的三要素 色调(色相/颜色):物体的颜色: 饱和度(彩度):色 ...
- C++实现Photoshop色相/饱和度/明度功能
本文用C++实现Photoshop色相/饱和度/明度功能,界面程序使用BCB6:图片操作采用GDI+.代码也可适用于其它C/C++编译器(可能要稍作修改). 有关Photoshop饱和度调整原理可参见 ...
- 在QT框架下进行仿照PS图像调整功能设计(亮度对比度,色相饱和度及明度)
原文链接:https://blog.csdn.net/maozefa/article/details/4778934 图像亮度调整分为非线性和线性两种方法. 非线性图像亮度是将图像像素的R.G.B分别 ...
- PHP调整图片饱和度,window_Win10系统电脑屏幕的饱和度如何调整?,什么是饱和度?
对电脑来说 - phpStudy...
Win10系统电脑屏幕的饱和度如何调整? 什么是饱和度? 对电脑来说,饱和度是指色彩的鲜艳程度,也称之为色彩的纯度. Win10系统电脑屏幕的饱和度如何调整?很多朋友都不是很清楚,其实方法很简单的,下 ...
- Android学习之复选框checkbox自定义样式以及调整图片大小
1.自定义样式: 下载复选框样式图:https://www.iconfont.cn/home/index?spm=a313x.7781069.1998910419.2 图片重命名为英文(否则找不到)并 ...
- Android调整Bitmap图片大小
#Android调整Bitmap图片大小 /*** 调整图片大小* * @param bitmap* 源* @param dst_w* 输出宽度* @param dst_h* 输出高度* @retur ...
- 借用gamma校正的方法来调整图片(灰度)亮度(解决侧光问题)并将其再次保存为RGB图片
近期在图片处理环节的时候,遇见了一个调整图片亮度的问题,这里需要调整整个图片的亮度,使得整体亮度较为均匀,根据网上查找,我最后确定使用gamma校正的方法来完成这个任务. 首先需要知道gamma校正是 ...
- 用OpenCV实现Photoshop算法(七): 调整色相饱和度
系列文章: 用OpenCV实现Photoshop算法(一): 图像旋转 用OpenCV实现Photoshop算法(二): 图像剪切 用OpenCV实现Photoshop算法(三): 曲线调整 用Ope ...
最新文章
- 必要时调整应用程序每个辅助进程的线程数
- 【组队学习】【23期】Datawhale编程实践(区块链)
- xieshiran:使用 R 语言开发评分卡模型
- SAP Spartacus checkout 流程使用 url 粘贴直接跳转到 delivery mode不能打开页面的原因
- GCD and LCM Aizu - 0005(辗转相除)+GCD LCM Inverse POJ - 2429(java或【Miller Rabin素数測试】+【Pollar Rho整数分解】)
- 可以在xml中靠增加属性来实现分组
- 9.MySQL数据查询SQL
- Node.js v11.0 正式发布!
- 《不要做浮躁的嵌入式工程师》观后感
- 二维数组转化稀疏数组
- cloudera-scm-service报错server已死,但pid文件仍存问题解决
- linux时间戳简介,linux 时间戳
- python没有缩进错误但报缩进_Python:“缩进错误:unindent与任何外部缩进级别都不匹配”...
- 信息炸弹——Message Boom
- EXCEL批量修改文件名
- 证券业数据大集中及其风险控制分析
- Method类的使用
- VM虚拟机安装及应用
- 1. 机器学习概述与特征工程
- 超简单、超实用的统计方法——因子分析
热门文章
- 搜狗蜘蛛池批量推送-搜狗蜘蛛池打造
- Golang语言环境安装
- 名编辑电子杂志大师教程 | 添加文本(纯文本文字,动态文字)
- 开启设计之门 设计基础教程之构图篇
- ICPLUS/九旸 IP179N/NI/H/HI功能,特性和应用范围说明;
- 电脑基础c语言,[电脑基础知识]c语言教案.ppt
- 【CAD二次开发】-ObjectARX-光标提示实体信息(EntInfoTip)
- 用html批量绘制k线图,10分钟学会ikvStockChart制作K线图(股票走势图)
- Azkaban——使用指南
- adobe reader linux rpm,Ubuntu 12.04安装Adobe Reader