开发者

PhoneGap screenshot plugin: get image file path and/or Uri

I am using PhoneGap along with the associated Screenshot Plugin for iOS. It is trivial to take a screenshot that is saved to the "Saved Photos" on the phone/simulator. But I would like to be able to take the screenshot, then do something with the saved image, specifically send it to a server.

It seems that the UIImageWriteToSavedPhotosAlbum开发者_如何学Go function used in the plugin does not return anything helpful so I am at a loss of how I can modify the plugin to return me the image path to be used in the FileUploader plugin.

The relevant plugin code below ...

- (void)saveScreenshot:(NSArray*)arguments withDict:(NSDictionary*)options
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGRect imageRect = CGRectMake(0, 0, CGRectGetWidth(screenRect), CGRectGetHeight(screenRect));
UIGraphicsBeginImageContext(imageRect.size);

CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor blackColor] set];
CGContextTranslateCTM(ctx, 0, 0);
CGContextFillRect(ctx, imageRect);

[webView.layer renderInContext:ctx];

UIImage *image1 = UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(image1, nil, nil, nil);
UIGraphicsEndImageContext();
UIAlertView *alert= [[UIAlertView alloc] initWithTitle:nil message:@"Image Saved" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}


In my case at least, i just wanted the screenshot image and didn't really care for it to be saved to the phone. So I modified the screenshot plugin to allow for a base64 string to be returned to a given function.

https://github.com/l0c0luke/phonegap-plugins/commit/cb4c09ae2442b6bb8053d3708152bc0ffc334990

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜