I am trying to use the iOS 7 style glass effect in my glass by applying image effects to a screenshot of a MKMapView
. This UIImage category, provided by Apple, is what I am using as a baseline. This method desaturates the source image, applies a tint color, and blurs heavily using the input vals:
[image applyBlurWithRadius:10.0
tintColor:[UIColor colorWithRed:229/255.0f green:246/255.0f blue:255/255.0f alpha:0.33]
saturationDeltaFactor:0.66
maskImage:nil];
This produces the effect I am looking for, but takes way too long — between .3
and .5
seconds to render on an iPhone 4.
I would like to use the excellent GPUImage
as my preliminary attempts have been about 5-10 times faster, but I just can't seem to get it right.
GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:image];
GPUImageSaturationFilter *saturationFilter = [[GPUImageSaturationFilter alloc] init];
saturationFilter.saturation = 0.33; // 1.0 - 0.66;
[stillImageSource addTarget:saturationFilter];
GPUImageMonochromeFilter *monochromeFilter = [[GPUImageMonochromeFilter alloc] init];
[monochromeFilter setColor:(GPUVector4){229/255.0f, 246/255.0f, 1.0f, 0.33f}];
[monochromeFilter setIntensity:0.2];
[saturationFilter addTarget:monochromeFilter];
GPUImageFastBlurFilter *blurFilter = [[GPUImageFastBlurFilter alloc] init];
blurFilter.blurSize = 2;
blurFilter.blurPasses = 3;
[monochromeFilter addTarget:blurFilter];
[saturationFilter prepareForImageCapture];
[monochromeFilter prepareForImageCapture];
[stillImageSource processImage];
image = [blurFilter imageFromCurrentlyProcessedOutput];
This produces an image which is close, but not quite there
The blur doesn't seem to be deep enough, but when I try to increase the blurSize
above, it becomes grid-like, almost like a kaleidoscope. You can actually see the grid here by zooming in on the second image. The tint-color I am trying to mimic seems to just wash out the image instead of overlaying and blending, which I think the Apple sample is doing.
I have tried to setup the filters according to comments made by @BradLarson in another SO question. Am I using the wrong GPUImage
filters to reproduce this effect, or am I just setting them up wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…