简体   繁体   English

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

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

So, I know how to take a screenshot with UIKit: 因此,我知道如何使用UIKit截屏:

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

And I know how to take a screenshot with OpenGL 而且我知道如何使用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

My app mixes OpenGL and UIKit, so any screenshot taken with just one method doesn't look right. 我的应用程序混合了OpenGL和UIKit,因此仅用一种方法拍摄的任何屏幕截图都不正确。

What's the best way to either a) Composit the two images together or b) Take a screenshot that can capture both OpenGL and UIKit together 最好的方法是a)将两个图像合成在一起,或者b)截取可以同时捕获OpenGL和UIKit的屏幕截图

This is a similar post which has some answers. 是类似的帖子,有一些答案。 Apparently you can use either UIGetScreenImage , or glReadPixels to do this task. 显然,您可以使用UIGetScreenImageglReadPixels来完成此任务。 Hope that helps! 希望有帮助!

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

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