From f6787b72081cd367b7b50d0fb7d683de46ab8fdb Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Thu, 21 Jan 2016 17:33:02 +0100 Subject: [PATCH] Convert 32bpp wxBitmap with alpha flag set to wxImage with alpha channel values. Create wxImage with alpha values if bitmap is explicitly marked as an ARGB one. Otherwise it will be checked automatically whether 32bpp bitmap contains real alpha channel values or not and output wxImage will be created with or without alpha channel values. --- src/msw/bitmap.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 780d12cb74..9b2c4ad9dc 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -932,7 +932,14 @@ wxImage wxBitmap::ConvertToImage() const } // and then DIB to our wxImage - wxImage image = dib.ConvertToImage(); + // By default, we autodetect the presence of alpha and consider unnecessary + // to create the alpha channel in wxImage if we don't have any effective + // alpha in the bitmap because its depth, on its own, is not an indicator + // that it uses alpha as it could be just the default screen depth. However + // if the user had explicitly called UseAlpha(), then we consider + // that the resulting image should really have the alpha channel too. + wxImage image = dib.ConvertToImage(HasAlpha() ? + wxDIB::Convert_AlphaAlwaysIf32bpp : wxDIB::Convert_AlphaAuto); if ( !image.IsOk() ) { return wxNullImage;