简体   繁体   English

如何在 Android Studio 中使用 JAVA 在 PNG 图像周围绘制轮廓?

[英]How to draw outline around a PNG image using JAVA in Android Studio?

I have a PNG image (with transparent background) and I want to draw an outline around its visible pixels only .我有一个 PNG 图像(具有透明背景),我只想在其可见像素周围绘制轮廓 (See example GIF attached). (见附件示例 GIF)。 I want to get this all done in JAVA .我想在JAVA中完成这一切。
I've read many Q&A over stackoverflow and around the web but I didn't find anything anyway near to my requirements.我已经阅读了许多关于 stackoverflow 和 web 的问答,但我没有找到任何符合我要求的东西。
PS: We don't have to draw the same image twice on canvas and use the bottom one as outline, so please don't propose such solutions. PS:我们不必在canvas上画两次相同的图像,并使用底部的一个作为轮廓,所以请不要提出这样的方案。
PPS: I would be great if this solution lets me draw an outline around all visible objects/elements (images & textviews etc) inside a canvas or inside a layout. PPS:如果这个解决方案能让我在 canvas 或布局内的所有可见对象/元素(图像和文本视图等)周围绘制轮廓,我会很棒。 Android Canvas 中 png 图像的轮廓

This question has already been answered on stackoverflow: Java - Create a shape from border around image这个问题已经在 stackoverflow 上得到解答: Java - Create a shape from border around image

Follow the steps from the solution and make sure that you have no opaque background on the image as that would create a square or rectangular background.按照解决方案中的步骤操作,确保图像上没有不透明的背景,因为这会创建方形或矩形背景。

..If this helped then please vote up ..如果这有帮助,请投票

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM