X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bba6f3bd3c8fc28acab21c839523156017b26996..7482b22003c03f7aa3335aec271b5fcb48e2693d:/src/common/image.cpp?ds=sidebyside diff --git a/src/common/image.cpp b/src/common/image.cpp index a7d34cce08..a5b3a74df6 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -23,13 +23,19 @@ #include "wx/debug.h" #include "wx/log.h" #include "wx/app.h" -#ifdef wxUSE_LIBPNG +#if wxUSE_LIBPNG #include "../png/png.h" #endif #include "wx/filefn.h" #include "wx/wfstream.h" #include "wx/intl.h" +#ifdef __SALFORDC__ +#ifdef FAR +#undef FAR +#endif +#endif + #ifdef __WXMSW__ #include #endif @@ -94,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 ) { @@ -304,6 +312,7 @@ int wxImage::GetHeight() const bool wxImage::LoadFile( const wxString& filename, long type ) { +#if wxUSE_STREAMS if (wxFileExists(filename)) { wxFileInputStream stream(filename); @@ -311,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(); @@ -335,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" ); @@ -360,6 +375,7 @@ bool wxImage::SaveFile( wxOutputStream& stream, int type ) return handler->SaveFile( this, stream ); } +#endif // wxUSE_STREAMS void wxImage::AddHandler( wxImageHandler *handler ) { @@ -395,7 +411,8 @@ 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(); } return (wxImageHandler *)NULL; @@ -407,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(); @@ -430,7 +447,7 @@ wxImageHandler *wxImage::FindHandler( long bitmapType ) void wxImage::InitStandardHandlers() { AddHandler( new wxBMPHandler ); -#ifdef wxUSE_LIBPNG +#if wxUSE_LIBPNG AddHandler( new wxPNGHandler ); #endif } @@ -456,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; @@ -465,18 +483,20 @@ bool wxImageHandler::SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSE { return FALSE; } +#endif // wxUSE_STREAMS //----------------------------------------------------------------------------- // wxPNGHandler //----------------------------------------------------------------------------- -#ifdef wxUSE_LIBPNG +#if wxUSE_LIBPNG #if !USE_SHARED_LIBRARIES 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); @@ -729,6 +749,7 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream ) } return TRUE; } +#endif // wxUSE_STREAMS #endif @@ -742,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; @@ -1091,6 +1113,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream ) return TRUE; } +#endif // wxUSE_STREAMS #ifdef __WXMSW__ @@ -1700,8 +1723,6 @@ wxImage::wxImage( const wxBitmap &bitmap ) #endif -// TODO - #ifdef __WXMOTIF__ #include