PorterDuffColorFilter : set Transparent Color

0

I'm trying to create a mask of bitmap code below work for all colors Hex format I put, expect the transparent.

For example changeBitmapColor(bitmap,0x00000008), The mask becomes invisible due to color, when I change the color to (for example 0xFFFF03FF), the mask appears

 private Bitmap changeBitmapColor(Bitmap sourceBitmap, int color) {
        Paint paint = new Paint();
        paint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
        Bitmap bitmapResult = Bitmap.createBitmap(sourceBitmap.getWidth(), sourceBitmap.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmapResult);
        canvas.drawBitmap(sourceBitmap, 0, 0, paint);
        return bitmapResult;
    }
java
android
colors
bitmap
porter-duff

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0