2013-10-08 63 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上? –