Hello Everyone, I recently shared my code for a screen capture plugin for Android Cordova not too long back, and since then have been working on an iOS version. It exposes the same api's to javascript and behaves identically between the two platforms.
The goal of these plugins is to provide a way of testing and debugging Cordova applications, as well as testing Cordova itself. With this plugin you can render a WebView, take a capture of it, optionally isolate a certain area of the capture, and write that capture to file, and even provide a comparison image to validate the WebView is rendering correctly. Here's a brief overview of the functions it provides: ScreenCapture.capture() - Takes a screenshot of the current WebView, with optional output file name and subrect region. ScreeCapture.captureAndCompare() - Same functionality as Capture, but you can also include the url of a comparison image, and pixel/color tolerances to perform an image compare on the native side for better performance. Both of the these functions funnels into a do-it-all function getScreenBits, In getScreenBits we spin off background threads to do file IO and comparison work. There is one section I'm not quite sure of, and that is getting the raw pixel data out of a UIImage. I ran into a problem where the data was not in the correct colorSpace when getting it from the UIImage directly, like this: CFDataRef actualImageData = CGDataProviderCopyData (CGImageGetDataProvider(image.CGImage)); So I instead went with a way that works, but seems inefficient to me as it involves a copy, this code is currently used in the getRawDataFromImage() function. Once again, if anyone can afford the time, I would love some feedback on the iOS implementation of this plugin, as I am still learning Objective C. Plugin: https://github.com/Charbs09/Cordova-Mobile-Spec-ScreenCapture/blob/master/iOS/CordovaMobileSpecScreenCapture/Plugins/CDVScreenCapture.m Usage: https://github.com/Charbs09/Cordova-Mobile-Spec-ScreenCapture/blob/master/iOS/www/autotest/tests/rendering.tests.js Also the non-working UIImage rawData code: https://github.com/Charbs09/Cordova-Mobile-Spec-ScreenCapture/blob/master/iOS/CordovaMobileSpecScreenCapture/Plugins/CDVScreenCaptureNoCopy.m#L132 Thanks alot for your time! Aaron