// Name: gifdecod.h
// Purpose: wxGIFDecoder, GIF reader for wxImage and wxAnimation
// Author: Guillermo Rodriguez Garcia <guille@iies.es>
-// Version: 3.0
-// Last rev: 1999/08/10
+// Version: 3.02
+// Last rev: 1999/08/18
// Copyright: (c) Guillermo Rodriguez Garcia
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
unsigned int left; /* x coord (in logical screen) */
unsigned int top; /* y coord (in logical screen) */
int transparent; /* transparent color (-1 = none) */
- int disposal; /* disposal method */
+ int disposal; /* disposal method (-1 = unspecified) */
long delay; /* delay in ms (-1 = unused) */
unsigned char *p; /* bitmap */
unsigned char *pal; /* palette */
// constructor, destructor, etc.
wxGIFDecoder(wxInputStream *s, bool anim = FALSE);
~wxGIFDecoder();
+ bool CanRead();
int ReadGIF();
void Destroy();
// Name: gifdecod.cpp
// Purpose: wxGIFDecoder, GIF reader for wxImage and wxAnimation
// Author: Guillermo Rodriguez Garcia <guille@iies.es>
-// Version: 3.01
-// Last rev: 1999/08/14
+// Version: 3.02
+// Last rev: 1999/08/18
// Copyright: (c) Guillermo Rodriguez Garcia
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
unsigned long i;
int transparent;
+ /* just in case... */
+ image->Destroy();
+
/* create the image */
image->Create(GetWidth(), GetHeight());
}
+// CanRead:
+// Returns TRUE if the file looks like a valid GIF, FALSE otherwise.
+//
+bool wxGIFDecoder::CanRead()
+{
+ unsigned char buf[3];
+
+ m_f->SeekI(0, wxFromStart);
+ m_f->Read(buf, 3);
+
+ return (memcmp(buf, "GIF", 3) == 0);
+}
+
+
// ReadGIF:
// Reads and decodes one or more GIF images, depending on whether
// animated GIF support is enabled. Can read GIFs with any bit
unsigned char buf[16];
IMAGEN **ppimg, *pimg, *pprev;
+ /* check GIF signature */
+ if (!CanRead())
+ return E_FORMATO;
- /* check GIF signature and animated GIF support (ver. >= 89a) */
+ /* check for and animated GIF support (ver. >= 89a) */
+ m_f->SeekI(0, wxFromStart);
m_f->Read(buf, 6);
- if (memcmp(buf, "GIF", 3) != 0)
- return E_FORMATO;
-
if (memcmp(buf + 3, "89a", 3) < 0)
m_anim = FALSE;