Java Code Examples for android.graphics.Bitmap.isPremultiplied()

The following are Jave code examples for showing how to use isPremultiplied() of the android.graphics.Bitmap class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: FreeStreams-TVLauncher   File: ImageTools.java   View Source Code Vote up 6 votes
/**
 *图片阴影
 * @param originalBitmap
 */
public static Drawable drawImageDropShadow(Bitmap originalBitmap, Context context) {

    BlurMaskFilter blurFilter = new BlurMaskFilter(3,BlurMaskFilter.Blur.NORMAL);
    Paint shadowPaint = new Paint();
    shadowPaint.setAlpha(80);
    shadowPaint.setColor(context.getResources().getColor(R.color.black));
    shadowPaint.setMaskFilter(blurFilter);
    int[] offsetXY = new int[2];
    Bitmap shadowBitmap = originalBitmap.extractAlpha(shadowPaint, offsetXY);
    Bitmap shadowImage32 = shadowBitmap.copy(Bitmap.Config.ARGB_8888, true);
    if ( !shadowImage32.isPremultiplied() )
    {
        shadowImage32.setPremultiplied( true );
    }
    Canvas c = new Canvas(shadowImage32);
    c.drawBitmap(originalBitmap, offsetXY[0], offsetXY[1], null);
    return new BitmapDrawable(shadowImage32);
}
 
Example 2
Project: live_master   File: NativeBitmapFactoryTest.java   View Source Code Vote up 5 votes
private void accessBitmap(Bitmap bitmap) {
    boolean result = (bitmap != null && bitmap.getWidth() == BITMAP_WIDTH && bitmap.getHeight() == BITMAP_HEIGHT);
    if (result) {
        if (android.os.Build.VERSION.SDK_INT >= 17 && !bitmap.isPremultiplied()) {
            bitmap.setPremultiplied(true);
        }
        Canvas canvas = new Canvas(bitmap);
        Paint paint = new Paint();
        paint.setColor(Color.RED);
        paint.setTextSize(20f);
        canvas.drawRect(0f, 0f, (float) bitmap.getWidth(), (float) bitmap.getHeight(),
                paint);
        canvas.drawText("TestLib", 0, 0, paint);
    }
}