Taking Screenshots in the background (iOS) - Improving Performance

蓝咒 提交于 2019-11-27 03:00:27

问题


This question is an extension to: Taking Screenshots from iOS app - emulating Display recorder (query on the internals)
There are 2 ways I came across to take screenshots from the background -
1. Creating an image out of the ios surface and saving it - it captures at a very fast rate (approximately 0.2-0.3 sec/ 12-15 screenshots), however there are some problems that are encountered, discussed here: Releasing an IOSurface
2. The following code does the same job using the createScreenIOSurface API:

IOSurfaceRef surface = [UIWindow createScreenIOSurface];
UIImage *surfaceImage = [[UIImage alloc] _initWithIOSurface:surface orientation:UIImageOrientationUp];
CFRelease(surface);
UIImageSaveToPhotosAlbum(surfaceImage, self, nil, nil);

However, the capture rate is very bad, approximately 0.5-0.7 sec/screenshot.

So, is there a solution to the problem faced in approach 1 ?
Is there a way to improve performance for approach 2 ?

来源:https://stackoverflow.com/questions/13971013/taking-screenshots-in-the-background-ios-improving-performance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!