4

I am developing an Image manipulation software in android.i want to change the brightness of an particular image.how it can be done in code?

ajay
  • 355
  • 3
  • 8
  • 17
  • 1
    Stack Overflow is not a code writing service. Have you got any implementation yet? Any ideas? Any code that you're already using? Where exactly in the process are you stuck? – slhck Jan 21 '11 at 09:12
  • 1
    @slhck do your work, if you have no idea how to do this, please do not showing father of stackoverflaw your self – Ashish Dwivedi May 28 '12 at 11:17
  • 2
    That's not a good argument. Everyone is entitled to vote or ask for clarification. Asking better questions results in better answers and showing research effort is one of the key factors here. This is what Stack Exchange is based on @ash – slhck May 28 '12 at 11:22

2 Answers2

7

I'm 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 could use LightningColorFilter too or ColorMatrixColorFilter. If anyone has a better (and by that I mean faster, besides using JNI which I haven't tried yet) method please let me know.

Mihai F
  • 161
  • 2
  • 3
3

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

Dave
  • 6,064
  • 4
  • 31
  • 38
  • 1
    this answer is good. but hard to understand how to use above methods without examples.. link will be helpful. – beginners Jul 16 '13 at 01:47