#ifndef GIF_LOAD_H
#define GIF_LOAD_H
#include <DataIO.h>
#include "LoadPalette.h"
#define GIF_INTERLACED 0x40
#define GIF_LOCALCOLORMAP 0x80
#define ENTRY_COUNT 4354
typedef struct Memblock {
unsigned char data[ENTRY_COUNT];
int offset;
Memblock* next;
} Memblock;
const int gl_pass_starts_at[] = { 0, 4, 2, 1, 0 };
const int gl_increment_pass_by[] = { 8, 8, 4, 2, 0 };
class GIFLoad {
public:
GIFLoad(BPositionIO* input,
BPositionIO* output);
virtual ~GIFLoad();
bool fatalerror;
private:
bool ReadGIFHeader();
bool ReadGIFLoopBlock();
bool ReadGIFControlBlock();
bool ReadGIFImageHeader();
bool ReadGIFImageData();
bool ReadGIFCommentBlock();
bool ReadGIFUnknownBlock(unsigned char c);
bool InitFrame(int codeSize);
short NextCode();
void ResetTable();
unsigned char* MemblockAllocate(int size);
void MemblockDeleteAll();
inline bool OutputColor(unsigned char* string, int size);
BPositionIO* fInput;
BPositionIO* fOutput;
LoadPalette* fPalette;
bool fInterlaced;
int fPass;
int fRow;
int fWidth;
int fHeight;
unsigned char fOldCode[ENTRY_COUNT];
unsigned int fOldCodeLength;
short fNewCode;
int fBits;
int fMaxCode;
int fCodeSize;
short fClearCode;
short fEndCode;
short fNextCode;
unsigned char* fTable[ENTRY_COUNT];
short fEntrySize[ENTRY_COUNT];
Memblock* fHeadMemblock;
int fBitCount;
unsigned int fBitBuffer;
unsigned char fByteCount;
unsigned char fByteBuffer[255];
uint32* fScanLine;
int fScanlinePosition;
};
#endif