X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fd94e8aa4563b22e7c66c379625a8373d20720aa..82cf15a4d43b1db7106641aaa544efdcdfd48302:/src/common/image.cpp diff --git a/src/common/image.cpp b/src/common/image.cpp index f533e00432..d4f9ddac8c 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -274,6 +274,7 @@ wxImage wxImage::Scale( int width, int height ) const } } #endif + // In case this is a cursor, make sure the hotspot is scalled accordingly: if ( HasOption(wxIMAGE_OPTION_CUR_HOTSPOT_X) ) image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, @@ -937,11 +938,28 @@ bool wxImage::LoadFile( const wxString& filename, const wxString& mimetype, int #endif // wxUSE_STREAMS } + + +bool wxImage::SaveFile( const wxString& filename ) const +{ + wxString ext = filename.AfterLast('.').Lower(); + + wxImageHandler * pHandler = FindHandler(ext, -1); + if (pHandler) + { + SaveFile(filename, pHandler->GetType()); + return TRUE; + } + + wxLogError(_("Can't save image to file '%s': unknown extension."), filename.c_str()); + + return FALSE; +} + bool wxImage::SaveFile( const wxString& filename, int type ) const { #if wxUSE_STREAMS - if ( !HasOption(wxIMAGE_OPTION_FILENAME) ) - ((wxImage*)this)->SetOption(wxIMAGE_OPTION_FILENAME, filename); + ((wxImage*)this)->SetOption(wxIMAGE_OPTION_FILENAME, filename); wxFileOutputStream stream(filename); @@ -958,8 +976,7 @@ bool wxImage::SaveFile( const wxString& filename, int type ) const bool wxImage::SaveFile( const wxString& filename, const wxString& mimetype ) const { #if wxUSE_STREAMS - if ( !HasOption(wxIMAGE_OPTION_FILENAME) ) - ((wxImage*)this)->SetOption(wxIMAGE_OPTION_FILENAME, filename); + ((wxImage*)this)->SetOption(wxIMAGE_OPTION_FILENAME, filename); wxFileOutputStream stream(filename); @@ -1281,10 +1298,10 @@ bool wxImageHandler::CanRead( const wxString& name ) //----------------------------------------------------------------------------- -// wxBitmap convertion routines +// Deprecated wxBitmap convertion routines //----------------------------------------------------------------------------- -#if wxUSE_GUI +#if WXWIN_COMPATIBILITY_2_2 && wxUSE_GUI #ifdef __WXGTK__ wxBitmap wxImage::ConvertToMonoBitmap( unsigned char red, unsigned char green, unsigned char blue ) const @@ -1306,24 +1323,7 @@ wxImage::wxImage( const wxBitmap &bitmap ) *this = bitmap.ConvertToImage(); } -#endif - - - -// A module to allow wxImage initialization/cleanup -// without calling these functions from app.cpp or from -// the user's application. - -class wxImageModule: public wxModule -{ -DECLARE_DYNAMIC_CLASS(wxImageModule) -public: - wxImageModule() {} - bool OnInit() { wxImage::InitStandardHandlers(); return TRUE; }; - void OnExit() { wxImage::CleanUpHandlers(); }; -}; - -IMPLEMENT_DYNAMIC_CLASS(wxImageModule, wxModule) +#endif // WXWIN_COMPATIBILITY_2_2 && wxUSE_GUI //----------------------------------------------------------------------------- @@ -1650,4 +1650,24 @@ wxImage wxImage::Rotate(double angle, const wxPoint & centre_of_rotation, bool i return rotated; } + + + + +// A module to allow wxImage initialization/cleanup +// without calling these functions from app.cpp or from +// the user's application. + +class wxImageModule: public wxModule +{ +DECLARE_DYNAMIC_CLASS(wxImageModule) +public: + wxImageModule() {} + bool OnInit() { wxImage::InitStandardHandlers(); return TRUE; }; + void OnExit() { wxImage::CleanUpHandlers(); }; +}; + +IMPLEMENT_DYNAMIC_CLASS(wxImageModule, wxModule) + + #endif // wxUSE_IMAGE