【问题标题】:iOS support for Canon RAW format?iOS 支持 Canon RAW 格式吗?
【发布时间】:2011-09-25 06:56:57
【问题描述】:

我知道 iPad 可以在与 Camera Kit 一起使用时读取 Canon RAW (.CR2) 文件,但 iOS 开发人员可以读取任何文件格式吗?还是我们仅限于 UIImage 类参考文档中支持的内容?

(https://developer.apple.com/documentation/uikit/uiimage)

【问题讨论】:

    标签: iphone ios uiimage


    【解决方案1】:

    对于这样的事情,Apple 的图像 API 不足以满足您的需求。但是,有一些第三方 API 应该适用于 iPhone。 Libraw 是一个很好的,我发现它有一个 C 接口。由于 Objective-C 是 C 的严格超集,您可能可以在您的 iOS 应用程序中使用它。

    根据我在他们的文档中看到的,您可以将 CR2 图像编写为 TIFF,然后将其解码为 UIImage,如下所示:

    NSString * cr2Path = @"path/to/cr2/file";
    NSString * tiffPath = [NSTemporaryDirectory stringByAppendingPathComponent:@"x.tiff"];
    
    libraw_data_t * cr2Data = libraw_init(0);
    libraw_open_file(cr2Data, [cr2Path UTF8String]);
    libraw_unpack(cr2Data);
    // setup encoding params
    cr2Data->params.output_tiff = 1;
    cr2Data->params.use_camera_wb = 1;
    // encode and write as tiff
    libraw_dcraw_process(cr2Data);
    libraw_dcraw_ppm_tiff_writer(cr2Data, [tiffPath UTF8String]);
    libraw_recycle(cr2Data); // free the memory
    // load the UIImage
    UIImage * myImage = [[UIImage alloc] initWithContentsOfFile:tiffPath];
    // use myImage here ...
    [myImage release];
    

    据我所见,您似乎可以使用download it here,然后将src/libraw/dcraw/internal/ 目录中的src 文件添加到您的Xcode 项目中。希望您不会遇到任何奇怪的链接/编译问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-10
      • 1970-01-01
      • 2023-04-02
      • 2014-04-05
      相关资源
      最近更新 更多