From b86ba8a40e2534e383ff2849b8222e808e9e9531 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Thu, 16 Oct 2025 14:20:23 -0400 Subject: [PATCH 1/4] Fix accidentally dropping image encoding quality on the floor on Windows. This fixes a bug in `AttachableImageFormat.init(encoderCLSID:encodingQuality:)` where the `encodingQuality` argument would not be preserved. --- .../Attachments/AttachableImageFormat+CLSID.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift index 37e7c8f9f..e996a21c1 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift @@ -277,13 +277,15 @@ extension AttachableImageFormat { @_spi(_) #endif public init(encoderCLSID: CLSID, encodingQuality: Float = 1.0) { - if encoderCLSID == CLSID_WICPngEncoder { - self = .png - } else if encoderCLSID == CLSID_WICJpegEncoder { - self = .jpeg - } else { - self.init(kind: .systemValue(encoderCLSID), encodingQuality: encodingQuality) + let kind: Kind = switch CLSID.Wrapper(encoderCLSID) { + case CLSID.Wrapper(CLSID_WICPngEncoder): + .png + case CLSID.Wrapper(CLSID_WICJpegEncoder): + .jpeg + case let encoderCLSID: + .systemValue(encoderCLSID) } + self.init(kind: kind, encodingQuality: encodingQuality) } /// Construct an instance of this type with the given path extension and From f863316d73ea8782c2b1d38708a46718ad9cf68e Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Thu, 16 Oct 2025 14:37:12 -0400 Subject: [PATCH 2/4] CLSID.Wrapper isn't on this branch --- .../Attachments/AttachableImageFormat+CLSID.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift index e996a21c1..e614398dd 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift @@ -277,10 +277,10 @@ extension AttachableImageFormat { @_spi(_) #endif public init(encoderCLSID: CLSID, encodingQuality: Float = 1.0) { - let kind: Kind = switch CLSID.Wrapper(encoderCLSID) { - case CLSID.Wrapper(CLSID_WICPngEncoder): + let kind: Kind = switch UInt128(encoderCLSID) { + case UInt128(CLSID_WICPngEncoder): .png - case CLSID.Wrapper(CLSID_WICJpegEncoder): + case UInt128(CLSID_WICJpegEncoder): .jpeg case let encoderCLSID: .systemValue(encoderCLSID) From 57effca9b9b60566c8378d0a47066461b3494782 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Thu, 16 Oct 2025 14:40:59 -0400 Subject: [PATCH 3/4] facepalm --- .../Attachments/AttachableImageFormat+CLSID.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift index e614398dd..cdff7916e 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift @@ -282,7 +282,7 @@ extension AttachableImageFormat { .png case UInt128(CLSID_WICJpegEncoder): .jpeg - case let encoderCLSID: + default: .systemValue(encoderCLSID) } self.init(kind: kind, encodingQuality: encodingQuality) From 43b313220e457893bed3dfea01654a0ef08c8cde Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Thu, 16 Oct 2025 14:51:57 -0400 Subject: [PATCH 4/4] Make the diff less complex to read --- .../Attachments/AttachableImageFormat+CLSID.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift index cdff7916e..72d0d8d3d 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift @@ -277,12 +277,11 @@ extension AttachableImageFormat { @_spi(_) #endif public init(encoderCLSID: CLSID, encodingQuality: Float = 1.0) { - let kind: Kind = switch UInt128(encoderCLSID) { - case UInt128(CLSID_WICPngEncoder): + let kind: Kind = if encoderCLSID == CLSID_WICPngEncoder { .png - case UInt128(CLSID_WICJpegEncoder): + } else if encoderCLSID == CLSID_WICJpegEncoder { .jpeg - default: + } else { .systemValue(encoderCLSID) } self.init(kind: kind, encodingQuality: encodingQuality)