Search code examples
iosobjective-cgpuimage

iOS Take screenshot with GPUImageview Programatically


I am working on GPUImageView Based application. I have implemented all functionality correctly but i am not able to capture Screenshot with GPUImageview.

enter image description here

Here I have also Attached Demo on My Github.

GPUImageview Demo

Note: I have tried to take a screenshot with renderInContext: but it not helpful for me.


Solution

  • As i can see in your question,you have used GPUImageview. and GPUImageview used openGL so, you can achive your goal with using UIGraphicsBeginImageContextWithOptions.

    you can use this method to achive your goal.

    - (UIImage ​*)snapshot:(UIView *​)view
    {
       UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0);
       [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
       UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
       UIGraphicsEndImageContext();
    
       return image;
    }
    

    for more information click on below link.

    On iOS 7 and later, how do I take a snapshot of my view and save the result in a UIImage?