如何将灰度变为彩色ImageView Android

时间:2013-09-28 08:42:08

标签: android imageview grayscale

我有一个应用程序。这可以将图像视图中的图像从彩色更改为灰度。但是,我希望改变相反,灰度到彩色。你能帮助我吗? 我只是将代码着色为灰度:

try {
    ImageView image = (ImageView) findViewById(R.id.imgView);
    Bitmap bMap = mPhoto;
    int width, height;
    height = bMap.getHeight();
    width = bMap.getWidth();
    mPhoto = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(mPhoto);
    Paint paint = new Paint();
    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.setSaturation(0);
    ColorMatrixColorFilter colorMatrixFilter = new ColorMatrixColorFilter(colorMatrix);
    paint.setColorFilter(colorMatrixFilter);
    canvas.drawBitmap(bMap, 0, 0, paint);
    image.setImageBitmap(mPhoto);
} catch (Exception e) { }

0 个答案:

没有答案