Ios 加载带有图像I/O目标C的原始图像返回错误的分辨率

Ios 加载带有图像I/O目标C的原始图像返回错误的分辨率,ios,objective-c,image,Ios,Objective C,Image,我正在尝试将原始图像加载到iOS项目以进行显示。目前,我正在使用这段代码加载原始图像 CFDictionaryRef optionsRef = (__bridge CFDictionaryRef) @{ // (id) kCGImageSour

我正在尝试将原始图像加载到iOS项目以进行显示。目前,我正在使用这段代码加载原始图像

CFDictionaryRef optionsRef = (__bridge CFDictionaryRef) @{
                                                                  //                                                               (id) kCGImageSourceShouldAllowFloat: @YES,
                                                                  (id) kCGImageSourceCreateThumbnailWithTransform : @YES,
                                                                  (id) kCGImageSourceCreateThumbnailFromImageAlways : @YES,
                                                                  (id) kCGImageSourceThumbnailMaxPixelSize : @(MAX(SCREEN_HEIGHT, SCREEN_WIDTH) * ([UIScreen mainScreen].scale))
                                                                  };

        CGImageSourceRef imageSourceRef = CGImageSourceCreateWithURL((CFURLRef)imageUrl, NULL);

        if (!imageSourceRef)
            return nil;

        NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                                 [NSNumber numberWithBool:NO], (NSString *)kCGImageSourceShouldCache,
                                 nil];
        CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSourceRef, 0, (CFDictionaryRef)options);
        if (imageProperties) {
            NSNumber *width = (NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelWidth);
            NSNumber *height = (NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelHeight);
            NSLog(@"Image dimensions: %@ x %@ px", width, height);
            CFRelease(imageProperties);
        }
问题是,这段代码在处理某些图像时完美无瑕,而在处理其他图像时却表现得异常。例如,对于我加载的一个图像,它显示宽度为128,高度为96,而正确的宽度高度为4320 × 3240


我不确定这里有什么问题,因为我所做的只是将图像加载到CGImageSourceRef:(

您所说的raw是指相机raw?(例如尼康NEF文件?)

据我所知,iOS没有原始图像解析引擎。它唯一能做的就是加载嵌入的JPEG缩略图。您可能看到的是缩略图的大小,而不是完整原始图像的大小

CFDictionaryRef optionsRef = (__bridge CFDictionaryRef) @{
                                                                  //                                                               (id) kCGImageSourceShouldAllowFloat: @YES,
                                                                  (id) kCGImageSourceCreateThumbnailWithTransform : @YES,
                                                                  (id) kCGImageSourceCreateThumbnailFromImageAlways : @YES,
                                                                  (id) kCGImageSourceThumbnailMaxPixelSize : @(MAX(SCREEN_HEIGHT, SCREEN_WIDTH) * ([UIScreen mainScreen].scale))
                                                                  };

        CGImageSourceRef imageSourceRef = CGImageSourceCreateWithURL((CFURLRef)imageUrl, NULL);

        if (!imageSourceRef)
            return nil;

        NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                                 [NSNumber numberWithBool:NO], (NSString *)kCGImageSourceShouldCache,
                                 nil];
        CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSourceRef, 0, (CFDictionaryRef)options);
        if (imageProperties) {
            NSNumber *width = (NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelWidth);
            NSNumber *height = (NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelHeight);
            NSLog(@"Image dimensions: %@ x %@ px", width, height);
            CFRelease(imageProperties);
        }

<我不曾尝试在iOS中打开相机原始图像,所以我对iOS所做的事情的答案是基于我读过的不完整的内存。

< P>尼康有可供下载的库,我认为它们是源代码。可能是C或C++,所以编译它们需要一些工作,并找出如何从iOS BU中使用它们。t这应该是可能的。你应该能够在尼康网站上找到它们。

嗨,邓肯,是的,我正在尝试读取原始图像(.NEF、.CR2…),到目前为止,我一直在使用此代码成功读取一些原始图像(主要是.CR2和几个.DNG)使用上面的代码。其他的我也可以读取,但输出图像的分辨率与原始图像不符。如果iOS确实无法加载原始图像,那么为什么这里有成功的案例?我不确定什么是允许iOS读取完全分辨率的图像配置