#include "wx/log.h"
#include "wx/app.h"
#include "wx/filefn.h"
+#include "wx/filesys.h"
#include "wx/wfstream.h"
#include "wx/intl.h"
#include "wx/module.h"
for (long j = 0; j < height; j++)
{
- long y_offset = (j * old_height / height) * old_width;
+ long y_offset = (j * (old_height-1) / (height-1)) * old_width;
for (long i = 0; i < width; i++)
{
memcpy( target_data,
- source_data + 3*(y_offset + ((i * old_width )/ width)),
+ source_data + 3*(y_offset + ((i * (old_width-1) )/ (width-1))),
3 );
target_data += 3;
}
bool wxImage::LoadFile( const wxString& filename, long type )
{
#if wxUSE_STREAMS
- if (wxFileExists(filename))
- {
- wxFileInputStream stream(filename);
- wxBufferedInputStream bstream( stream );
- return LoadFile(bstream, type);
- }
- else
- {
- wxLogError( _("Can't load image from file '%s': file does not exist."), filename.c_str() );
-
+ // We want to use wxFileSystem for virtual FS compatibility
+ wxFileSystem fsys;
+ wxFSFile *file = fsys.OpenFile(filename);
+ if (!file) {
+ wxLogError(_("Can't open file '%s'"), filename);
return FALSE;
- }
+ }
+ wxInputStream *stream = file->GetStream();
+ if (!stream) {
+ wxLogError(_("Can't open stream for file '%s'"), filename);
+ return FALSE;
+ }
+ return LoadFile(*stream, type);
#else // !wxUSE_STREAMS
return FALSE;
#endif // wxUSE_STREAMS
bool wxImage::LoadFile( const wxString& filename, const wxString& mimetype )
{
#if wxUSE_STREAMS
- if (wxFileExists(filename))
- {
- wxFileInputStream stream(filename);
- wxBufferedInputStream bstream( stream );
- return LoadFile(bstream, mimetype);
- }
- else
- {
- wxLogError( _("Can't load image from file '%s': file does not exist."), filename.c_str() );
-
+ // We want to use wxFileSystem for virtual FS compatibility
+ wxFileSystem fsys;
+ wxFSFile *file = fsys.OpenFile(filename);
+ if (!file) {
+ wxLogError(_("Can't open file '%s'"), filename);
return FALSE;
- }
+ }
+ wxInputStream *stream = file->GetStream();
+ if (!stream) {
+ wxLogError(_("Can't open stream for file '%s'"), filename);
+ return FALSE;
+ }
+ return LoadFile(*stream, mimetype);
#else // !wxUSE_STREAMS
return FALSE;
#endif // wxUSE_STREAMS
wxHashTable h;
wxObject dummy;
unsigned char r, g, b;
- unsigned char *p;
+ unsigned char *p;
unsigned long size, nentries, key;
p = GetData();
unsigned long wxImage::ComputeHistogram( wxHashTable &h )
{
unsigned char r, g, b;
- unsigned char *p;
+ unsigned char *p;
unsigned long size, nentries, key;
wxHNode *hnode;