-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAnimatedWebPCoder.swift
61 lines (49 loc) · 1.5 KB
/
AnimatedWebPCoder.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// AnimatedWebPCoder.swift
// ImageX
//
// Created by Condy on 2023/7/15.
//
import Foundation
import Harbeth
public struct AnimatedWebPCoder: AnimatedCodering {
public var data: Data
public var imageSource: CGImageSource?
public var frameCount: Int = 0
public var format: AssetType {
.webp
}
public var unclampedDelayTimeProperty: String {
if #available(iOS 14.0, tvOS 14, macOS 11, watchOS 7, *) {
return String(kCGImagePropertyWebPUnclampedDelayTime)
} else {
return "UnclampedDelayTime"
}
}
public var delayTimeProperty: String {
if #available(iOS 14.0, tvOS 14, macOS 11, watchOS 7, *) {
return String(kCGImagePropertyWebPDelayTime)
} else {
return "DelayTime"
}
}
public var dictionaryProperty: String {
if #available(iOS 14.0, tvOS 14, macOS 11, watchOS 7, *) {
return String(kCGImagePropertyWebPDictionary)
} else {
return "{WebP}"
}
}
public init(data: Data) {
self.data = data
}
public func decodedCGImage(options: ImageCoderOptions, index: Int) -> CGImage? {
guard canDecode(), let imageSource = self.imageSource else {
return nil
}
return imageSource.img.toCGImage(index: index)
}
public static func encodeImage(_ image: Harbeth.C7Image, options: ImageCoderOptions) -> Data? {
return nil
}
}