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:
parent
a05da1b682
commit
700ec4546c
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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...)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user