Java tutorial
//package com.java2s; //License from project: Apache License import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.Canvas; import android.graphics.ColorMatrix; import android.graphics.ColorMatrixColorFilter; import android.graphics.Paint; public class Main { public static final Bitmap alpha(Bitmap bitmap, int alpha) { float[] matrixItems = new float[] { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, alpha / 255f, 0, 0, 0, 0, 0, 1 }; int width = bitmap.getWidth(); int height = bitmap.getHeight(); Bitmap alphaBitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888); Canvas canvas = new Canvas(alphaBitmap); Paint paint = new Paint(); ColorMatrix colorMatrix = new ColorMatrix(matrixItems); ColorMatrixColorFilter colorMatrixFilter = new ColorMatrixColorFilter(colorMatrix); paint.setColorFilter(colorMatrixFilter); canvas.drawBitmap(bitmap, 0, 0, paint); return alphaBitmap; } }