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));
80int 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++);
149int GIFdecode(
byte *GIFarr,
byte *PIXarr,
int *Width,
int *Height,
int *Ncols,
byte *
R,
byte *
G,
byte *
B)
174 if (strncmp((
char *)GIFarr,
"GIF87a",6) && strncmp((
char *)GIFarr,
"GIF89a",6))
176 fprintf(stderr,
"\nGIFinfo: not a GIF\n");
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");
236 Npix =(
long) (*Width) * (*Height);
243 fprintf(stderr,
"\nGIFdecode: corrupted GIF (zero block length)\n");
248 fprintf(stderr,
"\nGIFdecode: corrupted GIF (unexpected EOF)\n");
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 byte Suffix[TSIZE]
static byte OutCode[TSIZE]
static void OutPixel(byte pix)
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)