我有以下过滤器,在使用UISlider时应用。
- (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];
});}
我想要能够获得原始数据的图像创建,以应用雪碧过滤器。Sepia过滤器的代码:
- (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-在曝光后的图像上涂上紫色。
发布于 2014-10-28 15:29:14
我设法将过滤器(CIFilter)应用于过滤器(使用CGContextCreate绘制比特),在滑块的方法(exposureSliderChanged:(Id)发件人)上编写这段代码:
imageRawData = realloc(imageRawData,CGImageGetHeight(_modifiedImage.CGImage)*CGImageGetWidth(_modifiedImage.CGImage)*4);
localData = CGBitmapContextCreate(imageRawData,
imageWidth,
imageHeight,
bitsPerComponent,
bytesPerRow,
colorSpace,
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrderDefault);
CGContextDrawImage(localData, CGRectMake(0, 0, imageWidth, imageHeight),cgimg);
CGContextRelease(localData);
CFRelease(localData);https://stackoverflow.com/questions/26610170
复制相似问题