Reputation: 800
I'm trying to convert an image I get from a rest call to a greyscale, however I need to keep the transparency because the image is an overlay on a map. I tried :
Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
Canvas c = new Canvas(bmpGrayscale);
Paint paint = new Paint();
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0);
ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
paint.setColorFilter(f);
c.drawBitmap(bmpOriginal, 0, 0, paint);
But it doesn't keep the transparency ... so if any of you has an idea I'll be glad to test it.
Thanks !
Upvotes: 0
Views: 545
Reputation: 12121
Your Bitmap.Config is RGB_565 which doesn't have an alpha which is the transparency layer. Try ARGB_8888.
Upvotes: 3