iOS 以编程方式使用 GPUImageview 截取屏幕截图
iOS Take screenshot with GPUImageview Programatically
我正在开发基于 GPUImageView 的应用程序。我已正确实现所有功能,但无法使用 GPUImageview 捕获屏幕截图。
这里我也在我的Github上附上了演示。
注意:我尝试使用 renderInContext: 截屏,但对我没有帮助。
正如我在你的问题中看到的,你使用了 GPUImageview。并且 GPUImageview 使用 openGL,因此,您可以使用 UIGraphicsBeginImageContextWithOptions
.
实现您的目标
您可以使用此方法来实现您的目标。
- (UIImage *)snapshot:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
有关详细信息,请单击下方 link。
On iOS 7 and later, how do I take a snapshot of my view and save the result in a UIImage?
我正在开发基于 GPUImageView 的应用程序。我已正确实现所有功能,但无法使用 GPUImageview 捕获屏幕截图。
这里我也在我的Github上附上了演示。
注意:我尝试使用 renderInContext: 截屏,但对我没有帮助。
正如我在你的问题中看到的,你使用了 GPUImageview。并且 GPUImageview 使用 openGL,因此,您可以使用 UIGraphicsBeginImageContextWithOptions
.
您可以使用此方法来实现您的目标。
- (UIImage *)snapshot:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
有关详细信息,请单击下方 link。
On iOS 7 and later, how do I take a snapshot of my view and save the result in a UIImage?