cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Max Woghiren <>
Subject Re: iOS ScreenCapture plugin for Cordova
Date Mon, 15 Apr 2013 18:01:53 GMT
Hi Aaron,

One quick, general Objective-C thing I noticed: when creating messages,
it's helpful (and recommended) for readability to write declarations like

- (void)getScreenBitsWithCaptureOptions:(NSObject*)captureOptions
compareOptions:(NSObject*)compareOptions captureCount:(int)captureCount

This way, when sending the message, the code looks like this:

[self getScreenBitsWithCaptureOptions:captureOptions compareOptions:nil
captureCount:self.mCaptureCount++ command:command];

Without the parameter headings, your line 30 is confusing:

[self getScreenBits:captureOptions:nil:self.mCaptureCount++:command];

since, for example, it's unclear what nil is referring to.  It still
compiles and works, but is less readable.
question covers it fairly well.

On Mon, Apr 15, 2013 at 12:58 PM, Aaron Charbonneau <>
> 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:
> Usage:
> Also the non-working UIImage rawData code:
> Thanks alot for your time!
> Aaron

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message