在Android中将位图转换为棕褐色

在Android中将位图转换为棕褐色,第1张

概述有没有办法将Bitmap转换成棕褐色? 我知道转换为grayScale是在ColorMatrix中设置setSaturation. 但是如何呢? 如果您有图像实例,则可以使用ColorMartix将其绘制在Sepia中.让我描述如何使用Drawable来做到这一点. public static void setSepiaColorFilter(Drawable drawable) { if ( 有没有办法将Bitmap转换成棕褐色? @H_301_2@我知道转换为grayScale是在colorMatrix中设置setSaturation. @H_301_2@但是如何呢?解决方法 如果您有图像实例,则可以使用colorMartix将其绘制在Sepia中.让我描述如何使用Drawable来做到这一点.
public static voID setSepiacolorFilter(Drawable drawable) {  if (drawable == null)    return;  final colorMatrix matrixA = new colorMatrix();  // making image B&W  matrixA.setSaturation(0);  final colorMatrix matrixB = new colorMatrix();  // applying scales for RGB color values  matrixB.setScale(1f,.95f,.82f,1.0f);  matrixA.setConcat(matrixB,matrixA);  final colorMatrixcolorFilter filter = new colorMatrixcolorFilter(matrixA);  drawable.setcolorFilter(filter);}

示例项目从Bitbucket移动到GitHub.请检查Release section下载APK二进制文件进行测试,无需编译.

总结

以上是内存溢出为你收集整理的在Android中将位图转换为棕褐色全部内容,希望文章能够帮你解决在Android中将位图转换为棕褐色所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1132701.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存