渲染阴影质量在Android透明PNG阴影、透明、质量、Android

2023-09-04 12:16:06 作者:哭泣是痊愈的开始

当使用一个透明的PNG图像具有优良衰落的阴影始终存在围绕Android的屏幕上的阴影边缘线。它不emualator或Exclipse显示此。见照片。

When using a transparent PNG image which has a fine fading shadow always there is an edge line around the shadow on the Android screen. It does not show this in emualator or Exclipse. See photo.

我不知道是否有办法来改善这一点。这是与Android的屏幕无法显示全部24位颜色或一个事实,即在缩放和重采样图像?

I wonder if there is way to improve on this. Is this something to do with inability of Android screen to show all 24 bit colours or the fact that is scaling and resampling image?

在这个例子中,图像加载到的ImageButton图。我尝试了作为源或背景,这是相同的质量。

In this example the image is loaded into an ImageButton view. I tried it as source or background and it is the same quality.

推荐答案

您看到的是被称为条带,它是每个像素的显示器是16位的结果的假象。

The artefact you are seeing is known as "banding" and it is a consequence of your display being 16bits per pixel.

要解决这一问题的最佳方法是添加一些噪音,以在Photoshop或Paint.NET您的图像资源。

The best way to resolve this is to add some "noise" to your image asset in Photoshop or Paint.NET.

另外,你可以设置你的窗口为32bpp的与下面的行添加到您的活动的的onCreate(),在 super.onCreate()的setContentView()

Alternatively you can set your window to be 32bpp with the following line added to your activity's onCreate(), between super.onCreate() and setContentView(). :

    getWindow().setFormat(PixelFormat.RGBA_8888);