Add missing wxUSE_WXDIB checks.

Fix compilation with wxUSE_WXDIB==0.

Closes #16113.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76197 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2014-03-24 18:46:18 +00:00
parent 338cf327b0
commit da91677e97
3 changed files with 19 additions and 7 deletions

View File

@ -68,10 +68,10 @@ public:
virtual void Free(); virtual void Free();
#if wxUSE_WXDIB
// Creates a new bitmap (DDB or DIB) from the contents of the given DIB. // Creates a new bitmap (DDB or DIB) from the contents of the given DIB.
void CopyFromDIB(const wxDIB& dib); void CopyFromDIB(const wxDIB& dib);
#if wxUSE_WXDIB
// Takes ownership of the given DIB. // Takes ownership of the given DIB.
bool AssignDIB(wxDIB& dib); bool AssignDIB(wxDIB& dib);
@ -130,13 +130,14 @@ public:
private: private:
void Init(); void Init();
#if wxUSE_WXDIB
// Initialize using the given DIB but use (and take ownership of) the // Initialize using the given DIB but use (and take ownership of) the
// bitmap handle if it is valid, assuming it's a DDB. If it's not valid, // bitmap handle if it is valid, assuming it's a DDB. If it's not valid,
// use the DIB handle itself taking ownership of it (i.e. wxDIB will become // use the DIB handle itself taking ownership of it (i.e. wxDIB will become
// invalid when this function returns even though we take it as const // invalid when this function returns even though we take it as const
// reference because this is how it's passed to us). // reference because this is how it's passed to us).
void InitFromDIB(const wxDIB& dib, HBITMAP hbitmap = NULL); void InitFromDIB(const wxDIB& dib, HBITMAP hbitmap = NULL);
#endif // wxUSE_WXDIB
// optional mask for transparent drawing // optional mask for transparent drawing
wxMask *m_bitmapMask; wxMask *m_bitmapMask;
@ -232,8 +233,10 @@ wxBitmapRefData::wxBitmapRefData(const wxBitmapRefData& data)
if (data.m_bitmapMask) if (data.m_bitmapMask)
m_bitmapMask = new wxMask(*data.m_bitmapMask); m_bitmapMask = new wxMask(*data.m_bitmapMask);
#if wxUSE_WXDIB
wxASSERT_MSG( !data.m_dib, wxASSERT_MSG( !data.m_dib,
wxT("can't copy bitmap locked for raw access!") ); wxT("can't copy bitmap locked for raw access!") );
#endif // wxUSE_WXDIB
m_hasAlpha = data.m_hasAlpha; m_hasAlpha = data.m_hasAlpha;
@ -291,6 +294,8 @@ void wxBitmapRefData::Free()
wxDELETE(m_bitmapMask); wxDELETE(m_bitmapMask);
} }
#if wxUSE_WXDIB
void wxBitmapRefData::InitFromDIB(const wxDIB& dib, HBITMAP hbitmap) void wxBitmapRefData::InitFromDIB(const wxDIB& dib, HBITMAP hbitmap)
{ {
m_width = dib.GetWidth(); m_width = dib.GetWidth();
@ -339,8 +344,6 @@ void wxBitmapRefData::CopyFromDIB(const wxDIB& dib)
InitFromDIB(dib, hbitmap); InitFromDIB(dib, hbitmap);
} }
#if wxUSE_WXDIB
bool wxBitmapRefData::AssignDIB(wxDIB& dib) bool wxBitmapRefData::AssignDIB(wxDIB& dib)
{ {
if ( !dib.IsOk() ) if ( !dib.IsOk() )
@ -377,6 +380,7 @@ wxGDIRefData *wxBitmap::CloneGDIRefData(const wxGDIRefData *data) const
return new wxBitmapRefData(*static_cast<const wxBitmapRefData *>(data)); return new wxBitmapRefData(*static_cast<const wxBitmapRefData *>(data));
} }
#if wxUSE_WXDIB
// Premultiply the values of all RGBA pixels in the given range. // Premultiply the values of all RGBA pixels in the given range.
static void PremultiplyPixels(unsigned char* begin, unsigned char* end) static void PremultiplyPixels(unsigned char* begin, unsigned char* end)
{ {
@ -472,6 +476,7 @@ static HBITMAP CreatePremultipliedDIBIfNeeded(HBITMAP hbmp)
return NULL; return NULL;
} }
#endif // wxUSE_WXDIB
bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon, bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon,
wxBitmapTransparency transp) wxBitmapTransparency transp)
@ -1195,12 +1200,14 @@ bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type)
if ( !handler->LoadFile(this, filename, type, -1, -1) ) if ( !handler->LoadFile(this, filename, type, -1, -1) )
return false; return false;
#if wxUSE_WXDIB
// wxBitmap must contain premultiplied data, but external files are not // wxBitmap must contain premultiplied data, but external files are not
// always in this format, so try to detect whether this is the case and // always in this format, so try to detect whether this is the case and
// create a premultiplied DIB if it really is. // create a premultiplied DIB if it really is.
HBITMAP hdib = CreatePremultipliedDIBIfNeeded(GetHbitmap()); HBITMAP hdib = CreatePremultipliedDIBIfNeeded(GetHbitmap());
if ( hdib ) if ( hdib )
static_cast<wxBitmapRefData*>(m_refData)->Set32bppHDIB(hdib); static_cast<wxBitmapRefData*>(m_refData)->Set32bppHDIB(hdib);
#endif // wxUSE_WXDIB
return true; return true;
} }
@ -1369,8 +1376,12 @@ bool wxBitmap::HasAlpha() const
void wxBitmap::MSWUpdateAlpha() void wxBitmap::MSWUpdateAlpha()
{ {
#if wxUSE_WXDIB
if ( CheckAlpha(GetHbitmap()) ) if ( CheckAlpha(GetHbitmap()) )
GetBitmapData()->m_hasAlpha = true; GetBitmapData()->m_hasAlpha = true;
#else // !wxUSE_WXDIB
GetBitmapData()->m_hasAlpha = false;
#endif // wxUSE_WXDIB/!wxUSE_WXDIB
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -378,10 +378,11 @@ wxBitmap wxImageList::GetBitmap(int index) const
GetSize(index, bmp_width, bmp_height); GetSize(index, bmp_width, bmp_height);
wxBitmap bitmap(bmp_width, bmp_height); wxBitmap bitmap(bmp_width, bmp_height);
#if wxUSE_WXDIB && wxUSE_IMAGE
wxMemoryDC dc; wxMemoryDC dc;
dc.SelectObject(bitmap); dc.SelectObject(bitmap);
#if wxUSE_WXDIB && wxUSE_IMAGE
IMAGEINFO ii; IMAGEINFO ii;
ImageList_GetImageInfo(GetHImageList(), index, &ii); ImageList_GetImageInfo(GetHImageList(), index, &ii);
if ( ii.hbmMask ) if ( ii.hbmMask )
@ -425,8 +426,6 @@ wxBitmap wxImageList::GetBitmap(int index) const
// even if it requires more work (and takes more time). // even if it requires more work (and takes more time).
bitmap.MSWUpdateAlpha(); bitmap.MSWUpdateAlpha();
} }
#else
wxBitmap bitmap;
#endif #endif
return bitmap; return bitmap;
} }

View File

@ -306,6 +306,7 @@ void wxStaticBitmap::SetImageNoCopy( wxGDIImage* image)
const HANDLE handleOrig = (HANDLE)m_image->GetHandle(); const HANDLE handleOrig = (HANDLE)m_image->GetHandle();
HANDLE handle = handleOrig; HANDLE handle = handleOrig;
#if wxUSE_WXDIB
if ( !m_isIcon ) if ( !m_isIcon )
{ {
// wxBitmap normally stores alpha in pre-multiplied format but // wxBitmap normally stores alpha in pre-multiplied format but
@ -321,6 +322,7 @@ void wxStaticBitmap::SetImageNoCopy( wxGDIImage* image)
wxDIB::PixelFormat_NotPreMultiplied).Detach(); wxDIB::PixelFormat_NotPreMultiplied).Detach();
} }
} }
#endif // wxUSE_WXDIB
LONG style = ::GetWindowLong( (HWND)GetHWND(), GWL_STYLE ) ; LONG style = ::GetWindowLong( (HWND)GetHWND(), GWL_STYLE ) ;
::SetWindowLong( (HWND)GetHWND(), GWL_STYLE, ( style & ~( SS_BITMAP|SS_ICON ) ) | ::SetWindowLong( (HWND)GetHWND(), GWL_STYLE, ( style & ~( SS_BITMAP|SS_ICON ) ) |
( m_isIcon ? SS_ICON : SS_BITMAP ) ); ( m_isIcon ? SS_ICON : SS_BITMAP ) );