1

我想用 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];
}
4

1 回答 1

1

您需要调查和使用AVCaptureStillImageOutput. Apple 提供了说明如何使用相机拍摄图像的文档。

您正在明确保存图像UIImageWriteToSavedPhotosAlbum- 您不需要这样做。只需image在图像视图或类似视图中使用。


或者,如果我误解了,请参阅如何以编程方式截取屏幕截图

于 2013-10-08T21:23:00.903 回答