Example usage for android.graphics Bitmap extractAlpha

List of usage examples for android.graphics Bitmap extractAlpha

Introduction

In this page you can find the example usage for android.graphics Bitmap extractAlpha.

Prototype

@CheckResult
public Bitmap extractAlpha(Paint paint, int[] offsetXY) 

Source Link

Document

Returns a new bitmap that captures the alpha values of the original.

Usage

From source file:Main.java

public static Bitmap setShadow(Bitmap bitmap, int radius) {
    BlurMaskFilter blurFilter = new BlurMaskFilter(radius, BlurMaskFilter.Blur.OUTER);
    Paint shadowPaint = new Paint();
    shadowPaint.setAlpha(50);/*from  w w w.  j ava 2  s  .c o m*/
    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;
}