From: Václav Slavík Date: Mon, 16 Aug 2004 12:31:42 +0000 (+0000) Subject: fixed wxImage->wxBitmap conversion for images with alpha channel X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a29b55cdf6c1f8547c615a5e928813ba78566e9a fixed wxImage->wxBitmap conversion for images with alpha channel git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28811 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index de3d7c1f67..2cb613a8fe 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -527,13 +527,18 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, return bmp; } -bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) +bool wxBitmap::CreateFromImage( const wxImage& img, int depth ) { UnRef(); - wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") ) + wxCHECK_MSG( img.Ok(), FALSE, wxT("invalid image") ) wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") ) + // NB: wxGTK doesn't yet support alpha channel in bitmaps. The best we can + // do is to convert alpha channel to mask, if it is present: + wxImage image(img); + image.ConvertAlphaToMask(); + int width = image.GetWidth(); int height = image.GetHeight(); diff --git a/src/gtk1/bitmap.cpp b/src/gtk1/bitmap.cpp index de3d7c1f67..2cb613a8fe 100644 --- a/src/gtk1/bitmap.cpp +++ b/src/gtk1/bitmap.cpp @@ -527,13 +527,18 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, return bmp; } -bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) +bool wxBitmap::CreateFromImage( const wxImage& img, int depth ) { UnRef(); - wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") ) + wxCHECK_MSG( img.Ok(), FALSE, wxT("invalid image") ) wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") ) + // NB: wxGTK doesn't yet support alpha channel in bitmaps. The best we can + // do is to convert alpha channel to mask, if it is present: + wxImage image(img); + image.ConvertAlphaToMask(); + int width = image.GetWidth(); int height = image.GetHeight();