Reputation: 603
I need to textured some bitmap in ImageView. I use code bellow:
Bitmap original - texture;
Bitmap mask - image that I must textured;
Bitmap result - result image;
Canvas mCanvas = new Canvas(result);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
mCanvas.drawBitmap(original, 0, 0, null);
mCanvas.drawBitmap(mask, 0, 0, paint);
paint.setXfermode(null);
imgView.setImageBitmap(result);
imgView.setScaleType(ScaleType.CENTER);
it's work but I have
mask and texture result image
But I need black borders and circuit of the image. Anybody know solution how to do that?
Upvotes: 2
Views: 1217
Reputation: 603
Solution my problem was very simple. Instead
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
Need to use
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));
And everything work like charm.
Upvotes: 1