From 6f2293d91b2a583d2ca594be081cdcf73ebc953a Mon Sep 17 00:00:00 2001 From: reuk Date: Wed, 14 Aug 2024 14:25:20 +0100 Subject: [PATCH] Windows: Fix conversion of WindowsBitmapImages to SoftwareBitmapImages --- .../native/juce_Windowing_windows.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_Windowing_windows.cpp b/modules/juce_gui_basics/native/juce_Windowing_windows.cpp index 6634602ec2..8513b1a360 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_windows.cpp +++ b/modules/juce_gui_basics/native/juce_Windowing_windows.cpp @@ -1019,8 +1019,18 @@ public: std::unique_ptr createType() const override { - // WindowsBitmapImage needs to be a software bitmap, not a D2D bitmap - return std::make_unique(); + // This type only exists to return a type ID that's different to the SoftwareImageType's ID, + // so that `SoftwareImageType{}.convert (windowsBitmapImage)` works. + // If we return SoftwareImageType here, then SoftwareImageType{}.convert() will compare the + // type IDs and assume the source image is already of the correct type. + struct Type : public ImageType + { + int getTypeID() const override { return ByteOrder::makeInt ('w', 'b', 'i', 't'); } + ImagePixelData::Ptr create (Image::PixelFormat, int, int, bool) const override { return {}; } + Image convert (const Image&) const override { return {}; } + }; + + return std::make_unique(); } std::unique_ptr createLowLevelContext() override