Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wuyang102 opened this issue Aug 9, 2015 · 1 comment

Comments

@wuyang102
Copy link

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

@plamenko
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants