iOS与相机预览模式iOS相比,捕获更大的图像

时间:2014-12-26 13:08:40

标签: ios objective-c iphone-5 iphone-6 iphone-6-plus

对于iPhone 6和6+我使用以下代码在全屏幕上拉伸相机。 我基本上使用cameraViewTransform将相机拉伸到全屏。因此,与预览模式相比,我获得了更大的放大图像。我怎样才能仅捕获在预览模式下可见的那部分。

请参阅以下屏幕截图以获得更多清关

在Iphone 6中 - http://i.imgur.com/gQNvLlr.jpg(在预览模式下)

http://i.imgur.com/agZmWPI.png(拍摄的图像)

在iphone 5中 - http://i.imgur.com/odp5ZYe.jpg(在预览模式下)

http://i.imgur.com/R17cE68.png(拍摄的图像)

  CGSize screenSize = [[UIScreen mainScreen] bounds].size;
            // set the aspect ratio of the camera
            float heightRatio = 4.0f / 3.0f;
            // calculate the height of the camera based on the screen width
            float cameraHeight = screenSize.width * heightRatio;
            // calculate the ratio that the camera height needs to be scaled by
            float scale = screenSize.height / cameraHeight;
            // move the controller to the center of the screen
            self.imagePickerController.cameraViewTransform = CGAffineTransformMakeTranslation(0, (screenSize.height - cameraHeight) / 2.0);
            // concatenate the scale transform
            self.imagePickerController.cameraViewTransform = CGAffineTransformScale(self.imagePickerController.cameraViewTransform, scale, scale);

0 个答案:

没有答案