I\'m creating a color picker for iOS. I would like to enable the user to select the brightness (luminance) and have the color wheel reflect this change. I\'m using Core Imag
Try this and change value using a slider:-
- (void)viewDidLoad{
UIImage *aUIImage = showPickedImageView.image;
CGImageRef aCGImage = aUIImage.CGImage;
aCIImage = [CIImage imageWithCGImage:aCGImage];
context = [[CIContext contextWithOptions:nil] retain];
brightnessFilter = [[CIFilter filterWithName:@"CIColorControls" keysAndValues: @"inputImage", aCIImage, nil] retain];
}
- (IBAction)brightnessSliderValueChanged:(id)sender {
[brightnessFilter setValue:[NSNumber numberWithFloat:brightnessSlider.value ] forKey: @"inputBrightness"];
outputImage = [brightnessFilter outputImage];
CGImageRef cgiig = [context createCGImage:outputImage fromRect:[outputImage extent]];
newUIImage = [UIImage imageWithCGImage:cgiig];
CGImageRelease(cgiig);
[showPickedImageView setImage:newUIImage];
}