From a29b55cdf6c1f8547c615a5e928813ba78566e9a Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 16 Aug 2004 12:31:42 +0000 Subject: [PATCH] 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 --- src/gtk/bitmap.cpp | 9 +++++++-- src/gtk1/bitmap.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) 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(); -- 2.45.2