Hi, I'm working on Erase image functionality. I ha...
# compose
a
Hi, I'm working on Erase image functionality. I have two images, the first is the original image, while the second is the mask image that has white background with drawn black(with opacity) paths. I tried the following and used
BlemdMode.DstOut
to erase the black paths in mask from the original image but failed since DstOut works with transparent and opaque not white/black. Could you suggest better solution that lets me erase the black paths while leaving the white in original image as it is?
🧵 1
Copy code
Canvas(Modifier.fillMaxSize()){
    drawContext.canvas.withSaveLayer(
        Rect(Offset.Zero, size), Paint()
    ){
        drawImage(image = originalImage)

        drawImage(
            image = whiteBgBlackPathImage, // mask has white BG with black(opacity) path(s)
            blendMode = BlendMode.DstOut
        )
    }
}
r
The blend modes that start with
Src
and
Dst
are all about alpha compositing. The
Modulate
and
Multiply
modes should do what you want if you invert the mask (white where you want to keep pixels, black otherwise)
You could also convert your masks to alpha masks
👍 1