From 87202f787cc318c19a4a516ca278be094b71374b Mon Sep 17 00:00:00 2001 From: Sylvain Bougnoux Date: Mon, 18 Oct 1999 14:18:15 +0000 Subject: [PATCH] Add wxImage::CanRead, wasn't in 1.59 ? git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4047 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/image.h | 2 ++ src/common/image.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) 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,8 +437,32 @@ 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 ) { UnRef(); -- 2.45.2