Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Color depth in Android

I just displayed a bitmap on a samsung galaxy 10.2. The image was created in photoshop showing some subtle change from a light red to a slightly darker red, it looked perfect on my PC, but the rendering on the tablet showed multiple bands.

I know this can be caused by insufficient colour depth... but I don't know what colour depth android devices have. Does android even specify a minimum colour depth? Is the colour depth something you can request more or less of at runtime? Is it just up to the manufacturer of the device?

enter image description here

like image 741
Mick Avatar asked Jan 12 '23 12:01

Mick


1 Answers

This is a perfect reading: Bitmap quality, banding and dithering by Romain Guy.

Answering your questions:

Does android even specify a minimum colour depth?

Android < 2.3 loads bitmaps with 16 bits color depth by default. Android >= 2.3 loads bitmaps with 32 bits by default. Quoting Romain Guy from the given article:

A much better solution is simply to render 32 bits bitmaps on 32 bits surfaces, which Android 2.3 now does by default.

The minimum for bitmaps is 8 bits, Bitmap.Config.ALPHA_8, but on 99% you shouldn't use this, but rather Bitmap.Config.ARGB_8888.

Set your Window to 32 bits (Bitmap.Config.ARGB_8888) and decode your bitmaps with 32 bits (PixelFormat.RGBA_8888). How to do it, below.

Is the colour depth something you can request more or less of at runtime? Is it just up to the manufacturer of the device?

You can set color depth of a Window or a Bitmap at anytime during the runtime.

  • For the Window with setFormat() and PixelFormat.
  • For the Bitmap with PixelFormat.
like image 123
Adam Stelmaszczyk Avatar answered Jan 18 '23 22:01

Adam Stelmaszczyk