【问题标题】:PhoneGap screenshot plugin: get image file path and/or UriPhoneGap截图插件:获取图片文件路径和/或Uri
【发布时间】:2011-04-26 17:39:07
【问题描述】:

我正在使用 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];
}

【问题讨论】:

    标签: iphone plugins cordova screenshot


    【解决方案1】:

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

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

    【讨论】:

    • 太棒了,这正是我想要的。感谢您发布对您自己问题的跟进。
    猜你喜欢
    • 1970-01-01
    • 2011-10-19
    • 1970-01-01
    • 2013-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-02
    相关资源
    最近更新 更多