Lumis
Lumis

Reputation: 21639

Quality of rendering shadow in transparent png on Android

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.

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?

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

alt text

Upvotes: 3

Views: 2823

Answers (1)

Reuben Scratton
Reuben Scratton

Reputation: 38707

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

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

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);

Upvotes: 11

Related Questions