在imageview上應用濾鏡後無法獲得原始圖像。我想在將滑塊從1移動到0(最大值到最小值,我的意思是反向方向)。 下面是應用銳度效果在使用清晰度濾鏡後Imageview未復位爲原始圖像
- (IBAction)actionSharp:(UISlider *)sender {
demoImage = _affectView.image;
CIImage* image = [CIImage imageWithCGImage:demoImage.CGImage];
CIContext *context = [CIContext contextWithOptions:nil];
NSNumber *testNSNumber = [NSNumber numberWithFloat:_sharpActionWithSlider.value];
NSLog(@"ffghhn %f",_sharpActionWithSlider.value);
CIFilter *gaussianBlurFilter = [CIFilter filterWithName:@"CISharpenLuminance" keysAndValues: @"inputImage", image, nil];
[gaussianBlurFilter setDefaults];
[gaussianBlurFilter setValue:testNSNumber forKey:kCIInputSharpnessKey];
[gaussianBlurFilter setDefaults];
CIImage *result2 = [gaussianBlurFilter valueForKey:kCIOutputImageKey];
CGImageRef cgImage = [context createCGImage:result2 fromRect:[result2 extent]];
UIImage *sharp= [UIImage imageWithCGImage:cgImage];
UIImage *p = sharp;
self.affectView.image= p;
self.affectView.alpha = sender.value;
CGImageRelease(cgImage);
}
每次您從self.affectView.image獲取圖像併爲其分配新圖像時,因此,每次你得到新的圖像,而不是原始圖像。您需要爲原始圖片添加效果,而不是更新後的圖片。我爲您的引薦添加了回覆。 – luckyShubhra