Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

inDither = true Android

Could someone explain what is really happening when setting inDither = true in the context of configarating a bitmap in Android?

At Developer.Android one can read about the static variable

Config.RGB_565

This configuration can produce slight visual artifacts depending on the configuration of the source. For instance, without dithering, the result might show a greenish tint. To get better results dithering should be applied

I had this problem until I followed this recommendation, that is:

options.inPreferredConfig = Config.RGB_565;
options.inDither = true;

So my question: how do one understand inDither in Android. Its one thing to know when to use a syntax ... another to fully understand it.

Thanks in advance!

like image 979
Björn Hallström Avatar asked Jan 13 '23 22:01

Björn Hallström


1 Answers

When you are running low on the number of colors supported , then moving from one color to other (gradient) will cause bands to appear (less steps in between).

Dithering reduces this by placing random noise in color steps. With dither, we can use a noise of available colors to give an illusion of unavailable colors:

enter image description here

RGB_565 has low precision (2 bytes) than ARGB_8888 (4 bytes). Due to low color range, RGB_565 bitmaps can show banding and low color range. Hence, dither flag is use to improve perceived image, and give an illusion of more colors.

like image 59
S.D. Avatar answered Jan 22 '23 07:01

S.D.