菜鸟教程小白 发表于 2022-12-11 16:47:22

ios - 使用 Image I/O 物镜 C 加载 Raw 图像会返回错误的分辨率


                                            <p><p>我正在尝试将 RAW 图像加载到 iOS 项目中进行显示。目前,我正在使用这段代码来加载原始图像。</p>

<pre><code>CFDictionaryRef optionsRef = (__bridge CFDictionaryRef) @{
                                                                  //                                                               (id) kCGImageSourceShouldAllowFloat: @YES,
                                                                  (id) kCGImageSourceCreateThumbnailWithTransform : @YES,
                                                                  (id) kCGImageSourceCreateThumbnailFromImageAlways : @YES,
                                                                  (id) kCGImageSourceThumbnailMaxPixelSize : @(MAX(SCREEN_HEIGHT, SCREEN_WIDTH) * (.scale))
                                                                  };

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

      if (!imageSourceRef)
            return nil;

      NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                                 , (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(@&#34;Image dimensions: %@ x %@ px&#34;, width, height);
            CFRelease(imageProperties);
      }
</code></pre>

<p>问题是,这段代码在某些图像上工作得很好,而在其他图像上却表现得很奇怪。例如,我加载的一张图片显示宽度为 128 高度为 96 ,而正确的宽度高度为 4320 × 3240。</p>

<p>我不确定这里有什么问题,因为我所做的只是将图像加载到 CGImageSourceRef。 :(</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>原始数据是指相机原始数据吗? (例如尼康 NEF 文件?)</p>

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

<p>免责声明:我从未尝试在 iOS 中打开相机原始图像,所以我对 iOS 正在做什么的回答是基于我对所读内容的不完美内存。 </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 使用 Image I/O 物镜 C 加载 Raw 图像会返回错误的分辨率,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/37942942/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/37942942/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 使用 Image I/O 物镜 C 加载 Raw 图像会返回错误的分辨率