danielebogo / DBCamera

DBCamera is a simple custom camera with AVFoundation
MIT License
1.26k stars 262 forks source link

Captured photo with extra space (issue resolved here) #194

Closed huang-kun closed 8 years ago

huang-kun commented 8 years ago

This is maybe not a big thing, but it's useful for whoever cares about why photo taken from custom full-screen camera preview is not look exactly same.

I noticed that using a custom camera view, which subclassed from DBCameraView, and call openCustomCamera from the given example, will generate a full-screen preview. And the captured photo from this full-screen preview on iPhone 5s and 6s will get some extra space from both side, which means the final photo will not look exactly the same from the preview before trigger the camera.

This is because:

  1. the session preset in code is AVCaptureSessionPresetPhoto
  2. the previewLayer's videoGravity is set to AVLayerVideoGravityResizeAspectFill
  3. the preview's frame is device screen's bounds

Fixed: Change the image output from default AVCaptureSessionPresetPhoto to other option whatever match the the screen ratio (i.e. 4:3 or 16:9).