1

I want to take picture with AVCaptureSession for iOS, I can take a picture but it takes like a print screen and save it on PhotoLibrary, How can I get real picture not print screen and also save it on view not in a library, would you please help me in this implementation,

Thanks in advance!

Here is my code:

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];
}
Ali Mohamad
  • 41
  • 2
  • 10

1 Answers1

1

You need to investigate and use AVCaptureStillImageOutput. Apple supplies documentation showing how to take an image with the camera.

You are explicitly saving the image with UIImageWriteToSavedPhotosAlbum - you don't need to do that. Just use the image in an image view or similar.


Or if I misunderstood, see How to take a screenshot programmatically.

Community
  • 1
  • 1
Wain
  • 118,658
  • 15
  • 128
  • 151