-#if wxUSE_STREAMS
-
-/*
-
-FOLLOWING CODE IS BY G.R.G. :
-(except wxInputStream stuff)
-
-*/
-
-/************************************************************************
- READGIF.H - Reads a GIF file
- ------------------------------------------------------------------------
- Guillermo Rodriguez Garcia
- <guille@iies.es>
-
- Version: 2.1
-*************************************************************************/
-
-
-typedef struct
-{
- int w; /* width */
- int h; /* height */
- int transparent; /* transparent color (-1 = none) */
- unsigned char *p; /* bitmap */
- unsigned char *pal; /* palette */
-} IMAGEN;
-
-
-
-/************************************************************************
- READGIF.C - Reads a GIF file
- ------------------------------------------------------------------------
- Guillermo Rodriguez Garcia
- <guille@iies.es>
-
- Version: 2.1
-*************************************************************************/
-
-
-#include <stdlib.h>
-#include <string.h>
-
-
-/* error codes */
-#define E_OK 0 /* everything was OK */
-#define E_ARCHIVO -1 /* error opening file */
-#define E_FORMATO -2 /* error in gif header */
-#define E_MEMORIA -3 /* error allocating memory */
-
-
-/* This class binding is by VS, so all bugs in it are mine ;-) */
-
-class gifDecoder
-{
- private:
- /* globals */
- int restbits; /* remaining valid bits */
- unsigned int restbyte; /* remaining bytes in this block */
- unsigned int lastbyte; /* last byte read */
-
- wxInputStream *f; /* input file */
-
- public:
- gifDecoder(wxInputStream *s) { f = s; }
- int getcode(int bits);
- int dgif(IMAGEN *img, int interl, int bits);
- int readgif(IMAGEN *img);
-};
-
-
-
-/* getcode:
- * Reads the next code from the file, with size 'bits'
- */
-int gifDecoder::getcode(int bits)
-{
- unsigned int mask; /* bit mask */
- unsigned int code; /* code (result) */
-
-
- /* get remaining bits from last byte read */
- mask = (1 << bits) - 1;
- code = (lastbyte >> (8 - restbits)) & mask;
-
- /* keep reading new bytes while needed */
- while (bits > restbits)
- {
- /* if no bytes left in this block, read the next block */
- if (restbyte == 0)
- restbyte = (unsigned char)f->GetC();
-
- /* read next byte and isolate the bits we need */
- lastbyte = (unsigned char)f->GetC();
- mask = (1 << (bits - restbits)) - 1;
- code = code + ((lastbyte & mask) << restbits);
- restbyte--;
-
- /* adjust total number of bits extracted from the buffer */
- restbits = restbits + 8;
- }
-
- /* find number of bits reamining for next code */
- restbits = (restbits - bits);
-
- return code;
-}
-