如何借鉴使用其他位图作为掩码位图? [英] How to draw on bitmap using another bitmap as mask?

查看:245
本文介绍了如何借鉴使用其他位图作为掩码位图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要的的使用另一个位图作为掩码的位图。掩码是黑色的位图,在它透明物体。我希望此透明部分也可以填充有任意颜色,并添加到我的原始图像。如何才能做到这一点?

I want to draw on a bitmap using another bitmap as mask. The mask is a black bitmap with a transparent object in it. I want this transparent part to be filled with an arbitrary color and added to my original image. How can this be done?

推荐答案

我不得不通过@Christian描述来改变口罩。然后,想要的结果可以很容易地制备:

I had to change the masks as described by @Christian. Then, the wanted result could easily be produced:

canvas.drawRect(rect, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
canvas.drawBitmap(mask, 0.0f, 0.0f, paint);

这篇关于如何借鉴使用其他位图作为掩码位图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆