9 patch editor android studio suddenly black

别来无恙 提交于 2019-12-06 05:26:17

Question is old, but I have run into this issue 5 minutes ago. The problem occur when I save custom .png in paint.net and choose option for depth color "auto-detection". But when I saved it with with color depth "32 bit" all ok, and background is transparent.

I have the similar problem, right-click to select "Create 9-Patch file...", the transparent area become black. It only occur in some images after converted by ImageMagick.

Check the image details by pngcheck tool:

xb@dnxb:/tmp$ pngcheck msg_box.png #original image
OK: msg_box.png (2251x967, 32-bit RGB+alpha, non-interlaced, 99.9%).

It becomes palette+trns after converted by ImageMagick:

xb@dnxb:/tmp$ convert msg_box.png -transparent white -trim msg_trim.png
xb@dnxb:/tmp$ pngcheck msg_trim.png 
OK: msg_trim.png (394x311, 8-bit palette+trns, non-interlaced, 98.5%).

The solution is prefix the image with png32 to force it outputs RGBA:

xb@dnxb:/tmp$ convert msg_box.png -transparent white -trim png32:msg_trim.png
xb@dnxb:/tmp$ pngcheck msg_trim.png                                                                          
OK: msg_trim.png (394x311, 32-bit RGB+alpha, non-interlaced, 99.4%).                                                                                  
xb@dnxb:/tmp$ 

Now when I paste this image in Android Studio and right-click to select "Create 9-Patch file...", then it able to keep transparent instead of black.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!