X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a0f81e9f15fedf29e5f6cf023b4ba3f2c2d2eb46..e87f080a8809a36b9fd05f5f9b3d8436dac017c3:/src/common/image.cpp diff --git a/src/common/image.cpp b/src/common/image.cpp index 9defc7b068..0f42524c20 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -25,12 +25,12 @@ #include "wx/utils.h" #include "wx/bitmap.h" #include "wx/math.h" + #include "wx/module.h" #endif #include "wx/filefn.h" #include "wx/wfstream.h" #include "wx/intl.h" -#include "wx/module.h" #if wxUSE_XPM #include "wx/xpmdecod.h" @@ -39,6 +39,19 @@ // For memcpy #include +// make the code compile with either wxFile*Stream or wxFFile*Stream: +#define HAS_FILE_STREAMS (wxUSE_STREAMS && (wxUSE_FILE || wxUSE_FFILE)) + +#if HAS_FILE_STREAMS + #if wxUSE_FILE + typedef wxFileInputStream wxImageFileInputStream; + typedef wxFileOutputStream wxImageFileOutputStream; + #elif wxUSE_FFILE + typedef wxFFileInputStream wxImageFileInputStream; + typedef wxFFileOutputStream wxImageFileOutputStream; + #endif // wxUSE_FILE/wxUSE_FFILE +#endif // HAS_FILE_STREAMS + //----------------------------------------------------------------------------- // wxImage //----------------------------------------------------------------------------- @@ -1500,10 +1513,10 @@ bool wxImage::LoadFile( const wxString& WXUNUSED_UNLESS_STREAMS(filename), long WXUNUSED_UNLESS_STREAMS(type), int WXUNUSED_UNLESS_STREAMS(index) ) { -#if wxUSE_STREAMS +#if HAS_FILE_STREAMS if (wxFileExists(filename)) { - wxFileInputStream stream(filename); + wxImageFileInputStream stream(filename); wxBufferedInputStream bstream( stream ); return LoadFile(bstream, type, index); } @@ -1513,19 +1526,19 @@ bool wxImage::LoadFile( const wxString& WXUNUSED_UNLESS_STREAMS(filename), return false; } -#else // !wxUSE_STREAMS +#else // !HAS_FILE_STREAMS return false; -#endif // wxUSE_STREAMS +#endif // HAS_FILE_STREAMS } bool wxImage::LoadFile( const wxString& WXUNUSED_UNLESS_STREAMS(filename), const wxString& WXUNUSED_UNLESS_STREAMS(mimetype), int WXUNUSED_UNLESS_STREAMS(index) ) { -#if wxUSE_STREAMS +#if HAS_FILE_STREAMS if (wxFileExists(filename)) { - wxFileInputStream stream(filename); + wxImageFileInputStream stream(filename); wxBufferedInputStream bstream( stream ); return LoadFile(bstream, mimetype, index); } @@ -1535,9 +1548,9 @@ bool wxImage::LoadFile( const wxString& WXUNUSED_UNLESS_STREAMS(filename), return false; } -#else // !wxUSE_STREAMS +#else // !HAS_FILE_STREAMS return false; -#endif // wxUSE_STREAMS +#endif // HAS_FILE_STREAMS } @@ -1561,19 +1574,19 @@ bool wxImage::SaveFile( const wxString& filename ) const bool wxImage::SaveFile( const wxString& WXUNUSED_UNLESS_STREAMS(filename), int WXUNUSED_UNLESS_STREAMS(type) ) const { -#if wxUSE_STREAMS +#if HAS_FILE_STREAMS wxCHECK_MSG( Ok(), false, wxT("invalid image") ); ((wxImage*)this)->SetOption(wxIMAGE_OPTION_FILENAME, filename); - wxFileOutputStream stream(filename); + wxImageFileOutputStream stream(filename); if ( stream.IsOk() ) { wxBufferedOutputStream bstream( stream ); return SaveFile(bstream, type); } -#endif // wxUSE_STREAMS +#endif // HAS_FILE_STREAMS return false; } @@ -1581,27 +1594,27 @@ bool wxImage::SaveFile( const wxString& WXUNUSED_UNLESS_STREAMS(filename), bool wxImage::SaveFile( const wxString& WXUNUSED_UNLESS_STREAMS(filename), const wxString& WXUNUSED_UNLESS_STREAMS(mimetype) ) const { -#if wxUSE_STREAMS +#if HAS_FILE_STREAMS wxCHECK_MSG( Ok(), false, wxT("invalid image") ); ((wxImage*)this)->SetOption(wxIMAGE_OPTION_FILENAME, filename); - wxFileOutputStream stream(filename); + wxImageFileOutputStream stream(filename); if ( stream.IsOk() ) { wxBufferedOutputStream bstream( stream ); return SaveFile(bstream, mimetype); } -#endif // wxUSE_STREAMS +#endif // HAS_FILE_STREAMS return false; } bool wxImage::CanRead( const wxString& WXUNUSED_UNLESS_STREAMS(name) ) { -#if wxUSE_STREAMS - wxFileInputStream stream(name); +#if HAS_FILE_STREAMS + wxImageFileInputStream stream(name); return CanRead(stream); #else return false; @@ -1611,8 +1624,8 @@ bool wxImage::CanRead( const wxString& WXUNUSED_UNLESS_STREAMS(name) ) int wxImage::GetImageCount( const wxString& WXUNUSED_UNLESS_STREAMS(name), long WXUNUSED_UNLESS_STREAMS(type) ) { -#if wxUSE_STREAMS - wxFileInputStream stream(name); +#if HAS_FILE_STREAMS + wxImageFileInputStream stream(name); if (stream.Ok()) return GetImageCount(stream, type); #endif @@ -1660,7 +1673,7 @@ int wxImage::GetImageCount( wxInputStream &stream, long type ) if ( !handler ) { - wxLogWarning(_("No image handler for type %d defined."), type); + wxLogWarning(_("No image handler for type %ld defined."), type); return false; } @@ -1670,7 +1683,7 @@ int wxImage::GetImageCount( wxInputStream &stream, long type ) } else { - wxLogError(_("Image file is not of type %d."), type); + wxLogError(_("Image file is not of type %ld."), type); return 0; } } @@ -1703,14 +1716,14 @@ bool wxImage::LoadFile( wxInputStream& stream, long type, int index ) if (handler == 0) { - wxLogWarning( _("No image handler for type %d defined."), type ); + wxLogWarning( _("No image handler for type %ld defined."), type ); return false; } if (stream.IsSeekable() && !handler->CanRead(stream)) { - wxLogError(_("Image file is not of type %d."), type); + wxLogError(_("Image file is not of type %ld."), type); return false; } else @@ -2114,7 +2127,7 @@ bool wxImageHandler::CanRead( const wxString& name ) { if (wxFileExists(name)) { - wxFileInputStream stream(name); + wxImageFileInputStream stream(name); return CanRead(stream); }