// course (except in !wxUSE_WXDIB), but is completely illogical
wxBitmap *self = wx_const_cast(wxBitmap *, this);
+ wxBitmapRefData *selfdata;
#if wxUSE_WXDIB
// copy the other bitmap
if ( data->m_hBitmap )
{
wxDIB dib((HBITMAP)(data->m_hBitmap));
self->CopyFromDIB(dib);
+
+ selfdata = wx_static_cast(wxBitmapRefData *, 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 )
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
_T("invalid HDC in wxBitmap::CreateFromImage()") );
const wxMSWDCImpl *impl = wxDynamicCast( dc.GetImpl(), wxMSWDCImpl );
-
+
if (impl)
return CreateFromImage(image, -1, impl->GetHDC());
else
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;
// 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
{
SelectInHDC selectDst(dcDst, GetHbitmapOf(ret));
-
+
if ( !selectDst )
{
wxLogLastError(_T("SelectObject(destBitmap)"));