图片Android

时间:2017-01-29 07:25:19

标签: android image-processing

enter image description here

我希望任何图像都采用这个黑色部分的形状。我怎样才能在android中做到这一点?我有很多这样的设计。

2 个答案:

答案 0 :(得分:1)

你可以查看这个。 https://github.com/mafujuls/mafs-image-shape

整合这个lib:

dependencies {
compile 'com.mafstech.libs:mafs-image-shape:1.0.4'   
}

实现后,您只需要用一些参数编写单行代码。那就是:

Shaper.shape(MainActivity.this, R.drawable.your_image, R.drawable.your_shaped_image, your_image_view, height, weight);

更多详情:https://github.com/mafujuls/mafs-image-shape

答案 1 :(得分:0)

您可以使用OpenCV for Android解决此问题。

将要使用的图像调整为自定义图像的大小。这是我的:

enter image description here

然后我将自定义图像反转为:

enter image description here

我使用了cv2.bitwise_and()函数,如下所示:

final = cv2.bitwise_and(resized,resized,mask = thresh)
cv2.imwrite('final.jpg',final)

并获得了这个:

enter image description here

如果您使用相同的自定义图像而不反转它,您将得到:

enter image description here

希望有所帮助:)