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)相同的運行循環? –