@@ -13,7 +13,7 @@ public import WinSDK
1313
1414extension AttachableImageFormat {
1515 private static let _encoderPathExtensionsByCLSID = Result {
16- var result = [ GUID : [ String] ] ( )
16+ var result = [ CLSID . Wrapper : [ String] ] ( )
1717
1818 // Create an imaging factory.
1919 let factory = try IWICImagingFactory . create ( )
@@ -66,7 +66,7 @@ extension AttachableImageFormat {
6666 continue
6767 }
6868 let extensions = _pathExtensions ( for: info)
69- result [ clsid] = extensions
69+ result [ CLSID . Wrapper ( clsid) ] = extensions
7070 }
7171
7272 return result
@@ -133,7 +133,7 @@ extension AttachableImageFormat {
133133 0 == _wcsicmp ( pathExtension, encoderExt)
134134 }
135135 }
136- } . map { $0. key }
136+ } . map { $0. key. rawValue }
137137 }
138138
139139 /// Get the `CLSID` value of the WIC image encoder corresponding to the same
@@ -169,13 +169,13 @@ extension AttachableImageFormat {
169169 static func appendPathExtension( for clsid: CLSID , to preferredName: String ) -> String {
170170 // If there's already a CLSID associated with the filename, and it matches
171171 // the one passed to us, no changes are needed.
172- if let existingCLSID = computeEncoderCLSID ( forPreferredName: preferredName) , clsid == existingCLSID {
172+ if let existingCLSID = computeEncoderCLSID ( forPreferredName: preferredName) , CLSID . Wrapper ( clsid) == CLSID . Wrapper ( existingCLSID) {
173173 return preferredName
174174 }
175175
176176 // Find the preferred path extension for the encoder with the given CLSID.
177177 let encoderPathExtensionsByCLSID = ( try ? _encoderPathExtensionsByCLSID. get ( ) ) ?? [ : ]
178- if let ext = encoderPathExtensionsByCLSID [ clsid] ? . first {
178+ if let ext = encoderPathExtensionsByCLSID [ CLSID . Wrapper ( clsid) ] ? . first {
179179 return " \( preferredName) . \( ext) "
180180 }
181181
@@ -202,7 +202,7 @@ extension AttachableImageFormat {
202202 case . jpeg:
203203 CLSID_WICJpegEncoder
204204 case let . systemValue( clsid) :
205- clsid as! GUID
205+ ( clsid as! CLSID . Wrapper ) . rawValue
206206 }
207207 }
208208
@@ -231,11 +231,12 @@ extension AttachableImageFormat {
231231 @_spi ( _)
232232#endif
233233 public init ( encoderCLSID: CLSID , encodingQuality: Float = 1.0 ) {
234- if encoderCLSID == CLSID_WICPngEncoder {
234+ switch CLSID . Wrapper ( encoderCLSID) {
235+ case CLSID . Wrapper ( CLSID_WICPngEncoder) :
235236 self = . png
236- } else if encoderCLSID == CLSID_WICJpegEncoder {
237+ case CLSID . Wrapper ( CLSID_WICJpegEncoder) :
237238 self = . jpeg
238- } else {
239+ case let encoderCLSID :
239240 self . init ( kind: . systemValue( encoderCLSID) , encodingQuality: encodingQuality)
240241 }
241242 }
0 commit comments