/* ** MyGif.c ** ** Stupid & simple EGA GIF viewer. Does not load color palette, simply ** decodes and displays the image. ** ** Rewrite LoadPalette() to perform palette loading. I didn't insert ** this since my viewer uses my frame grabber board for display, and ** the palette loading code is very different. Also loading a VGA ** palette is different from that of the EGA. Customize for your ** system. ** ** I hereby release this code to the public domain, no restrictions, ** no warranty, no nothing. This applies only to this file (mygif.c), ** see the other files for other copyrights, etc. */ #include #include #include #include #include #include #include #include #include #include "errs.h" #define FALSE 0 #define TRUE 1 #define min(x,y) (xy ? x:y) #define ROWCNT 350 #define COLCNT 640 typedef unsigned int uint; typedef unsigned char uchar; /* VDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD7 : Working variables - globals, screen info, color table : SDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD= */ int infile; /* Input file handle */ uint screenwidth; /* The dimensions of the screen */ uint screenheight; /* (not those of the image) */ short global; /* Is there a global color map? */ int globalbits; /* Number of bits of global colors */ int backclr; /* Background color */ int colres; /* Number of bits of color resol. */ int *interleavetable; uchar globalmap[256][3]; /* RGB values for global color map */ uchar colortable[256*3]; /* RGB values for image */ uint row,left,top, width,height; void usage(), fatal(), checksignature(), readextension(); void readscreen(), initcolors(), readimage(); /* Support routines: customize for your system ** get_byte() - return next byte of GIF image data ** out_line() - display a line of graphics on the screen ** ** Load_Pallete() - load the proper colors into the palette */ get_byte() { uint ch; /* VERY slow, use buffered reading for faster throughput */ if (read(infile,(char *)&ch,1)==1) return(ch); else return(READ_ERROR); } out_line(line, len) uchar line[]; int len; { register uint i; /* slow, maybe write out entire line at once, instead of pixel by pixel */ if (interleavetable[row] < ROWCNT) { for(i=0; i> 4) +1; backclr = buf[5]; if (global) { globalbits = (buf[4] & 0x07) + 1; read(infile,(char *)globalmap,3*(1<