【问题标题】:Resolution of image from photo library is always 640 * 480照片库中图像的分辨率始终为 640 * 480
【发布时间】:2010-10-22 15:25:39
【问题描述】:

我正在开发一个模块,我需要从照片库中选择图像并在视图上绘制。但每当我选择大尺寸图像时,它总是返回 640 * 480 缩放图像,因为显示的是小图像。

我已启用 AllowEditing。

谁能帮我找到原始图像的分辨率,以便我可以再次将其缩放到原始图像。

iImagePicker.allowsImageEditing = YES;

- (void)imagePickerController:(UIImagePickerController *)picker 
        didFinishPickingImage:(UIImage *)image
                  editingInfo:(NSDictionary *)editingInfo
{

    [[iImagePicker parentViewController] dismissModalViewControllerAnimated:YES];  
    iIsImageSaved = YES;
    iSavedImage = [editingInfo objectForKey:@"UIImagePickerControllerOriginalImage"];;
    int width,height;
    width = iSavedImage.size.width;
    height = iSavedImage.size.height;

    iApp->ImagePicked(image);
}

谢谢,

萨加尔

【问题讨论】:

    标签: iphone


    【解决方案1】:

    您不需要缩小图像,无论如何它都应该可用。检查我对this question 的回答(我认为这是重复的......)


    [为您的代码更新了答案] 您正在使用deprecated method,请尝试使用imagePickerController:didFinishPickingMediaWithInfo:UIImagePickerControllerOriginalImage 键代替。


    添加代码sn-p:

    -(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
        UIImage* originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];
        NSLog(@"Original image width: %f and height: %f", originalImage.size.width, originalImage.size.height);
    
        UIImage* editedImage = [info objectForKey:UIImagePickerControllerEditedImage];
        NSLog(@"Edited image width: %f and height: %f", editedImage.size.width, editedImage.size.height);
    
        [self dismissModalViewControllerAnimated:YES];
    }
    

    【讨论】:

    • 我尝试使用该链接,但仍然得到 640 * 480 的大小。我已经用我的 src 代码更新了帖子。
    • 我已经更新了 src 代码 - (void)imagePickerController:(UIImagePickerController )picker didFinishPickingMediaWithInfo:(NSDictionary *)info { //UIImage image = nil; [[iImagePicker parentViewController]dismissModalViewControllerAnimated:YES]; iIsImageSaved = 是; iSavedImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];整数宽度,高度;宽度 = iSavedImage.size.width;高度 = iSavedImage.size.height; iApp->ImagePicked(iSavedImage);但我仍然得到相同的结果。我正在使用 4.1 OS 的第 4 代 iPod 上检查它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-13
    • 1970-01-01
    • 2013-02-27
    • 2011-05-28
    • 1970-01-01
    • 2011-03-06
    • 1970-01-01
    相关资源
    最近更新 更多