PhoneGap截图插件:获取图像文件路径和/或Uri

Luk*_*ett 3 iphone plugins screenshot cordova

我正在使用PhoneGap以及相关的iOS插件插件.在手机/模拟器上拍摄保存到"已保存照片"的屏幕截图是微不足道的.但我希望能够截取屏幕截图,然后对保存的图像执行某些操作,特别是将其发送到服务器.

似乎UIImageWriteToSavedPhotosAlbum插件中使用的函数没有返回任何有用的东西,所以我不知道如何修改插件以返回我在FileUploader插件中使用的图像路径.

下面的相关插件代码......

- (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];
}
Run Code Online (Sandbox Code Playgroud)

Luk*_*ett 6

在我的情况下,至少,我只是想要截图图像并没有真正关心它保存到手机.所以我修改了截图插件,允许将base64字符串返回给定的函数.

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