|
28 | 28 |
|
29 | 29 | // Specify File Size for lossy format encoding, like JPEG
|
30 | 30 | static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestinationRequestedFileSize";
|
| 31 | +// Support Xcode 15 SDK, use raw value instead of symbol |
| 32 | +static NSString * kSDCGImageDestinationEncodeRequest = @"kCGImageDestinationEncodeRequest"; |
| 33 | +static NSString * kSDCGImageDestinationEncodeToSDR = @"kCGImageDestinationEncodeToSDR"; |
| 34 | +static NSString * kSDCGImageDestinationEncodeToISOHDR = @"kCGImageDestinationEncodeToISOHDR"; |
| 35 | +static NSString * kSDCGImageDestinationEncodeToISOGainmap = @"kCGImageDestinationEncodeToISOGainmap"; |
| 36 | + |
31 | 37 |
|
32 | 38 | // This strip the un-wanted CGImageProperty, like the internal CGImageSourceRef in iOS 15+
|
33 | 39 | // However, CGImageCreateCopy still keep those CGImageProperty, not suit for our use case
|
@@ -282,6 +288,18 @@ @implementation SDImageIOAnimatedCoder {
|
282 | 288 | BOOL _decodeToHDR;
|
283 | 289 | }
|
284 | 290 |
|
| 291 | +#if SD_IMAGEIO_HDR_ENCODING |
| 292 | ++ (void)initialize { |
| 293 | + if (@available(macOS 15, iOS 18, tvOS 18, watchOS 11, *)) { |
| 294 | + // Use SDK instead of raw value |
| 295 | + kSDCGImageDestinationEncodeRequest = (__bridge NSString *)kCGImageDestinationEncodeRequest; |
| 296 | + kSDCGImageDestinationEncodeToSDR = (__bridge NSString *)kCGImageDestinationEncodeToSDR; |
| 297 | + kSDCGImageDestinationEncodeToISOHDR = (__bridge NSString *)kCGImageDestinationEncodeToISOHDR; |
| 298 | + kSDCGImageDestinationEncodeToISOGainmap = (__bridge NSString *)kCGImageDestinationEncodeToISOGainmap; |
| 299 | + } |
| 300 | +} |
| 301 | +#endif |
| 302 | + |
285 | 303 | - (void)dealloc
|
286 | 304 | {
|
287 | 305 | if (_imageSource) {
|
@@ -902,11 +920,11 @@ - (NSData *)encodedDataWithFrames:(NSArray<SDImageFrame *> *)frames loopCount:(N
|
902 | 920 | }
|
903 | 921 | if (@available(macOS 15, iOS 18, tvOS 18, watchOS 11, *)) {
|
904 | 922 | if (encodeToHDR == 1) {
|
905 |
| - properties[(__bridge NSString *)kCGImageDestinationEncodeRequest] = (__bridge NSString *)kCGImageDestinationEncodeToISOHDR; |
| 923 | + properties[kSDCGImageDestinationEncodeRequest] = kSDCGImageDestinationEncodeToISOHDR; |
906 | 924 | } else if (encodeToHDR == 2) {
|
907 |
| - properties[(__bridge NSString *)kCGImageDestinationEncodeRequest] = (__bridge NSString *)kCGImageDestinationEncodeToISOGainmap; |
| 925 | + properties[kSDCGImageDestinationEncodeRequest] = kSDCGImageDestinationEncodeToISOGainmap; |
908 | 926 | } else {
|
909 |
| - properties[(__bridge NSString *)kCGImageDestinationEncodeRequest] = (__bridge NSString *)kCGImageDestinationEncodeToSDR; |
| 927 | + properties[kSDCGImageDestinationEncodeRequest] = kSDCGImageDestinationEncodeToSDR; |
910 | 928 | }
|
911 | 929 | }
|
912 | 930 |
|
|
0 commit comments