简体   繁体   English

UIImagePickerController返回的图像大于iPhone 4上的预览

[英]UIImagePickerController Image returned is bigger than preview on iPhone 4

I'm taking a photo with UIImagePickerController. 我正在使用UIImagePickerController拍照。 Everything works fine on iPad and on iPhone 5. The problem comes with an iPhone4: the photo that I get from the picker is "bigger" than what I saw on the screen when I took the photo. 在iPad和iPhone 5上,一切都可以正常工作。iPhone4带来了问题:从选择器获得的照片比拍摄照片时在屏幕上看到的要大。

What do I mean with bigger? 更大意味着什么? I mean that at both sides of the photo, and at the bottom, I see parts of the scene that the camera didn't show when I was taking the photo. 我的意思是,在照片的两边以及在底部,我都看到了拍摄照片时相机没有显示的部分场景。 This is a problem for my app. 这是我的应用程序遇到的问题。 I need to capture exactly the same scene that the user sees through the camera when he takes the photo. 我需要捕捉用户拍摄照片时通过相机看到的完全相同的场景。 Not a bigger scene. 没有更大的场景。 As I said, on iPhone5 and iPad4 everything works fine. 正如我所说,在iPhone5和iPad4上一切正常。 I don't understand this different behaviour. 我不了解这种不同的行为。 How can I solve this? 我该如何解决?

PD: I'm not applying any transformation to the image on the picker. PD:我没有对选择器上的图像应用任何变换。

-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
{
    UIImage* originalImage = [info valueForKey:@"UIImagePickerControllerOriginalImage"];
    NSLog(@"Image Size Width %f  Height %f",originalImage.size.width,originalImage.size.height);

    UIGraphicsBeginImageContext(CGSizeMake(320, 480));
    [originalImage drawInRect:CGRectMake(0,0,320,480)];
    UIImage* image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    NSLog(@"image Size h %f  Width %f",[image size].height, [image size].width);

}

Here you can see that What is original image size and after than you can change size as your wish.. 在这里,您可以看到什么是原始图像尺寸,然后您可以根据需要更改尺寸。

It was a problem with the preview on the iPhone4... the preview on the iPhone4 is 16:9, but the final image is 4:3. iPhone4上的预览存在问题... iPhone4上的预览为16:9,但最终图像为4:3。 On the iPhone5 and the iPad, both the preview and the final image are 4:3. 在iPhone5和iPad上,预览和最终图像均为4:3。

I didn't realize it before because my overlay was hiding part of the preview on the iPhone4, so I thought the preview was 4:3 too (and I think that the preview with iOS6 is 4:3, I'm not sure, I've got to find an iPhone4 with iOS6). 我之前没有意识到这一点,因为我的叠加层在iPhone4上隐藏了预览的一部分,所以我认为预览也是4:3(而且我认为iOS6的预览是4:3,我不确定,我必须找到具有iOS6的iPhone4)。

I made my overlay (a UIToolbar) translucent, and now I get what I want. 我使覆盖图(UIToolbar)半透明,现在我得到了想要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM