import UIKit
import ImageIO
class Tools: NSObject {
class func parseGIFDataToImageArray(data: NSData) -> [UIImage]{
var images: [UIImage] = []
let src = CGImageSourceCreateWithData(data as CFDataRef,nil)
var animationTime: CGFloat = 0.8
if let src = src {
let total = CGImageSourceGetCount(src)
for var i = 0;i < total;i++ {
let img = CGImageSourceCreateImageAtIndex(src, i, nil)
let properties = CGImageSourceCopyPropertiesAtIndex(src, i, nil)! as Dictionary
let imageProperties = properties[kCGImagePropertyGIFDictionary as String]!
let delayTime = imageProperties[kCGImagePropertyGIFUnclampedDelayTime as String] as! NSNumber
animationTime += CGFloat(delayTime)
if let img = img {
images.append(UIImage(CGImage: img))
}
}
print("time=\(animationTime)")
}
return images
}
}
iOS将GIF转变为图片
最新推荐文章于 2022-06-29 16:47:05 发布
本文详细介绍了如何在iOS应用中将GIF动态图转换为静态图片,包括使用UIImage处理GIF、第三方库的选择与集成,以及性能优化方面的考虑,帮助开发者实现GIF到图片的高效转换。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Qwen3-8B
文本生成
Qwen3
Qwen3 是 Qwen 系列中的最新一代大型语言模型,提供了一整套密集型和专家混合(MoE)模型。基于广泛的训练,Qwen3 在推理、指令执行、代理能力和多语言支持方面取得了突破性进展
531

被折叠的 条评论
为什么被折叠?



