Reputation: 9893
I need to adjust the contrast and brightness of the CGImageRef
my means of CoreGraphics/Quartz.
Any ideas how to do it ?
Quartz guildeline and online search didn't give many results.
Please don't refer to OpenGL solution.
Upvotes: 0
Views: 1858
Reputation: 171
also if you want to improve the behavior you can use GCD, enjoy!
CIContext *ctxt63 = [CIContext contextWithOptions:nil];
CIFilter *filter63 = [CIFilter filterWithName:@"CIColorControls"];
[filter63 setDefaults];
[filter63 setValue:input forKey:kCIInputImageKey];
[filter63 setValue:@1.8 forKeyPath:kCIInputSaturationKey];
[filter63 setValue:[NSNumber numberWithFloat:0.8] forKey:@"inputBrightness"];
[filter63 setValue:[NSNumber numberWithFloat:3.0] forKey:@"inputContrast"];
CIImage *output63 = [filter63 outputImage];
//Aplicar el filtro en segundo plano
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
CGImageRef res63 = [ctxt63 createCGImage:output63 fromRect:[output63 extent]];
dispatch_async(dispatch_get_main_queue(), ^{
UIImage *img63 = [UIImage imageWithCGImage:res63];
CGImageRelease(res63);
self.photoView.image = img63;
});
});
Upvotes: 0
Reputation: 96363
You want Core Image. The filter for your purpose is CIColorControls.
Upvotes: 1