X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3fb1e0594abc234aed02f0b7e614bba7dabc4e99..5c6aad4737c43ad32408132ab5e927679393c47e:/src/msw/bitmap.cpp diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 5a46ab36d7..6e7e0436f6 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -254,7 +254,7 @@ wxGDIImageRefData *wxBitmap::CreateData() const wxGDIRefData *wxBitmap::CloneGDIRefData(const wxGDIRefData *dataOrig) const { const wxBitmapRefData * - data = wx_static_cast(const wxBitmapRefData *, dataOrig); + data = static_cast(dataOrig); if ( !data ) return NULL; @@ -262,25 +262,27 @@ wxGDIRefData *wxBitmap::CloneGDIRefData(const wxGDIRefData *dataOrig) const // wxBitmapRefData using its copy ctor but instead it modifies this // bitmap itself and then returns its m_refData -- which works, of // course (except in !wxUSE_WXDIB), but is completely illogical - wxBitmap *self = wx_const_cast(wxBitmap *, this); + wxBitmap *self = const_cast(this); + wxBitmapRefData *selfdata; #if wxUSE_WXDIB // copy the other bitmap if ( data->m_hBitmap ) { wxDIB dib((HBITMAP)(data->m_hBitmap)); self->CopyFromDIB(dib); + + selfdata = static_cast(m_refData); + selfdata->m_hasAlpha = data->m_hasAlpha; } else #endif // wxUSE_WXDIB { // copy the bitmap data - self->m_refData = new wxBitmapRefData(*data); + selfdata = new wxBitmapRefData(*data); + self->m_refData = selfdata; } - wxBitmapRefData * const - selfdata = wx_static_cast(wxBitmapRefData *, m_refData); - // copy also the mask wxMask * const maskSrc = data->GetMask(); if ( maskSrc ) @@ -540,7 +542,7 @@ bool wxBitmap::Create(int width, int height, const wxDC& dc) wxCHECK_MSG( dc.IsOk(), false, _T("invalid HDC in wxBitmap::Create()") ); const wxMSWDCImpl *impl = wxDynamicCast( dc.GetImpl(), wxMSWDCImpl ); - + if (impl) return DoCreate(width, height, -1, impl->GetHDC()); else @@ -816,7 +818,7 @@ bool wxBitmap::CreateFromImage(const wxImage& image, const wxDC& dc) _T("invalid HDC in wxBitmap::CreateFromImage()") ); const wxMSWDCImpl *impl = wxDynamicCast( dc.GetImpl(), wxMSWDCImpl ); - + if (impl) return CreateFromImage(image, -1, impl->GetHDC()); else @@ -839,14 +841,17 @@ 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(); + + if (depth == -1) + depth = dib.GetDepth(); // 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; m_refData = refData; @@ -857,20 +862,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 @@ -1130,7 +1132,7 @@ wxBitmap wxBitmap::GetSubBitmapOfHDC( const wxRect& rect, WXHDC hdc ) const { SelectInHDC selectDst(dcDst, GetHbitmapOf(ret)); - + if ( !selectDst ) { wxLogLastError(_T("SelectObject(destBitmap)")); @@ -1173,13 +1175,13 @@ wxBitmap wxBitmap::GetSubBitmapOfHDC( const wxRect& rect, WXHDC hdc ) const wxPalette* wxBitmap::GetPalette() const { return GetBitmapData() ? &GetBitmapData()->m_bitmapPalette - : (wxPalette *) NULL; + : NULL; } #endif wxMask *wxBitmap::GetMask() const { - return GetBitmapData() ? GetBitmapData()->GetMask() : (wxMask *) NULL; + return GetBitmapData() ? GetBitmapData()->GetMask() : NULL; } wxBitmap wxBitmap::GetMaskBitmap() const @@ -1195,7 +1197,7 @@ wxBitmap wxBitmap::GetMaskBitmap() const wxDC *wxBitmap::GetSelectedInto() const { - return GetBitmapData() ? GetBitmapData()->m_selectedInto : (wxDC *) NULL; + return GetBitmapData() ? GetBitmapData()->m_selectedInto : NULL; } #endif