iPhone 4 后置摄像头对于 UIImageView 来说质量太高?

发布于 2024-09-10 00:03:32 字数 894 浏览 1 评论 0原文

使用 iPhone 4 时,我在使用后置摄像头时遇到内存问题。它会导致内存错误,并且不会将图片分配给 UIView。这是代码。

-(IBAction)getCameraPicture:(id)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = NO;

if(sender == takePictureButton)
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
else
    picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

[self presentModalViewController:picker animated:YES];
[picker release];

- (void)imagePickerController:(UIImagePickerController *)picker 
didFinishPickingMediaWithInfo:(NSDictionary *)info
{

    imageView.image = [info objectForKey:UIImagePickerControllerOriginalImage];
    [picker dismissModalViewControllerAnimated:YES];
}

当使用前置(质量较低)摄像头时,它工作得很好,加载未以全质量拍摄的现有照片也是如此 有什么方法可以降低后置摄像头拍摄的照片的质量,或者有其他方法来解决这个问题吗?

When using the iPhone 4, I'm having memory issues when using the rear-facing camera. It's causing memory errors and won't assign the picture to a UIView. Here's the code.

-(IBAction)getCameraPicture:(id)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = NO;

if(sender == takePictureButton)
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
else
    picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

[self presentModalViewController:picker animated:YES];
[picker release];

}

- (void)imagePickerController:(UIImagePickerController *)picker 
didFinishPickingMediaWithInfo:(NSDictionary *)info
{

    imageView.image = [info objectForKey:UIImagePickerControllerOriginalImage];
    [picker dismissModalViewControllerAnimated:YES];
}

It works fine when using the front-facing (lower quality) camera, as does loading existing pictures not taken at full quality. Is there any way to reduce the quality of the photo taken with the rear camera, or some other way to get around this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你げ笑在眉眼 2024-09-17 00:03:33

这是一个常见问题,iPhone 相机拍摄的图像很大!通常比您需要的大得多。最佳做法是将图像大小调整为不大于您需要的大小。我使用 MGImageUtilities 并且效果很好。

如果您出于任何原因需要完整尺寸的图像,请在调整其大小之前将其缓存到磁盘。

This is a common problem, the images from the cameras on the iPhone are huge! Usually much bigger than you need. Best practice is to resize the image to be no bigger than you need. I use MGImageUtilities and it works great.

If you need the full-sized image for any reason, cache it to disk before you resize it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文