【发布时间】: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