[英]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的屏幕截圖
這是類似的帖子,有一些答案。 顯然,您可以使用UIGetScreenImage
或glReadPixels
來完成此任務。 希望有幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.