don't always create DIBs in wxBitmap(wxImage) ctor
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55153 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -540,7 +540,7 @@ bool wxBitmap::Create(int width, int height, const wxDC& dc)
|
|||||||
wxCHECK_MSG( dc.IsOk(), false, _T("invalid HDC in wxBitmap::Create()") );
|
wxCHECK_MSG( dc.IsOk(), false, _T("invalid HDC in wxBitmap::Create()") );
|
||||||
|
|
||||||
const wxMSWDCImpl *impl = wxDynamicCast( dc.GetImpl(), wxMSWDCImpl );
|
const wxMSWDCImpl *impl = wxDynamicCast( dc.GetImpl(), wxMSWDCImpl );
|
||||||
|
|
||||||
if (impl)
|
if (impl)
|
||||||
return DoCreate(width, height, -1, impl->GetHDC());
|
return DoCreate(width, height, -1, impl->GetHDC());
|
||||||
else
|
else
|
||||||
@@ -816,7 +816,7 @@ bool wxBitmap::CreateFromImage(const wxImage& image, const wxDC& dc)
|
|||||||
_T("invalid HDC in wxBitmap::CreateFromImage()") );
|
_T("invalid HDC in wxBitmap::CreateFromImage()") );
|
||||||
|
|
||||||
const wxMSWDCImpl *impl = wxDynamicCast( dc.GetImpl(), wxMSWDCImpl );
|
const wxMSWDCImpl *impl = wxDynamicCast( dc.GetImpl(), wxMSWDCImpl );
|
||||||
|
|
||||||
if (impl)
|
if (impl)
|
||||||
return CreateFromImage(image, -1, impl->GetHDC());
|
return CreateFromImage(image, -1, impl->GetHDC());
|
||||||
else
|
else
|
||||||
@@ -839,14 +839,15 @@ bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc)
|
|||||||
if ( !dib.IsOk() )
|
if ( !dib.IsOk() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( depth == -1 )
|
const bool hasAlpha = image.HasAlpha();
|
||||||
depth = dib.GetDepth(); // Get depth from image if none specified
|
|
||||||
|
|
||||||
// store the bitmap parameters
|
// store the bitmap parameters
|
||||||
wxBitmapRefData *refData = new wxBitmapRefData;
|
wxBitmapRefData * const refData = new wxBitmapRefData;
|
||||||
refData->m_width = w;
|
refData->m_width = w;
|
||||||
refData->m_height = h;
|
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;
|
m_refData = refData;
|
||||||
|
|
||||||
@@ -857,20 +858,17 @@ bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc)
|
|||||||
// are we going to use DIB?
|
// are we going to use DIB?
|
||||||
//
|
//
|
||||||
// NB: DDBs don't support alpha so if we have alpha channel we must 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
|
// don't delete the DIB section in dib object dtor
|
||||||
hbitmap = dib.Detach();
|
hbitmap = dib.Detach();
|
||||||
|
|
||||||
refData->m_isDIB = true;
|
refData->m_isDIB = true;
|
||||||
refData->m_depth = depth;
|
|
||||||
}
|
}
|
||||||
#ifndef ALWAYS_USE_DIB
|
#ifndef ALWAYS_USE_DIB
|
||||||
else // we need to convert DIB to DDB
|
else // we need to convert DIB to DDB
|
||||||
{
|
{
|
||||||
hbitmap = dib.CreateDDB((HDC)hdc);
|
hbitmap = dib.CreateDDB((HDC)hdc);
|
||||||
|
|
||||||
refData->m_depth = depth;
|
|
||||||
}
|
}
|
||||||
#endif // !ALWAYS_USE_DIB
|
#endif // !ALWAYS_USE_DIB
|
||||||
|
|
||||||
@@ -1130,7 +1128,7 @@ wxBitmap wxBitmap::GetSubBitmapOfHDC( const wxRect& rect, WXHDC hdc ) const
|
|||||||
|
|
||||||
{
|
{
|
||||||
SelectInHDC selectDst(dcDst, GetHbitmapOf(ret));
|
SelectInHDC selectDst(dcDst, GetHbitmapOf(ret));
|
||||||
|
|
||||||
if ( !selectDst )
|
if ( !selectDst )
|
||||||
{
|
{
|
||||||
wxLogLastError(_T("SelectObject(destBitmap)"));
|
wxLogLastError(_T("SelectObject(destBitmap)"));
|
||||||
|
Reference in New Issue
Block a user