2013-10-08 62 views
1

我想拍摄AVCaptureSession for iOS的照片,我可以拍照,但需要打印屏幕并将其保存在PhotoLibrary上,如何获得真实照片而不是打印屏幕并保存查看不在图书馆,请你帮我在这个实施中,iOS - 使用AVCaptureSession拍摄图像

在此先感谢!

这里是我的代码:

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]; 
} 
+0

你确实是指使用相机,或采取屏幕抓取,但不使用私人API? – Wain

+0

@是否使用相机并拍摄照片并将其显示到其他屏幕 –

回答

1

你需要调查和使用AVCaptureStillImageOutput。 Apple提供documentation显示如何用相机拍摄图像。

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


或者如果我误解了,请参阅​​3210。

+0

否我不需要截图,但如何将图像保存在imageView上? –