3
我正在使用PhoneGap以及相关的iOS截图插件。将屏幕截图保存到手机/模拟器上的“保存的照片”是很简单的。但我希望能够截取屏幕截图,然后对保存的图像执行一些操作,特别是将其发送到服务器。PhoneGap截图插件:获取图像文件路径和/或Uri
看起来插件中使用的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];
}
奇妙的是,这正是我所期待的。感谢您发布自己的问题后续行动。 – JayZeeNYC 2012-03-23 20:24:41