]> git.saurik.com Git - wxWidgets.git/commitdiff
Compile fix for GIF decoder,
authorRobert Roebling <robert@roebling.de>
Tue, 30 Nov 1999 17:24:14 +0000 (17:24 +0000)
committerRobert Roebling <robert@roebling.de>
Tue, 30 Nov 1999 17:24:14 +0000 (17:24 +0000)
  Added image index to loadfile.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4774 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/image.h
src/common/gifdecod.cpp
src/common/imagbmp.cpp
src/common/image.cpp
src/common/imaggif.cpp
src/common/imagjpeg.cpp
src/common/imagpcx.cpp
src/common/imagpng.cpp
src/common/imagpnm.cpp
src/common/imagtiff.cpp

index cded61d096310a264e8a680365749f782df717f0..cbff996d7595a5d96c78bf5defdc04e29aef0462 100644 (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
index 3345366d7b250423acf27a58f1adb0c8404f9505..0a8a6f525bf6e64d64bb279da17cdb7a8568c076 100644 (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);
 }
index 52dade70e42264231a62c40ebddc439b5708b889..baec6a1d48eb3b25308b6c725ad48b79d045da67 100644 (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;
index 96d3c58d8a6059040ebdb95150dcbab598ae236b..c714ea6b5b150b1d18b1b17de199df4bebb04866 100644 (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
 
 //-----------------------------------------------------------------------------
index b15fff887ec0a9dea92fc30f59dadbaa9a9b2c93..41211855a5e497847c5030659541d321f72708b2 100644 (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;
index a4fc184bedbbf8fe39878d607b307b9f00aa5abf..6676597e79764dcce69bb5cb8f6cc694fd94f45a 100644 (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;
index 4f5ecbb32840eb3ce3cde0942301c662755f8aa8..0ba41da2f227bf58c4a5169b740c856f2a0b1b7c 100644 (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;
 
index 132655980c64e0e38e6f08eedc30e726491fa890..e8d9f42c7e304768d27b5905fae5fb8d6a8cb14c 100644 (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...)
index c2ed7bf13c9629789129a8159bc3576251980247..ec9edd90b122b640886c5f546e24234ccdfef444 100644 (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;
index 1ca0a0d0f788e5d95d650ab92c87a5f78c6c64ca..b182648068f3c2af8045c27090ca03743581d1c3 100644 (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;
 }