From c90c34007a72d942f378e46b77e4f4456ac9c5b1 Mon Sep 17 00:00:00 2001 From: Stefan Neis Date: Sun, 18 Sep 2005 23:27:28 +0000 Subject: [PATCH] Added (dummy) handler for loading bitmap from file instead of resource. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35585 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/os2/bitmap.h | 9 +++++++++ src/os2/bitmap.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/include/wx/os2/bitmap.h b/include/wx/os2/bitmap.h index 555184acc8..5b5e917b4d 100644 --- a/include/wx/os2/bitmap.h +++ b/include/wx/os2/bitmap.h @@ -162,6 +162,9 @@ public: virtual bool LoadFile( int nId ,long lType = wxBITMAP_TYPE_BMP_RESOURCE ); + virtual bool LoadFile( const wxString& rName + ,long lType = wxBITMAP_TYPE_XPM + ); virtual bool SaveFile( const wxString& rName ,int lType ,const wxPalette* pCmap = NULL @@ -312,6 +315,12 @@ public: ,int nDesiredWidth ,int nDesiredHeight ); + virtual bool LoadFile( wxBitmap* pBitmap + ,const wxString& rName + ,long lFlags + ,int nDesiredWidth + ,int nDesiredHeight + ); virtual bool SaveFile( wxBitmap* pBitmap ,const wxString& rName ,int lType diff --git a/src/os2/bitmap.cpp b/src/os2/bitmap.cpp index 51b5cfdc4c..8f74051db4 100644 --- a/src/os2/bitmap.cpp +++ b/src/os2/bitmap.cpp @@ -407,6 +407,34 @@ bool wxBitmap::CreateFromXpm( #endif } // end of wxBitmap::CreateFromXpm +bool wxBitmap::LoadFile(const wxString& filename, long type) +{ + UnRef(); + + wxBitmapHandler *handler = wxDynamicCast(FindHandler(type), wxBitmapHandler); + + if ( handler ) + { + m_refData = new wxBitmapRefData; + + return handler->LoadFile(this, filename, type, -1, -1); + } +#if wxUSE_IMAGE + else // no bitmap handler found + { + wxImage image; + if ( image.LoadFile( filename, type ) && image.Ok() ) + { + *this = wxBitmap(image); + + return true; + } + } +#endif // wxUSE_IMAGE + + return false; +} + bool wxBitmap::LoadFile( int nId , long lType @@ -1505,6 +1533,17 @@ bool wxBitmapHandler::LoadFile( return false; } +bool wxBitmapHandler::LoadFile( + wxBitmap* WXUNUSED(pBitmap) +, const wxString& WXUNUSED(rName) +, long WXUNUSED(lType) +, int WXUNUSED(nDesiredWidth) +, int WXUNUSED(nDesiredHeight) +) +{ + return false; +} + bool wxBitmapHandler::SaveFile( wxBitmap* WXUNUSED(pBitmap) , const wxString& WXUNUSED(rName) -- 2.45.2