diff --git a/include/wx/image.h b/include/wx/image.h index 0b7cc551b2..18ac41ad0f 100644 --- a/include/wx/image.h +++ b/include/wx/image.h @@ -290,10 +290,12 @@ public: unsigned char GetGreen( int x, int y ); unsigned char GetBlue( int x, int y ); + static bool CanRead( const wxString& name ); virtual bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_ANY ); virtual bool LoadFile( const wxString& name, const wxString& mimetype ); #if wxUSE_STREAMS + static bool CanRead( wxInputStream& stream ); virtual bool LoadFile( wxInputStream& stream, long type = wxBITMAP_TYPE_ANY ); virtual bool LoadFile( wxInputStream& stream, const wxString& mimetype ); #endif diff --git a/src/common/image.cpp b/src/common/image.cpp index 3679c78d03..05344a678f 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -437,7 +437,31 @@ bool wxImage::SaveFile( const wxString& filename, const wxString& mimetype ) return FALSE; } +bool wxImage::CanRead( const wxString &name ) +{ #if wxUSE_STREAMS + wxFileInputStream stream(name); + return CanRead(stream); +#else + return FALSE; +#endif +} + +#if wxUSE_STREAMS + +bool wxImage::CanRead( wxInputStream &stream ) +{ + wxList &list=GetHandlers(); + + for ( wxList::Node *node = list.GetFirst(); node; node = node->GetNext() ) + { + wxImageHandler *handler=(wxImageHandler*)node->GetData(); + if (handler->CanRead( stream )) + return TRUE; + } + + return FALSE; +} bool wxImage::LoadFile( wxInputStream& stream, long type ) {