X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a0f81e9f15fedf29e5f6cf023b4ba3f2c2d2eb46..a8c5e1a9d1f56190e2d87aadc40a75589585af1f:/src/common/image.cpp diff --git a/src/common/image.cpp b/src/common/image.cpp index 9defc7b068..545afb1301 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -20,17 +20,16 @@ #ifndef WX_PRECOMP #include "wx/log.h" - #include "wx/app.h" #include "wx/hash.h" #include "wx/utils.h" - #include "wx/bitmap.h" #include "wx/math.h" + #include "wx/module.h" + #include "wx/palette.h" + #include "wx/intl.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 +38,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 +1512,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 +1525,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 +1547,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 +1573,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 +1593,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 +1623,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 +1672,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 +1682,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 +1715,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 +2126,7 @@ bool wxImageHandler::CanRead( const wxString& name ) { if (wxFileExists(name)) { - wxFileInputStream stream(name); + wxImageFileInputStream stream(name); return CanRead(stream); }