Compile fix for GIF decoder,

Added image index to loadfile.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4774 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 1999-11-30 17:24:14 +00:00
parent a05da1b682
commit 700ec4546c
10 changed files with 51 additions and 23 deletions

View File

@ -62,8 +62,10 @@ public:
wxImageHandler() { m_name = ""; m_extension = ""; m_type = 0; }
#if wxUSE_STREAMS
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=0 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual int GetImageCount( wxInputStream& stream );
bool CanRead( wxInputStream& stream ) { return DoCanRead(stream); }
bool CanRead( const wxString& name );
@ -108,7 +110,7 @@ public:
};
#if wxUSE_STREAMS
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=0 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
#endif
@ -135,7 +137,7 @@ public:
};
#if wxUSE_STREAMS
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=0 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
#endif
@ -162,9 +164,10 @@ public:
};
#if wxUSE_STREAMS
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=0 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
virtual int GetImageCount( wxInputStream& stream );
#endif
};
#endif
@ -188,7 +191,7 @@ public:
};
#if wxUSE_STREAMS
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=0 );
virtual bool DoCanRead( wxInputStream& stream );
#endif
};
@ -214,7 +217,7 @@ public:
};
#if wxUSE_STREAMS
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=0 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
#endif
@ -241,7 +244,7 @@ public:
};
#if wxUSE_STREAMS
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=0 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
#endif
@ -268,7 +271,7 @@ public:
};
#if wxUSE_STREAMS
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE );
virtual bool LoadFile( wxImage *image, wxInputStream& stream, bool verbose=TRUE, int index=0 );
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
#endif // wxUSE_STREAMS

View File

@ -446,7 +446,7 @@ bool wxGIFDecoder::CanRead()
unsigned char buf[3];
m_f->Read(buf, 3);
stream.SeekI(-3, wxFromCurrent);
m_f->SeekI(-3, wxFromCurrent);
return (memcmp(buf, "GIF", 3) == 0);
}

View File

@ -64,7 +64,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxBMPHandler,wxImageHandler)
#define poffset (line * width * 3 + column * 3)
bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream, bool WXUNUSED(verbose) )
bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream, bool WXUNUSED(verbose), int WXUNUSED(index) )
{
int rshift = 0, gshift = 0, bshift = 0;
wxUint8 aByte;

View File

@ -656,7 +656,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxImageHandler,wxObject)
#endif
#if wxUSE_STREAMS
bool wxImageHandler::LoadFile( wxImage *WXUNUSED(image), wxInputStream& WXUNUSED(stream), bool WXUNUSED(verbose) )
bool wxImageHandler::LoadFile( wxImage *WXUNUSED(image), wxInputStream& WXUNUSED(stream), bool WXUNUSED(verbose), int WXUNUSED(index) )
{
return FALSE;
}
@ -666,9 +666,13 @@ bool wxImageHandler::SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSE
return FALSE;
}
int wxImageHandler::GetImageCount( wxInputStream& WXUNUSED(stream) )
{
return 1;
}
bool wxImageHandler::CanRead( const wxString& name )
{
#if wxUSE_STREAMS
if (wxFileExists(name))
{
wxFileInputStream stream(name);
@ -680,13 +684,9 @@ bool wxImageHandler::CanRead( const wxString& name )
return FALSE;
}
#else // !wxUSE_STREAMS
return FALSE;
#endif // wxUSE_STREAMS
}
#endif // wxUSE_STREAMS
//-----------------------------------------------------------------------------

View File

@ -40,7 +40,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxGIFHandler,wxImageHandler)
#if wxUSE_STREAMS
bool wxGIFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose )
bool wxGIFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose, int WXUNUSED(index) )
{
wxGIFDecoder *decod;
int error;

View File

@ -150,7 +150,7 @@ my_error_exit (j_common_ptr cinfo)
bool wxJPEGHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose )
bool wxJPEGHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose, int WXUNUSED(index) )
{
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;

View File

@ -222,7 +222,7 @@ int ReadPCX(wxImage *image, wxInputStream& stream)
IMPLEMENT_DYNAMIC_CLASS(wxPCXHandler,wxImageHandler)
#endif
bool wxPCXHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose )
bool wxPCXHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose, int WXUNUSED(index) )
{
int error;

View File

@ -96,7 +96,7 @@ LINKAGEMODE png_silent_warning(png_structp WXUNUSED(png_ptr), png_const_charp WX
{
}
bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose)
bool wxPNGHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose, int WXUNUSED(index) )
{
// VZ: as this function uses setjmp() the only fool proof error handling
// method is to use goto (setjmp is not really C++ dtors friendly...)

View File

@ -50,7 +50,7 @@ void Skip_Comment(wxInputStream &stream)
}
}
bool wxPNMHandler::LoadFile( wxImage *image, wxInputStream& stream, bool WXUNUSED(verbose) )
bool wxPNMHandler::LoadFile( wxImage *image, wxInputStream& stream, bool WXUNUSED(verbose), int WXUNUSED(index) )
{
wxUint32 width, height;
wxUint16 maxval;

View File

@ -119,7 +119,7 @@ TIFFwxOpen(wxInputStream &stream, const char* name, const char* mode)
}
bool wxTIFFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose )
bool wxTIFFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose, int index )
{
image->Destroy();
@ -132,6 +132,16 @@ bool wxTIFFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbos
return FALSE;
}
if (!TIFFSetDirectory( tif, (tdir_t)index ))
{
if (verbose)
wxLogError( _("Invalid TIFF image index.") );
TIFFClose( tif );
return FALSE;
}
uint32 w, h;
size_t npixels;
@ -216,9 +226,24 @@ bool wxTIFFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbos
return TRUE;
}
int wxTIFFHandler::GetImageCount( wxInputStream& stream )
{
TIFF *tif = TIFFwxOpen( stream, "image", "r" );
if (!tif)
return 0;
int dircount = 0; // according to the libtiff docs, dircount should be set to 1 here???
do {
dircount++;
} while (TIFFReadDirectory(tif));
TIFFClose( tif );
return dircount;
}
bool wxTIFFHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbose )
bool wxTIFFHandler::SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSED(stream), bool WXUNUSED(verbose) )
{
return FALSE;
}