10 typedef unsigned char byte;
29 static long b3[3], CurByte;
42 nbyte = CurByte - OldByte;
47 if (lblk == 0)
return -1;
54 return (((b3[0]+0x100*b3[1]+0x10000*b3[2])>>shift) & (
CurMaxCode-1));
80 int GIFinfo(
byte *GIFarr,
int *Width,
int *Height,
int *Ncols)
88 if (strncmp((
char *)GIFarr,
"GIF87a",6) && strncmp((
char *)GIFarr,
"GIF89a",6))
90 fprintf(stderr,
"\nGIFinfo: not a GIF\n");
100 *Ncols = 1 << ((b & 7) + 1);
101 if ((b & 0x80) == 0) {
102 fprintf(stderr,
"\nGIFinfo: warning! no color map\n");
109 fprintf(stderr,
"\nGIFdecode: bad screen descriptor\n");
113 ptr1 += (*Ncols) * 3;
117 fprintf(stderr,
"\nGIFinfo: no image separator\n");
124 *Width = b + 0x100*(*
ptr1++);
126 *Height = b + 0x100*(*
ptr1++);
174 if (strncmp((
char *)GIFarr,
"GIF87a",6) && strncmp((
char *)GIFarr,
"GIF89a",6))
176 fprintf(stderr,
"\nGIFinfo: not a GIF\n");
186 BitsPixel = (b & 7) + 1;
188 PixMask = (*Ncols) - 1;
189 if ((b & 0x80) == 0) {
190 fprintf(stderr,
"\nGIFdecode: warning! no color map\n");
197 fprintf(stderr,
"\nGIFdecode: bad screen descriptor\n");
201 for (i=0; i<(*Ncols); i++) {
209 fprintf(stderr,
"\nGIFdecode: no image separator\n");
216 *Width = b + 0x100*(*
ptr1++);
218 *Height = b + 0x100*(*
ptr1++);
221 if ((b & 0xc0) != 0) {
223 "\nGIFdecode: unexpected item (local colors or interlace)\n");
227 IniCodeSize = *
ptr1++;
230 ClearCode = (1 << (IniCodeSize - 1));
231 EOFCode = ClearCode + 1;
232 FreeCode = ClearCode + 2;
236 Npix =(long) (*Width) * (*Height);
243 fprintf(stderr,
"\nGIFdecode: corrupted GIF (zero block length)\n");
247 if (CurCode == EOFCode) {
248 fprintf(stderr,
"\nGIFdecode: corrupted GIF (unexpected EOF)\n");
252 if (CurCode == ClearCode) {
256 FreeCode = ClearCode + 2;
265 if (CurCode >= FreeCode) {
269 while (CurCode > PixMask) {
270 if (OutCount >=
TSIZE) {
271 fprintf(stderr,
"\nGIFdecode: corrupted GIF (big output count)\n");
275 CurCode =
Prefix[CurCode];
280 for (i=OutCount-1; i>=0; i--) {
static void OutPixel(byte pix)
static byte OutCode[TSIZE]
int GIFdecode(byte *GIFarr, byte *PIXarr, int *Width, int *Height, int *Ncols, byte *R, byte *G, byte *B)
int GIFinfo(byte *GIFarr, int *Width, int *Height, int *Ncols)
static byte Suffix[TSIZE]
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b