【发布时间】:2010-11-05 08:46:17
【问题描述】:
在我的应用程序中,我进行了屏幕截图:
UIImage *viewImage = [UIImage imageWithCGImage:UIGetScreenImage()];
CGRect cropRect = CGRectMake(0, 0, 320, 440);
CGImageRef imageRef = CGImageCreateWithImageInRect([viewImage CGImage], cropRect);
viewImage = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
captureImage = [[UIImage alloc] init];
captureImage = viewImage;
然后我想把它保存到相册:
UIImageWriteToSavedPhotosAlbum(anImage, self, @selector(savedPhotoImage:didFinishSavingWithError:contextInfo:), nil);
- (void) savedPhotoImage:(UIImage *)image
didFinishSavingWithError:(NSError *)error
contextInfo:(void *)contextInfo
{
NSString *themessage = @"This image has been saved to your Photos album. Tap to continue.";
NSString *errorTitle = @"Image saved.";
if (error) {
themessage = [error localizedDescription];
errorTitle = @"error";
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:errorTitle
message:themessage
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
保存到相册时应用程序崩溃。 捕获的图像是好的,我可以成功上传并显示它。 我还尝试从内存中加载图像并将其保存到相册,它也有效。
我想我在处理图像时做错了什么.. 有什么想法吗?
谢谢!
【问题讨论】:
-
你得到 BAD_ACCESS 错误,还是什么?
-
很遗憾我无法在实际设备上进行测试,我只能从客户那里得到反馈。 UIGetScreenImage() 函数在模拟器中也不可用。