#endif // wxUSE_STREAMS
wxImage::wxImage( const wxImage& image )
+ : wxObject()
{
Ref(image);
}
wxCHECK_MSG( data, image, wxT("unable to create image") );
- if (M_IMGDATA->m_hasMask)
- image.SetMaskColour( M_IMGDATA->m_maskRed, M_IMGDATA->m_maskGreen, M_IMGDATA->m_maskBlue );
+ image.SetMaskColour( M_IMGDATA->m_maskRed, M_IMGDATA->m_maskGreen, M_IMGDATA->m_maskBlue );
+ image.SetMask( M_IMGDATA->m_hasMask );
memcpy( data, GetData(), M_IMGDATA->m_width*M_IMGDATA->m_height*3 );
bool wxImage::CanRead( wxInputStream &stream )
{
- wxList &list=GetHandlers();
+ const wxList& list = GetHandlers();
for ( wxList::Node *node = list.GetFirst(); node; node = node->GetNext() )
{
return CanRead(stream);
}
- else {
- wxLogError( _("Can't check image format of file '%s': file does not exist."), name.c_str() );
+ wxLogError( _("Can't check image format of file '%s': file does not exist."), name.c_str() );
+
+ return FALSE;
+}
+
+bool wxImageHandler::CallDoCanRead(wxInputStream& stream)
+{
+ off_t posOld = stream.TellI();
+ if ( posOld == wxInvalidOffset )
+ {
+ // can't test unseekable stream
+ return FALSE;
+ }
+
+ bool ok = DoCanRead(stream);
+
+ // restore the old position to be able to test other formats and so on
+ if ( stream.SeekI(posOld) == wxInvalidOffset )
+ {
+ wxLogDebug(_T("Failed to rewind the stream in wxImageHandler!"));
+ // reading would fail anyhow as we're not at the right position
return FALSE;
}
-// return FALSE;
+
+ return ok;
}
#endif // wxUSE_STREAMS
//-----------------------------------------------------------------------------
-// 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
*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
//-----------------------------------------------------------------------------
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