Added image index to loadfile.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4774
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
wxImageHandler() { m_name = ""; m_extension = ""; m_type = 0; }
#if wxUSE_STREAMS
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 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 );
bool CanRead( wxInputStream& stream ) { return DoCanRead(stream); }
bool CanRead( const wxString& name );
- 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
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
#endif
- 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
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
#endif
- 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 bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
+ virtual int GetImageCount( wxInputStream& stream );
- 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
};
virtual bool DoCanRead( wxInputStream& stream );
#endif
};
- 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
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
#endif
- 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
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
#endif
- 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
virtual bool SaveFile( wxImage *image, wxOutputStream& stream, bool verbose=TRUE );
virtual bool DoCanRead( wxInputStream& stream );
#endif // wxUSE_STREAMS
unsigned char buf[3];
m_f->Read(buf, 3);
unsigned char buf[3];
m_f->Read(buf, 3);
- stream.SeekI(-3, wxFromCurrent);
+ m_f->SeekI(-3, wxFromCurrent);
return (memcmp(buf, "GIF", 3) == 0);
}
return (memcmp(buf, "GIF", 3) == 0);
}
#define poffset (line * width * 3 + column * 3)
#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;
{
int rshift = 0, gshift = 0, bshift = 0;
wxUint8 aByte;
-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) )
+int wxImageHandler::GetImageCount( wxInputStream& WXUNUSED(stream) )
+{
+ return 1;
+}
+
bool wxImageHandler::CanRead( const wxString& name )
{
bool wxImageHandler::CanRead( const wxString& name )
{
if (wxFileExists(name))
{
wxFileInputStream stream(name);
if (wxFileExists(name))
{
wxFileInputStream stream(name);
#endif // wxUSE_STREAMS
//-----------------------------------------------------------------------------
#endif // 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;
{
wxGIFDecoder *decod;
int error;
-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;
{
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;
IMPLEMENT_DYNAMIC_CLASS(wxPCXHandler,wxImageHandler)
#endif
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) )
-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...)
{
// VZ: as this function uses setjmp() the only fool proof error handling
// method is to use goto (setjmp is not really C++ dtors friendly...)
-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;
{
wxUint32 width, height;
wxUint16 maxval;
-bool wxTIFFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose )
+bool wxTIFFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose, int index )
+
+ if (!TIFFSetDirectory( tif, (tdir_t)index ))
+ {
+ if (verbose)
+ wxLogError( _("Invalid TIFF image index.") );
+
+ TIFFClose( tif );
+
+ return FALSE;
+ }
uint32 w, h;
size_t npixels;
uint32 w, h;
size_t npixels;
+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) )