第35月第29天 iOS 修改图片的亮度、对比度、饱和度

1.

UIImage *myImage = [UIImage imageNamed:@"Superman"];
CIContext *context = [CIContext contextWithOptions:nil];
CIImage *superImage = [CIImage imageWithCGImage:myImage.CGImage];
CIFilter *lighten = [CIFilter filterWithName:@"CIColorControls"];
[lighten setValue:superImage forKey:kCIInputImageKey];

// 修改亮度   -1---1   数越大越亮
[lighten setValue:@(0.2) forKey:@"inputBrightness"];

// 修改饱和度  0---2
[lighten setValue:@(0.5) forKey:@"inputSaturation"];

// 修改对比度  0---4
[lighten setValue:@(2.5) forKey:@"inputContrast"];
CIImage *result = [lighten valueForKey:kCIOutputImageKey];
CGImageRef cgImage = [context createCGImage:result fromRect:[superImage extent]];

// 得到修改后的图片
myImage = [UIImage imageWithCGImage:cgImage];

// 释放对象
CGImageRelease(cgImage);

https://blog.csdn.net/u013892686/article/details/49076621

原文地址:https://www.cnblogs.com/javastart/p/11429329.html