#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"
// For memcpy
#include <string.h>
+// 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
//-----------------------------------------------------------------------------
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);
}
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);
}
return false;
}
-#else // !wxUSE_STREAMS
+#else // !HAS_FILE_STREAMS
return false;
-#endif // wxUSE_STREAMS
+#endif // HAS_FILE_STREAMS
}
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;
}
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;
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
if ( !handler )
{
- wxLogWarning(_("No image handler for type %d defined."), type);
+ wxLogWarning(_("No image handler for type %ld defined."), type);
return false;
}
}
else
{
- wxLogError(_("Image file is not of type %d."), type);
+ wxLogError(_("Image file is not of type %ld."), type);
return 0;
}
}
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
{
if (wxFileExists(name))
{
- wxFileInputStream stream(name);
+ wxImageFileInputStream stream(name);
return CanRead(stream);
}