Blur an UIImage on change of slider

前端 未结 3 1543
走了就别回头了
走了就别回头了 2021-02-02 04:00

I have tried gaussian blur and checked out all the questions on stackoverflow but no one of them solved my crash issue.Please help is there is any other way to blur image other

相关标签:
3条回答
  • 2021-02-02 04:13

    Not sure about how to blur an image. This may help is you want to blur an UIImageView or any view.

       UIView *myView = self.theImageView;
        CALayer *layer = [myView layer];
        [layer setRasterizationScale:0.25];
        [layer setShouldRasterize:YES];
    

    You can undo it by setting the rasterization scale back to 1.

    [layer setRasterizationScale:1.0];
    

    UPDATE:

    The below Apple sample code includes a blur/sharp effect. (using Open GL) See if it helps, http://developer.apple.com/library/ios/#samplecode/GLImageProcessing/Introduction/Intro.html

    0 讨论(0)
  • 2021-02-02 04:31

    I've made a small StackBlur extension to UIImage. StackBlur is close to GaussianBlur but much faster.

    Check it at: https://github.com/tomsoft1/StackBluriOS


    tiny note... there's a typo just on that ReadMe, "normalized" for "normalize"

    0 讨论(0)
  • 2021-02-02 04:33

    What you probably want is a Box Blur algorithm. It is about 10 times faster than Gaussian blur and produces nice results. I have the code running on Android, I just haven't ported it to iOS yet. Here is the source.

    Should only take about 10 minutes to port to iOS. The functions will work as is, you just need to access the image bytes (as you are doing in the source code above) and feed them to functions.

    0 讨论(0)
提交回复
热议问题