Fast blur on iOS

前端 未结 5 489
孤独总比滥情好
孤独总比滥情好 2020-12-07 10:29

I\'m running into trouble trying to blur part of the screen in my iOS app. See image for better idea of what I\'m trying to do.

5条回答
  •  醉梦人生
    2020-12-07 10:51

    I would recommend Brad Larson's GPUImage which is fully backed by the GPU for a wide variety of image processing effects. It's very fast, and even fast enough that in his demo app he does real-time video processing from the camera and the frame-rate is excellent.

    https://github.com/BradLarson/GPUImage

    Here is a code snippet I wrote to apply a basic box blur which blurs the bottom and top thirds of the image but leaves the middle of the image un-blurred. His library is extremely extensive and contains almost every kind of image filter effect imaginable.

    GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:[self screenshot]];
    
    GPUImageTiltShiftFilter *boxBlur = [[GPUImageTiltShiftFilter alloc] init];
            boxBlur.blurSize = 0.5;
    
    [stillImageSource addTarget:boxBlur];
    
    [stillImageSource processImage];
    
    UIImage *processedImage = [stillImageSource imageFromCurrentlyProcessedOutput];
    

提交回复
热议问题