有没有办法将Bitmap转换成棕褐色?
我知道转换为grayScale是在ColorMatrix中设置setSaturation.
但是如何呢?
我知道转换为grayScale是在ColorMatrix中设置setSaturation.
但是如何呢?
解决方法
如果您有图像实例,则可以使用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二进制文件进行测试,无需编译.
原文地址:https://www.jb51.cc/android/312130.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。