#pragma hdrstop
#endif
+#include "wx/defs.h"
+
+#if wxUSE_IMAGE
+
#include "wx/image.h"
#include "wx/bitmap.h"
#include "wx/debug.h"
#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;
}
}
return;
}
-
+
if (!HasMask() && image.HasMask())
{
unsigned char r = image.GetMaskRed();
unsigned char g = image.GetMaskGreen();
unsigned char b = image.GetMaskBlue();
-
+
width *= 3;
unsigned char* source_data = image.GetData() + xx*3 + yy*3*image.GetWidth();
int source_step = image.GetWidth()*3;
unsigned char* target_data = GetData() + (x+xx)*3 + (y+yy)*3*M_IMGDATA->m_width;
int target_step = M_IMGDATA->m_width*3;
-
+
for (int j = 0; j < height; j++)
{
for (int i = 0; i < width; i+=3)
{
- if ((source_data[i] != r) &&
- (source_data[i+1] != g) &&
+ if ((source_data[i] != r) &&
+ (source_data[i+1] != g) &&
(source_data[i+2] != b))
{
memcpy( target_data+i, source_data+i, 3 );
}
- }
+ }
source_data += source_step;
target_data += target_step;
}
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
void wxImage::InitStandardHandlers()
{
- AddHandler( new wxBMPHandler );
+ AddHandler(new wxBMPHandler);
+#if !defined(__WXGTK__) && !defined(__WXMOTIF__)
+ AddHandler(new wxXPMHandler);
+#endif
}
void wxImage::CleanUpHandlers()
{
wxHashTable h;
wxObject dummy;
- unsigned char r, g, b, *p;
+ unsigned char r, g, b;
+ unsigned char *p;
unsigned long size, nentries, key;
p = GetData();
//
unsigned long wxImage::ComputeHistogram( wxHashTable &h )
{
- unsigned char r, g, b, *p;
+ unsigned char r, g, b;
+ unsigned char *p;
unsigned long size, nentries, key;
wxHNode *hnode;
return rotated;
}
+#endif // wxUSE_IMAGE