我想用 AVCaptureSession for iOS 拍照,我可以拍照,但它需要像打印屏幕一样并将其保存在 PhotoLibrary 上,我怎样才能获得真实图片而不是打印屏幕并将其保存在视图中而不是在库中,你会吗?请在此实施中帮助我,
提前致谢!
这是我的代码:
CGImageRef UIGetScreenImage(void);
- (void) scanButtonPressed {
CGImageRef screen = UIGetScreenImage();(what should I use here instead of
UIGetScreenImage)
UIImage* image = [UIImage imageWithCGImage:screen];
CGImageRelease(screen);
// Save the captured image to photo album
UIImageWriteToSavedPhotosAlbum(image, self,
@selector(image:didFinishSavingWithError:contextInfo:), nil);
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void
*)contextInfo
{
UIAlertView *alert;
if (error)
alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Unable to save image to Photo Album."
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
else {
CoverCapturePhoto *c = [[CoverCapturePhoto alloc] init];
[self.navigationController pushViewController:c animated:YES];
[c.captureImage setImage:image];
}
[alert show];
}