Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Every response here is using <strong>vImageBoxConvolve_ARGB8888</strong> this function is really, really slow, that is fine, if the performance is not a high priority requirement, but if you are using this for transitioning between two View Controllers (for example) this approach means times over 1 second or maybe more, that is very bad to the user experience of your application.</p> <p>If you prefer leave all this image processing to the GPU (And you should) you can get a much better effect and also awesome times rounding 50ms (supposing that you have a time of 1 second in the first approach), so, lets do it.</p> <p>First download the GPUImage Framework (BSD Licensed) <a href="https://github.com/BradLarson/GPUImage" rel="noreferrer">here</a>.</p> <p>Next, Add the following classes (.m and .h) from the GPUImage (I'm not sure that these are the minimum needed for the blur effect only)</p> <ul> <li>GPUImage.h</li> <li>GPUImageAlphaBlendFilter</li> <li>GPUImageFilter</li> <li>GPUImageFilterGroup</li> <li>GPUImageGaussianBlurPositionFilter</li> <li>GPUImageGaussianSelectiveBlurFilter</li> <li>GPUImageLuminanceRangeFilter</li> <li>GPUImageOutput</li> <li>GPUImageTwoInputFilter</li> <li>GLProgram</li> <li>GPUImageBoxBlurFilter</li> <li>GPUImageGaussianBlurFilter</li> <li>GPUImageiOSBlurFilter</li> <li>GPUImageSaturationFilter</li> <li>GPUImageSolidColorGenerator</li> <li>GPUImageTwoPassFilter</li> <li><p>GPUImageTwoPassTextureSamplingFilter</p></li> <li><p>iOS/GPUImage-Prefix.pch</p></li> <li>iOS/GPUImageContext </li> <li>iOS/GPUImageMovieWriter</li> <li>iOS/GPUImagePicture</li> <li>iOS/GPUImageView</li> </ul> <p>Next, create a category on UIImage, that will add a blur effect to an existing UIImage:</p> <pre><code>#import "UIImage+Utils.h" #import "GPUImagePicture.h" #import "GPUImageSolidColorGenerator.h" #import "GPUImageAlphaBlendFilter.h" #import "GPUImageBoxBlurFilter.h" @implementation UIImage (Utils) - (UIImage*) GPUBlurredImage { GPUImagePicture *source =[[GPUImagePicture alloc] initWithImage:self]; CGSize size = CGSizeMake(self.size.width * self.scale, self.size.height * self.scale); GPUImageBoxBlurFilter *blur = [[GPUImageBoxBlurFilter alloc] init]; [blur setBlurRadiusInPixels:4.0f]; [blur setBlurPasses:2.0f]; [blur forceProcessingAtSize:size]; [source addTarget:blur]; GPUImageSolidColorGenerator * white = [[GPUImageSolidColorGenerator alloc] init]; [white setColorRed:1.0f green:1.0f blue:1.0f alpha:0.1f]; [white forceProcessingAtSize:size]; GPUImageAlphaBlendFilter * blend = [[GPUImageAlphaBlendFilter alloc] init]; blend.mix = 0.9f; [blur addTarget:blend]; [white addTarget:blend]; [blend forceProcessingAtSize:size]; [source processImage]; return [blend imageFromCurrentlyProcessedOutput]; } @end </code></pre> <p>And last, add the following frameworks to your project:</p> <p>AVFoundation CoreMedia CoreVideo OpenGLES</p> <p>Yeah, got fun with this much faster approach ;) </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload