1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| +(void) adjustImage:(UIImage *) image container:(UIImageView *) iv{ CIImage *beginImage = [CIImage imageWithCGImage:image.CGImage]; CIFilter * filter = [CIFilter filterWithName:@"CIColorControls"]; [filter setValue:beginImage forKey:kCIInputImageKey]; NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; float lightPercent = [[ud objectForKey:@"Light"] floatValue]; float lightValue = -1 + 2*lightPercent; float contrastPercent = [[ud objectForKey:@"Contrast"] floatValue]; float contrastValue = 0 + 4*contrastPercent; float bhdPercent = [[ud objectForKey:@"Temp"] floatValue]; float bhdValue = 0 + 2*bhdPercent; [filter setValue:@(lightValue) forKey:@"inputBrightness"]; [filter setValue:@(contrastValue)forKey:@"inputContrast"]; [filter setValue:@(bhdValue) forKey:@"inputSaturation"]; CIImage *outputImage = [filter outputImage];
UIImage *newImg = [UIImage imageWithCIImage:outputImage];
[iv setImage:newImg];
}
|