2
我需要在我的應用中實現觸摸模糊效果。我使用GPUImage進行基本過濾,但我還需要包含模糊圖像中任何區域的功能。我在這方面掙扎了幾天,找不到任何其他有幫助的問題/答案。GPUImage +觸摸模糊效果
我現在的(僞)實現,它不採取GPUImage的優點如下:
In the pan gesture recognizer, I'm collecting the pan gesture objects and saving them to an array. When UIGestureRecognizerStateEnded, I attempt to apply the blur using:
1. Get image from GPUImagePicture.
2. Create a "CIGaussianBlur" CIFilter to create a blurred image.
3. Loop through the gesture taps
4. Create a CIFilter mask with a CIRadialGradient with the location as center.
5. Composite the masks into 1 mask:
maskImage = [[CIFilter filterWithName:@"CISourceOverCompositing" keysAndValues:
kCIInputImageKey, gassBlur, kCIInputBackgroundImageKey, maskImage, nil] valueForKey:kCIOutputImageKey];
6. Crop the mask:
CIVector *rect = [CIVector vectorWithCGRect:origImage.extent];
maskImage = [CIFilter filterWithName:@"CICrop" keysAndValues:kCIInputImageKey, maskImage, @"inputRectangle", rect, nil].outputImage;
7. Use a CIBlendWithMask filter to combine the original image, the mask, and the blurred image:
CIFilter *blendedFilter = [CIFilter filterWithName:@"CIBlendWithMask" keysAndValues:
@"inputImage", pixellateFilter.outputImage,
@"inputBackgroundImage", origImage,
@"inputMaskImage", maskImage,
nil];
8. Update the image view with the new image:
[self.tempImgView setImage:[UIImage imageWithCIImage:pixellateFilter.outputImage]];
我怎樣才能讓模糊效果的實時,因爲如果用戶是「清明上河圖」圖像與模糊的畫筆?一個完美的例子是應用程序Touch Blur。
編輯1:
我的過濾器鏈是這樣的:
[self.staticPicture addTarget:self.filter]; // self.filter is some B&W, sepia, etc filter
[self.filter addTarget:self.blurFilter]; // I think the blur filter should be modified somehow
[self.blurFilter addTarget:self.gpuImageView];
[self.staticPicture processImage];
我需要以某種方式更新在鍋裏手勢事件self.blurFilter,然後調用processImage來每次更新gpuImageView 。