2
我正在为iPhone应用程序编写图像编辑器。我使用GPUImage library在画布上呈现精灵图像(在GPUImageView上)。我用下面的方法来获取画布的截图:如何获取包含GPUImageView的视图的屏幕截图?
@implementation UIView (SnapshotImage)
// Return a snapshot image of this view
- (UIImage*)snapshot{
UIGraphicsBeginImageContextWithOptions(self.bounds.size,YES,0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
// In iOS 7, you can use the following instead of `-renderInContext:`. It should be faster.
// [self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
[self.layer renderInContext:context];
UIImage *capturedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return capturedImage;
}
@end
我用这个方法后得到的关键窗口的全屏幕截图,画布的领域是空的(没有任何精灵的形象)。
UIView *keyWindow = [[UIApplication sharedApplication] keyWindow];
UIImage *snapshotIamge = [keyWindow snapshot];
// Present the image on the view...
我认为这是获取包含GPUImageView(S)的视图,其使用OpenGLES来渲染图像不石英的截图的问题。如何获取包含GPUImageView的视图截图?
当拍摄屏幕截图时(例如Mac上的cmd + shift + 4
),是否可以使用特定的CGRect获取裁剪后的图像?
剂量,这意味着我应该创建并添加新的UIImageView(s)到精灵(s)以呈现从-imageFromCurrentlyProcessedOutput'的UIImage,拍摄快照,然后从精灵中删除UIImageView(s)相同的运行循环? –