我有我在其上应用两个蒙版的位图。当我在位图的右侧应用蒙版时,它可以正常工作,但之后当我在同一个位图的底部应用蒙版时,由于重新屏蔽,我在位图上有一个区域再次出现。我试图用下面的图片来解释这个问题。圈出的区域引起了问题。我希望该区域即使在重新屏蔽后也保持透明。
这是我的屏蔽功能代码被剪断。
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
.......
public void setRightMask(MyBitmap bmp, Type type) {
int maskIndex = -1;
switch(type){
case CONCAVE:
maskIndex = 0;
break;
case CONVEX:
maskIndex = 6;
break;
}
Bitmap result = Bitmap.createBitmap((int)bmp.getWidth(), (int)bmp.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(result);
canvas.drawBitmap(bmp.getBmp(), 0, 0, null);
canvas.drawBitmap(masks[maskIndex].getBmp(), bmp.getWidth() - masks[maskIndex].getBmp().getWidth(), 0, paint);
bmp.setBmp(result);
}
public void setBottomMask(MyBitmap bmp, Type type) {
int maskIndex = -1;
switch(type){
case CONCAVE:
maskIndex = 1;
break;
case CONVEX:
maskIndex = 7;
break;
}
Bitmap result = Bitmap.createBitmap((int)bmp.getWidth(), (int)bmp.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(result);
canvas.drawBitmap(bmp.getBmp(), 0, 0, null);
canvas.drawBitmap(masks[maskIndex].getBmp(), 0, bmp.getHeight() - masks[maskIndex].getBmp().getHeight(), paint);
bmp.setBmp(result);
}