0
我有以下使用UISlider時應用的過濾器。我如何從CIImage獲取CGBItmapContextCreate
- (IBAction)exposureSliderChanged:(id)sender {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
exposureFilter = [CIFilter filterWithName: @"CIExposureAdjust" keysAndValues: @"inputImage", aCIImage, nil];
[exposureFilter setValue:[NSNumber numberWithFloat:_slider.value] forKey:@"inputEV"];
exposureValue=_slider.value;
dispatch_async(dispatch_get_main_queue(), ^{
outputImage = [exposureFilter outputImage];
CGImageRef cgimg = [context createCGImage:outputImage fromRect:[outputImage extent]];
_modifiedImage = [UIImage imageWithCGImage:cgimg scale:2.0 orientation:UIImageOrientationUp];
[_cropImageView setImage:_modifiedImage];
CGImageRelease(cgimg);
});
;
});
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
exposureDict = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat:(float)_slider.value],@"Exposure", nil];
});
}
我希望能夠得到以應用懷舊濾鏡產生的圖像的原始數據。 棕褐色過濾器的代碼:
- (IBAction)sepiaFilterButtonPressed:(id)sender {
_slider.hidden=YES;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
_undoImage=[_modifiedImage copy];
SepiaToneEffect *sepiaToneEffect = [[SepiaToneEffect alloc] init];
[sepiaToneEffect setImageWidth: imageWidth];
[sepiaToneEffect setImageHeight: imageHeight];
//set the blurred image to your imageView in the main thread
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"%f",_modifiedImage.size.width);
_modifiedImage = [sepiaToneEffect modifyImageWithSepia:_modifiedImage
imageRawData:imageRawData
withColorR:112
colorG:66
colorB:20
depth:0.5];
_modifiedImage=[Globals imageWithImage:_modifiedImage scaledToSize:sizeNeeded];
NSLog(@"%f",_modifiedImage.size.width);
[_cropImageView setImage:_modifiedImage];
//Create CIImage
UIImage *aUIImage =_modifiedImage;
CGImageRef aCGImage = aUIImage.CGImage;
aCIImage = [CIImage imageWithCGImage:aCGImage];
//Create context
context = [CIContext contextWithOptions:nil];
});
NSDictionary *modification = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], @"Sepia",nil];
[[kAppDelegate modificationsArray] addObject:modification];
});
}
是否有過過濾器應用過濾器的方法?例如: 1-應用曝光濾鏡; 2-應用曝光後產生的圖像上的棕褐色。