Java tutorial
//package com.java2s; import android.graphics.Bitmap; import android.graphics.BlurMaskFilter; import android.graphics.Canvas; import android.graphics.Paint; public class Main { public static Bitmap setShadow(Bitmap bitmap, int radius) { BlurMaskFilter blurFilter = new BlurMaskFilter(radius, BlurMaskFilter.Blur.OUTER); Paint shadowPaint = new Paint(); shadowPaint.setAlpha(50); shadowPaint.setColor(0xff424242); shadowPaint.setMaskFilter(blurFilter); int[] offsetXY = new int[2]; Bitmap shadowBitmap = bitmap.extractAlpha(shadowPaint, offsetXY); Bitmap shadowImage32 = shadowBitmap.copy(Bitmap.Config.ARGB_8888, true); Canvas c = new Canvas(shadowImage32); c.drawBitmap(bitmap, -offsetXY[0], -offsetXY[1], null); return shadowImage32; } @Deprecated public static Bitmap setAlpha(Bitmap source, int number) { int[] argb = new int[source.getWidth() * source.getHeight()]; source.getPixels(argb, 0, source.getWidth(), 0, 0, source.getWidth(), source.getHeight()); number = number * 255 / 100; for (int i = 0; i < argb.length; i++) { argb[i] = (number << 24) | (argb[i] & 0x00FFFFFF); } return Bitmap.createBitmap(argb, source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); } }