【问题标题】:When to add properties using CGImageDestinationSetProperties and when to add properties with CGImageDestinationAddImage何时使用 CGImageDestinationSetProperties 添加属性以及何时使用 CGImageDestinationAddImage 添加属性
【发布时间】:2013-10-18 12:04:18
【问题描述】:

我一直在研究使用 CGImageDestinationRef 创建 gif 文件,但我找不到任何文档,说明我应该使用 CGImageDestinationSetProperties 应用哪些属性,以及在将图像添加到 CGImageDestination 对象时应该设置哪些属性使用 CGImageDestinationAddImage。

但我意识到这个问题不仅仅适用于将图像文件导出为 GIF 文件。

我查看了 CGImageSource 返回的一些属性,尽管这提供了一些线索,但它是命中注定的。但例如,似乎 HasGlobalColorMap 和 LoopCount 应该是使用 CGImageDestinationSetProperties 设置的属性,而 UnclampedDelayTime 和 DelayTime 是应该在添加图像时设置的属性。

我正在了解应该直接将哪些属性添加到 CGImageDestinationRef 以及添加图像时应该添加哪些属性?

谢谢

【问题讨论】:

    标签: ios macos core-graphics


    【解决方案1】:

    我希望 Apple 在解释这些小细节方面做得更好。我也在为这个问题摸不着头脑。

    查看Image I/O Programming Guide 示例,所有属性都使用CGImageDestinationAddImage 设置在单个图像上(尽管那里的描述确实与此相矛盾...)。

    CGImageProperties Reference 中有一个列表,列出了CGImageDestinationSetPropertiesCGImageDestinationAddImage 使用的所有(?)可能的键。它区分了单个图像键、格式特定键和“图像源容器属性”(只有一个键):

    图像源容器属性

    一般适用于容器但不一定适用于容器中任何单个图像的属性。

    这意味着(并通过随机抽样试验支持错误)所有其他键应使用带有CGImageDestinationAddImage 的单个图像设置。

    【讨论】:

    • 最后对我来说,我需要通过反复试验来测试。这是我可以确定 {GIF}.LoopCount 和 {GIF}.HasGlobalColorMap 都是使用 CGImageDestinationSetProperties 设置的唯一方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-13
    • 1970-01-01
    • 2010-12-11
    相关资源
    最近更新 更多