How to change image brightness in Android?

I am developing image processing software in android.i to change the brightness of a particular image. How can this be done in code?

+4
source share
2 answers

I am using something like this at the moment:

if (brighter) { darknessPaint.setColorFilter(new PorterDuffColorFilter(Color.argb(level, 255, 255, 255), Mode.SRC_OVER)); } else { darknessPaint.setColorFilter(new PorterDuffColorFilter(Color.argb(level, 0, 0, 0), Mode.SRC_ATOP)); } darknessCanvas.setBitmap(dst); darknessCanvas.drawBitmap(src, 0, 0, darknessPaint); 

Indeed, you can use LightningColorFilter or ColorMatrixColorFilter. If anyone has the best (and I mean, it's faster than using JNI, which I haven't tried yet), please let me know.

+7
source

You probably want to look at LightingColorFilter and Drawable , or if you want to do the manipulation manually, look at Bitmap - specifically getPixels and setPixels (or copyPixelsFromBuffer and copyPixelsToBuffer if you want).

+3
source

Source: https://habr.com/ru/post/1336431/


All Articles