设置为灰度图

设置为灰度图
  1. public Bitmap toGrayscale(Bitmap bmpOriginal){
  2. int width, height;
  3. height = bmpOriginal.getHeight();
  4. width = bmpOriginal.getWidth();
  5. Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
  6. Canvas c = new Canvas(bmpGrayscale);
  7. Paint paint = new Paint();
  8. ColorMatrix cm = new ColorMatrix();
  9. cm.setSaturation(0);
  10. ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
  11. paint.setColorFilter(f);
  12. c.drawBitmap(bmpOriginal, 0, 0, paint);
  13. return bmpGrayscale;
  14. }





posted @ 2016-01-04 13:00  风倾清凌  阅读(813)  评论(0编辑  收藏  举报