How can I increase/decrease the brightness of UIIm

2019-06-09 18:58发布

问题:

I've an image , I want to change its brightness and I need to save the resultant image obtained from the actual image, how can I do it. I want to increase the brightness using a UIslider?

回答1:

Get the code from the Github for UIImage category here.

To brighten the image, write the code as below:

//brighten value can be obtained from slider change event from -255 to 255.
UIImage* brightImage = [originalImage brightenWithValue:sliderValue];

//Convert image into data
NSData *brightImageData = UIImagePNGRepresentation(brightImage);

//Get the path of Documents directory and store the data object to proper file


回答2:

Here's the sample code and explanation about implementing simple image processing filters (Brightness, Contrast, Saturation, Hue rotation, Sharpness) using OpenGL ES1.1. I recommend you this apple's official link here