Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quality of rendering shadow in transparent png on Android

Tags:

android

png

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

like image 766
Lumis Avatar asked Nov 28 '25 20:11

Lumis


1 Answers

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);
like image 119
Reuben Scratton Avatar answered Nov 30 '25 11:11

Reuben Scratton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!