位图保持透明,但设置为imageview时变为不透明

时间:2017-01-16 03:51:06

标签: android opencv image-processing bitmap java-native-interface

我使用OpenCV实现简单的操作,如果Mat的像素(x,y)的颜色等于白色,则会变为透明(alpha = 0)。之后,将Mat转换为bitmap

enter image description here

调试返回的位图是正确的,但是当我将其设置为imageview时,返回的图像仍然具有白色背景(如在原始图像中)而不是透明图像。

这是原始图像(带白色背景)

enter image description here

调试图片,透明背景

enter image description here

请帮我修理一下:(

1 个答案:

答案 0 :(得分:0)

在ImageView中添加以下行

android:background="@android:color/transparent"