Badal Shah Badal Shah - 5 months ago 21
iOS Question

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.

Here is my Scenario ..

enter image description here

Here i have also Attached Demo on My Github. Please help me regarding this issue.

GPUImageview Demo

Note :- I have tried to take a screenshot with renderInContext: but it not helpfull for me . Thank you.

Answer

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?