Android apply colorMatrix colorFilter on part of imageView with a mask(Android 在带有遮罩的部分 imageView 上应用 colorMatrix colorFilter)
问题描述
我想改变图像某些部分的亮度.我知道如何使用 ColorMatrix 来改变图像的亮度(或色调).但它将应用于整个图像.
I want to change the brightness on certain part of an image. I know how to use ColorMatrix to change the brightness(or hue) of an image. But it will be applied to the whole image.
我有一个遮罩文件(黑白图像).我想仅在该蒙版的白色部分应用亮度变化.如何在 Android 中执行此操作?
I have a mask file (black and white image). I want to apply the brightness change only on the the white part of that mask.How to do this in Android?
下面是蒙版图像和我想要得到的结果.
Below is a mask image and the result I want to get.
推荐答案
对于给定的位图和掩码:
for given bitmap and mask:
首先创建一个临时位图:
first create a temporary bitmap:
并绘制它(因为我的模拟器缩小了它,所以我放大了它):
and draw it (I scaled it up since my emulator scaled it down):
结果是:
这篇关于Android 在带有遮罩的部分 imageView 上应用 colorMatrix colorFilter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!