3

I'm currently developing my first iPhone application. I've implemented a custom camera view where the camera view is displayed through my regular view in a rectangle set by a frame:

    AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
[captureVideoPreviewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];

[captureVideoPreviewLayer setFrame:CGRectMake(viewLayer.frame.origin.x, viewLayer.frame.origin.y, viewLayer.bounds.size.width, viewLayer.bounds.size.height)];

This works good but when I try to take a picture and cutting it with the same rectangle the image rotates 90 degrees. I can't figure out why it does this.

Is there any way I could detect what my "camera window" sees and then crop my taken picture with the same window?

  • http://stackoverflow.com/questions/10850184/ios-image-get-rotated-90-degree-after-saved-as-png-representation-data – Rushabh Aug 27 '13 at 12:42

1 Answers1

0

The image has the native orientation of the camera sensor, which records images the same way no matter how you're holding the device. You can look at the imageOrientation property of a UIImage to figure out how to display the image.

Caleb
  • 124,013
  • 19
  • 183
  • 272