简体   繁体   中英

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 . (See example GIF attached). I want to get this all done in JAVA .
I've read many Q&A over stackoverflow and around the web but I didn't find anything anyway near to my requirements.
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.
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. Android Canvas 中 png 图像的轮廓

This question has already been answered on 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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