Learning Android Development

Android Image Lighting Control and Color Filtering

Easily adjust image brightness and color filtering with Android’s LightingColorFilter

Photo by bedrck on Pixabay

Given an image, how could we make it brighter or darker in Android? Some might think of using another layer of color, but that’s not ideal.

Fortunately, Android provides us with a LightingColorFilter class that can easily adjust the brightness of an image.

image_background.colorFilter = LightingColorFilter(mul, add)

Below is the sample app I use to adjust the lighting.

Explaining Mul and Add

In the API description provided, the explanation is not very clear.

/**
* Create a colorfilter that multiplies the RGB channels by one
* color, and then adds a second color. The alpha components of the
* mul and add arguments are ignored.
*/

Formal description

Let me share the description mathematically (as there are multiplications and additions).

--

--