how to merge with Transparent image
When we us this code with normal image it works fine
**
* Uses the detected segmentation mask to overlay the background image
*/
fun generateMaskBgImage(image: Bitmap, bg: Bitmap): Bitmap {
val bgBitmap = Bitmap.createBitmap(image.width, image.height, image.config)
for (y in 0 until maskHeight) {
for (x in 0 until maskWidth) {
val bgConfidence = ((1.0 - maskBuffer.float) * 255).toInt()
var bgPixel = bg.getPixel(x, y)
bgPixel = ColorUtils.setAlphaComponent(bgPixel, bgConfidence)
bgBitmap.setPixel(x, y, bgPixel)
}
}
maskBuffer.rewind()
return mergeBitmaps(image, bgBitmap)
}
}
however when we try to merge it with transparent image it creates a black background instead of transparent background how can we merge and keep background transparent.
how to merge with Transparent image
When we us this code with normal image it works fine
**
* Uses the detected segmentation mask to overlay the background image
*/
fun generateMaskBgImage(image: Bitmap, bg: Bitmap): Bitmap {
val bgBitmap = Bitmap.createBitmap(image.width, image.height, image.config)
}
however when we try to merge it with transparent image it creates a black background instead of transparent background how can we merge and keep background transparent.