Android examples for Graphics:Bitmap Scale
grayscale Bitmap
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.ColorMatrix; import android.graphics.ColorMatrixColorFilter; import android.graphics.Paint; public class Main { public static Bitmap grayscaleBitmap(Bitmap bmp) { ColorMatrix cm = new ColorMatrix(new float[] { 0.3f, 0.59f, 0.11f, 0, -24, 0.3f, 0.59f, 0.11f, 0, 40, 0.3f, 0.59f, 0.11f, 0, 64, 0, 0, 0, 1, 0 });//from w ww . ja va 2 s . c o m Bitmap ret = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), bmp.getConfig()); Canvas canvas = new Canvas(ret); Paint paint = new Paint(); paint.setColorFilter(new ColorMatrixColorFilter(cm)); canvas.drawBitmap(bmp, 0, 0, paint); return ret; } }