可能的重复:
为什么 glReadPixels() 在 iOS 6.0 中的这段代码中失败? https://stackoverflow.com/questions/12528365/why-is-glreadpixels-failing-in-this-code-in-ios-6-0
我正在使用 OpenGL 开发一款游戏,需要在拍摄最佳镜头时进行屏幕截图并上传 Facebook,但当我拍摄屏幕截图时,它只有黑屏。我做什么 ?
我还在链接中使用代码:UIview+glview以编程方式取屏 https://stackoverflow.com/questions/6197137/take-screen-programmatically-of-uiviewglview和类似的代码
但没有成功。
我正在起诉以下代码:http://developer.apple.com/library/ios/#qa/qa1704/_index.html http://developer.apple.com/library/ios/#qa/qa1704/_index.html
但是所有代码都会在模拟器中产生图像,而不是在设备中(在设备中仅黑色或白色)
如果您想拍摄屏幕截图,请尝试使用该代码并检查:
CGRect screenRect = [[UIScreen mainScreen] bounds];
UIGraphicsBeginImageContextWithOptions(screenRect.size, NO, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)