]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/image.cpp
added rtti info (python problem)
[wxWidgets.git] / src / common / image.cpp
index 48b39581f5a6a69f1d13687d93e268061fb44db7..0f2e9b6def4abbabaf8f75bb8b32868052fefc0c 100644 (file)
@@ -131,6 +131,7 @@ wxImage::wxImage( wxInputStream& stream, const wxString& mimetype, int index )
 #endif // wxUSE_STREAMS
 
 wxImage::wxImage( const wxImage& image )
 #endif // wxUSE_STREAMS
 
 wxImage::wxImage( const wxImage& image )
+    : wxObject()
 {
     Ref(image);
 }
 {
     Ref(image);
 }
@@ -275,6 +276,14 @@ wxImage wxImage::Scale( int width, int height ) const
     }
 #endif
 
     }
 #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,
+                (GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X)*width)/old_width);
+    if ( HasOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y) )
+        image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y,
+                (GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y)*height)/old_height);
+
     return image;
 }
 
     return image;
 }
 
@@ -930,9 +939,29 @@ bool wxImage::LoadFile( const wxString& filename, const wxString& mimetype, int
 #endif // wxUSE_STREAMS
 }
 
 #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
 bool wxImage::SaveFile( const wxString& filename, int type ) const
 {
 #if wxUSE_STREAMS
+    ((wxImage*)this)->SetOption(wxIMAGE_OPTION_FILENAME, filename);
+
     wxFileOutputStream stream(filename);
 
     if ( stream.LastError() == wxStream_NOERROR )
     wxFileOutputStream stream(filename);
 
     if ( stream.LastError() == wxStream_NOERROR )
@@ -948,6 +977,8 @@ bool wxImage::SaveFile( const wxString& filename, int type ) const
 bool wxImage::SaveFile( const wxString& filename, const wxString& mimetype ) const
 {
 #if wxUSE_STREAMS
 bool wxImage::SaveFile( const wxString& filename, const wxString& mimetype ) const
 {
 #if wxUSE_STREAMS
+    ((wxImage*)this)->SetOption(wxIMAGE_OPTION_FILENAME, filename);
+
     wxFileOutputStream stream(filename);
 
     if ( stream.LastError() == wxStream_NOERROR )
     wxFileOutputStream stream(filename);
 
     if ( stream.LastError() == wxStream_NOERROR )
@@ -1268,10 +1299,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
 
 #ifdef __WXGTK__
 wxBitmap wxImage::ConvertToMonoBitmap( unsigned char red, unsigned char green, unsigned char blue ) const
@@ -1293,24 +1324,7 @@ wxImage::wxImage( const wxBitmap &bitmap )
     *this = bitmap.ConvertToImage();
 }
 
     *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
 
 
 //-----------------------------------------------------------------------------
 
 
 //-----------------------------------------------------------------------------
@@ -1637,4 +1651,24 @@ wxImage wxImage::Rotate(double angle, const wxPoint & centre_of_rotation, bool i
     return rotated;
 }
 
     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
 #endif // wxUSE_IMAGE