diff --git a/docs/changes.txt b/docs/changes.txt index f11b13b57b..d1d28a489b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -135,7 +135,9 @@ wxMSW: - Fix quoting of arguments passed to wxExecute(char **) (Brian Ravnsgaard Riis). - Support disabling items before adding them to the menu (Christian Walther). - Allow to call SetFont(wxNullFont) to reset the font to default. -- Implement UUID::operator==() and !=() (SQLAware). +- Implement UUID::operator==() and !=() (SQLAware Corporation). +- Fixed long standing (introduced in 2.6.3) bug which resulted in always + creating a DIB and not DDB in wxBitmap(const wxImage&) ctor. wxGTK: diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 6dde041876..e8e525dfce 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -808,14 +808,15 @@ bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc) if ( !dib.IsOk() ) return false; - if ( depth == -1 ) - depth = dib.GetDepth(); // Get depth from image if none specified + const bool hasAlpha = image.HasAlpha(); // store the bitmap parameters - wxBitmapRefData *refData = new wxBitmapRefData; + wxBitmapRefData * const refData = new wxBitmapRefData; refData->m_width = w; refData->m_height = h; - refData->m_hasAlpha = image.HasAlpha(); + refData->m_hasAlpha = hasAlpha; + refData->m_depth = depth == -1 ? (hasAlpha ? 32 : 24) + : depth; m_refData = refData; @@ -826,20 +827,17 @@ bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc) // are we going to use DIB? // // NB: DDBs don't support alpha so if we have alpha channel we must use DIB - if ( image.HasAlpha() || wxShouldCreateDIB(w, h, depth, hdc) ) + if ( hasAlpha || wxShouldCreateDIB(w, h, depth, hdc) ) { // don't delete the DIB section in dib object dtor hbitmap = dib.Detach(); refData->m_isDIB = true; - refData->m_depth = depth; } #ifndef ALWAYS_USE_DIB else // we need to convert DIB to DDB { hbitmap = dib.CreateDDB((HDC)hdc); - - refData->m_depth = depth; } #endif // !ALWAYS_USE_DIB