简体   繁体   English

在Android中可绘制半透明图形,但边缘黑

[英]Drawing translucency drawable in Android, but black edge

I have the below image (the white bubble in the image) to draw in a canvas. 我有下面的图像(图像中的白色气泡)在画布上绘制。 When I draw the image using the code.., the image 's edge is getting black circle and rounded .. the edge's alpha is 0x00. 当我使用代码绘制图像时,图像的边缘逐渐变黑并变圆。边缘的Alpha为0x00。

image.setBounds(left, top, right, bottom); image.setBounds(left,top,right,bottom);

image.draw(canvas); image.draw(画布);

Expected 预期 替代文字 When I draw 当我画画时 替代文字

How could I remove the black circle??? 我如何去除黑圈??? Is the image wrong?? 图像不对吗? or Anyone know the clue, Please give me a clue.. Thanks in advance.. 或任何人都知道该线索,请给我一个线索..在此先感谢..

^^ ^^

Is your expected output taken from an image editor (Photoshop?) If so, that'll be the result of a 32-bit blend, whereas it looks like the alpha-blend on Android is being performed in 16-bits, hence the banding in the background, and halo around your image. 您的预期输出是从图像编辑器(Photoshop?)获得的吗?如果是,那是32位混合的结果,而Android上的alpha混合似乎是以16位执行的,因此条带化在背景中,并在您的图像周围散发出光晕。

Presuming you're using Bitmap objects, you can check whether this is the case by calling bitmap.getConfig() to find their colour depth (from the Bitmap.Config enum). 假设您使用的是Bitmap对象,则可以通过调用bitmap.getConfig()来查找其颜色深度(从Bitmap.Config枚举中)来检查是否存在这种情况。

Edit : One more thing that may be causing the halo - you say the edges of your sprite have an alpha of 0, but what about the RGB values? 编辑 :可能会引起光环的另一件事-您说精灵的边缘的alpha为0,但是RGB值呢? Make sure the ARGB is set to full-white (ARGB 0x00ffffff) rather than black (ARGB 0x00000000). 确保将ARGB设置为全白(ARGB 0x00ffffff),而不是黑色(ARGB 0x00000000)。

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

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