Share the post "How To Change Opacity Of A Bitmap Object In Android"
A very short method to change a bitmap object’s opacity. The opacity value should be in the 0-255 range.
|
1 2 3 4 5 6 |
public static Bitmap changeOpacity(Context context, Bitmap bitmap, int opacity) { Bitmap bm = Bitmap.createBitmap(bitmap); Canvas canvas = new Canvas(bm); canvas.drawColor((opacity & 0xFF) << 24, PorterDuff.Mode.DST_IN); return new BitmapDrawable(context.getResources(), bm).getBitmap(); } |