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