ios – GIFS的DelayTime或UnclampedDelayTime

ios – GIFS的DelayTime或UnclampedDelayTime,第1张

概述将Gif转换为动画UI Image时,每个帧的延迟都从属性kCGImagePropertyGIFDelayTime或kCGImagePropertyGIFUnclampedDelayTime中提取 像这样: NSString *frameKeyPath = [NSString stringWithFormat:@"%@.%@",(NSString*)kCGImagePropertyGIFDicti 将Gif转换为动画UI Image时,每个帧的延迟都从属性kCGImagePropertyGIFDelayTime或kCGImagePropertyGIFUnclampedDelayTime中提取

像这样:

Nsstring *frameKeyPath = [Nsstring stringWithFormat:@"%@.%@",(Nsstring*)kCGImagePropertyGIFDictionary,kCGImagePropertyGIFUnclampedDelayTime];CFDictionaryRef cfFramePropertIEs = CGImageSourcecopyPropertIEsAtIndex(source,i,nil);NSDictionary *framePropertIEs = (__brIDge NSDictionary*)cfFramePropertIEs;NSNumber *delayTimeProp = [framePropertIEs valueForKeyPath:frameKeyPath];

在两个示例情况下,Chrome都会选择正确的:

kCGImagePropertyGIFDelayTime = 0.1:http://i.imgur.com/tX9cjUO.gif

kCGImagePropertyGIFUnclampedDelayTime = 0.01:http://i.minus.com/iIOyK7SKp8TYc.gif

为每个案例选择一个会导致其中一个示例图像动画太慢或太快

有没有办法确定使用哪个属性?

谢谢

解决方法 使用webkit方法结束选择,松开,钳位或0.1默认

+ (float)frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source{    float frameDuration = 0.1f;    CFDictionaryRef cfFramePropertIEs = CGImageSourcecopyPropertIEsAtIndex(source,index,nil);    NSDictionary *framePropertIEs = (__brIDge NSDictionary*)cfFramePropertIEs;    NSDictionary *gifPropertIEs = framePropertIEs[(Nsstring*)kCGImagePropertyGIFDictionary];    NSNumber *delayTimeUnclampedProp = gifPropertIEs[(Nsstring*)kCGImagePropertyGIFUnclampedDelayTime];    if(delayTimeUnclampedProp) {        frameDuration = [delayTimeUnclampedProp floatValue];    } else {        NSNumber *delayTimeProp = gifPropertIEs[(Nsstring*)kCGImagePropertyGIFDelayTime];        if(delayTimeProp) {            frameDuration = [delayTimeProp floatValue];        }    }    // Many annoying ads specify a 0 duration to make an image flash as quickly as possible.    // We follow firefox's behavior and use a duration of 100 ms for any frames that specify    // a duration of <= 10 ms. See <rdar://problem/7689300> and <http://webkit.org/b/36082>    // for more information.    if (frameDuration < 0.011f)        frameDuration = 0.100f;    CFRelease(cfFramePropertIEs);    return frameDuration;}
总结

以上是内存溢出为你收集整理的ios – GIFS的DelayTime或UnclampedDelayTime全部内容,希望文章能够帮你解决ios – GIFS的DelayTime或UnclampedDelayTime所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/web/1065155.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存