X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a3ef5bf5045991260005634272633717c0a26174..1f2f0331455e0a91fdbc57afefe8f8c7c0db9392:/src/common/image.cpp diff --git a/src/common/image.cpp b/src/common/image.cpp index a4f18c0975..e749f5d39d 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -100,10 +100,12 @@ wxImage::wxImage( const wxString& name, long type ) LoadFile( name, type ); } +#if wxUSE_STREAMS wxImage::wxImage( wxInputStream& stream, long type ) { LoadFile( stream, type ); } +#endif // wxUSE_STREAMS wxImage::wxImage( const wxImage& image ) { @@ -310,6 +312,7 @@ int wxImage::GetHeight() const bool wxImage::LoadFile( const wxString& filename, long type ) { +#if wxUSE_STREAMS if (wxFileExists(filename)) { wxFileInputStream stream(filename); @@ -317,12 +320,28 @@ bool wxImage::LoadFile( const wxString& filename, long type ) } else { - wxLogWarning( "Image file does not exist." ); + wxLogError( "Can't load image from file '%s': file does not exist.", filename.c_str() ); return FALSE; } +#else // !wxUSE_STREAMS + return FALSE; +#endif // wxUSE_STREAMS +} + +bool wxImage::SaveFile( const wxString& filename, int type ) +{ +#if wxUSE_STREAMS + wxFileOutputStream stream(filename); + + if ( stream.LastError() == wxStream_NOERROR ) + return SaveFile(stream, type); + else +#endif // wxUSE_STREAMS + return FALSE; } +#if wxUSE_STREAMS bool wxImage::LoadFile( wxInputStream& stream, long type ) { UnRef(); @@ -341,16 +360,6 @@ bool wxImage::LoadFile( wxInputStream& stream, long type ) return handler->LoadFile( this, stream ); } -bool wxImage::SaveFile( const wxString& filename, int type ) -{ - wxFileOutputStream stream(filename); - - if ( stream.LastError() == wxStream_NOERROR ) - return SaveFile(stream, type); - else - return FALSE; -} - bool wxImage::SaveFile( wxOutputStream& stream, int type ) { wxCHECK_MSG( Ok(), FALSE, "invalid image" ); @@ -366,6 +375,7 @@ bool wxImage::SaveFile( wxOutputStream& stream, int type ) return handler->SaveFile( this, stream ); } +#endif // wxUSE_STREAMS void wxImage::AddHandler( wxImageHandler *handler ) { @@ -401,7 +411,7 @@ wxImageHandler *wxImage::FindHandler( const wxString& name ) while (node) { wxImageHandler *handler = (wxImageHandler*)node->Data(); - if (handler->GetName() == name) return handler; + if (handler->GetName().Cmp(name) == 0) return handler; node = node->Next(); } @@ -414,7 +424,7 @@ wxImageHandler *wxImage::FindHandler( const wxString& extension, long bitmapType while (node) { wxImageHandler *handler = (wxImageHandler*)node->Data(); - if ( handler->GetExtension() == extension && + if ( (handler->GetExtension().Cmp(extension) == 0) && (bitmapType == -1 || handler->GetType() == bitmapType) ) return handler; node = node->Next(); @@ -463,6 +473,7 @@ void wxImage::CleanUpHandlers() IMPLEMENT_DYNAMIC_CLASS(wxImageHandler,wxObject) #endif +#if wxUSE_STREAMS bool wxImageHandler::LoadFile( wxImage *WXUNUSED(image), wxInputStream& WXUNUSED(stream) ) { return FALSE; @@ -472,6 +483,7 @@ bool wxImageHandler::SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSE { return FALSE; } +#endif // wxUSE_STREAMS //----------------------------------------------------------------------------- // wxPNGHandler @@ -484,6 +496,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxPNGHandler,wxImageHandler) #endif +#if wxUSE_STREAMS static void _PNG_stream_reader( png_structp png_ptr, png_bytep data, png_size_t length ) { ((wxInputStream*) png_get_io_ptr( png_ptr )) -> Read(data, length); @@ -736,6 +749,7 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream ) } return TRUE; } +#endif // wxUSE_STREAMS #endif @@ -749,6 +763,7 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream ) IMPLEMENT_DYNAMIC_CLASS(wxBMPHandler,wxImageHandler) #endif +#if wxUSE_STREAMS bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream ) { unsigned char *data, *ptr; @@ -1098,6 +1113,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream ) return TRUE; } +#endif // wxUSE_STREAMS #ifdef __WXMSW__