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

有没有办法将Bitmap转换成棕褐色?
我知道转换为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二进制文件进行测试,无需编译.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...