设置为灰度图

设置为灰度图
     
     
     
     
  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. }



来自为知笔记(Wiz)


你可能感兴趣的:(设置为灰度图)