fresco icon indicating copy to clipboard operation
fresco copied to clipboard

handle bitmap in postprocessor will lead to the bitmap has a black background

Open wuyang102 opened this issue 11 years ago • 1 comments

I try to show image with a bubble shape. And handle the bitmap in postprocessor. It runs normally on 5.0. But the image has a black background color on 4.4.2 even I set the background color to transparent.

Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));

public CloseableReference<Bitmap> process(Bitmap bitmap, PlatformBitmapFactory platformBitmapFactory) {
        Matrix matrix = new Matrix();
        if (mScale != 1) {
            matrix.postScale(mScale, mScale);
        }

        CloseableReference<Bitmap> bitmapReference = platformBitmapFactory.createBitmap(mWidth, mHeight);
        Canvas canvas = new Canvas(bitmapReference.get());

        Resources resources = mRootView.getResources();
        NinePatchDrawable drawable = (NinePatchDrawable) resources.getDrawable(getBubbleResource());
        if (drawable != null) {
            drawable.setBounds(0, 0, mWidth, mHeight);
            drawable.draw(canvas);
        }
        canvas.drawBitmap(bitmap, matrix, mPaint);
        return CloseableReference.cloneOrNull(bitmapReference);
}

screenshot_2015-08-09-17-13-08

wuyang102 avatar Aug 09 '15 09:08 wuyang102

Do bitmapReference.get().setHasAlpha(true);

plamenko avatar Aug 10 '15 11:08 plamenko