繁体   English   中英

截取混合了UIKit和OpenGL的iPhone应用的屏幕截图

[英]Taking a Screenshot of an iPhone app mixing UIKit and OpenGL

因此,我知道如何使用UIKit截屏:

UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
UIGraphicsBeginImageContext(window.bounds.size);
[window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);

而且我知道如何使用OpenGL截屏

// Some preparation to read pixels into a buffer
glReadPixels(0,0,backingWidth, backingHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
// Some code to massage the raw pixel data into an image

我的应用程序混合了OpenGL和UIKit,因此仅用一种方法拍摄的任何屏幕截图都不正确。

最好的方法是a)将两个图像合成在一起,或者b)截取可以同时捕获OpenGL和UIKit的屏幕截图

是类似的帖子,有一些答案。 显然,您可以使用UIGetScreenImageglReadPixels来完成此任务。 希望有帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM