home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / graphics / 11517 < prev    next >
Encoding:
Text File  |  1992-11-05  |  19.6 KB  |  547 lines

  1. Newsgroups: comp.graphics
  2. Path: sparky!uunet!cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!spool.mu.edu!darwin.sura.net!news.duc.auburn.edu!eng.auburn.edu!sjreeves
  3. From: sjreeves@eng.auburn.edu (Stan Reeves)
  4. Subject: Re: anything to ASCII image converter
  5. Message-ID: <sjreeves.921104102934@fourier.ee.eng.auburn.edu>
  6. Sender: usenet@news.duc.auburn.edu (News Account)
  7. Nntp-Posting-Host: fourier.ee.eng.auburn.edu
  8. Organization: Auburn University Engineering
  9. References: <1992Nov2.231556.20933@sol.ctr.columbia.edu>
  10. Date: Wed, 4 Nov 1992 16:29:34 GMT
  11. Lines: 534
  12.  
  13. In article <1992Nov2.231556.20933@sol.ctr.columbia.edu> anselmo@cumesb.mech.columbia.edu (Andrew P. Anselmo) writes:
  14. >
  15. >
  16. >Hello Netland-
  17. >
  18. >I was wondering if anyone knew of a nice widget to convert gif/pbx/pbm/tiff
  19. >whatever to crude ASCII images, suitable for display on a crude 80x25
  20. >character device.  
  21.  
  22. Here's one:
  23.  
  24.  
  25.  
  26. #! /bin/sh
  27. # This is a shell archive.  Remove anything before this line, then feed it
  28. # into a shell via "sh file" or similar.  To overwrite existing files,
  29. # type "sh file -c".
  30. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  31. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  32. # Contents:  ascgif.c
  33. # Wrapped by kent@sparky on Sat May 23 22:57:11 1992
  34. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  35. echo If this archive is complete, you will see the following message:
  36. echo '          "shar: End of archive."'
  37. if test -f 'ascgif.c' -a "${1}" != "-c" ; then 
  38.   echo shar: Will not clobber existing file \"'ascgif.c'\"
  39. else
  40.   echo shar: Extracting \"'ascgif.c'\" \(17535 characters\)
  41.   sed "s/^X//" >'ascgif.c' <<'END_OF_FILE'
  42. X/* Ascii Gif Viewer Version 1.6 May (c) 1992 John Ferrell jwf10@juts.ccc.amdahl.com*/
  43. X/* 5 changes for pc to mainframe portability. (search on 'mainframes') */
  44. X
  45. X#include <string.h>
  46. X#include <libc.h>     /* libc.h for mainframes, stdlib.h for pc */
  47. X#include <stdio.h>
  48. X
  49. X#define UBYTE unsigned char  /* 8Bit */
  50. X#define UWORD unsigned short /* 16Bit */
  51. X#define ULONG unsigned int   /* 32Bit  int for mainframes, long for pc */
  52. X#define BOOL unsigned short
  53. X
  54. X#define TRUE  1
  55. X#define FALSE 0
  56. X
  57. X
  58. Xstruct GIFdescriptor {
  59. X   UWORD gd_Width;
  60. X   UWORD gd_Height;
  61. X   UBYTE gd_ColInfo;
  62. X   UBYTE gd_BackGround;
  63. X   UBYTE gd_PixelAspect;
  64. X};
  65. X
  66. Xstruct ImageDesc {
  67. X   UWORD id_Left;
  68. X   UWORD id_Top;
  69. X   UWORD id_Width;
  70. X   UWORD id_Height;
  71. X   UBYTE id_Info;
  72. X};
  73. X
  74. Xstruct RGB {
  75. X   UBYTE rgb_Red;
  76. X   UBYTE rgb_Green;
  77. X   UBYTE rgb_Blue;
  78. X};
  79. X
  80. X
  81. X#define GIF_IMAGE       0x2C
  82. X#define GIF_EXTENSION   0x21
  83. X#define GIF_TERMINATOR  0x3B
  84. X#define GIF_COMMENT_EXT 0xFE
  85. X
  86. X/* void *screen; */  /* uncomment for pc, comment out for mainframes */
  87. X
  88. Xint gx=79;
  89. Xint gy=23;
  90. X
  91. Xstruct GIFdescriptor gdesc;
  92. X
  93. XUBYTE **BitPlane;
  94. Xstruct RGB GlobalColourTable[256];
  95. X
  96. XUBYTE Map[256];
  97. X
  98. XULONG ImageNumber;
  99. X
  100. XFILE *GIFfh = NULL;
  101. XFILE *CAPT = NULL;
  102. X
  103. Xvoid ERROR(str)
  104. X   char *str;
  105. X   {
  106. X   printf(str);
  107. X   exit(1);
  108. X   }
  109. X
  110. Xvoid FlipWord(word)
  111. X   UWORD *word;
  112. X   {
  113. X   UBYTE swap1;
  114. X   UBYTE swap2;
  115. X   swap1 = *word & 0xFF;                /*comment out for pc, needed for mainframes */
  116. X   swap2 = (*word & 0xFF00) >> 8;       /*       "                "                 */
  117. X   *word = swap1 << 8 | swap2;          /*       "                "                 */
  118. X   }
  119. X
  120. Xstatic struct ImageDesc idesc;
  121. Xstatic struct RGB LocalColourTable[256];
  122. X
  123. Xstatic UWORD Xpos, Ypos;
  124. Xstatic BOOL interleave;
  125. X
  126. Xstatic UBYTE LeaveStep[5]  = {1, 8, 8, 4, 2};
  127. Xstatic UBYTE LeaveFirst[5] = {0, 0, 4, 2, 1};
  128. X
  129. Xstatic int ReadError;
  130. Xstatic UBYTE CodeSize;
  131. Xstatic int EOFCode;
  132. Xstatic UBYTE ReadMask;
  133. Xstatic int CompDataPointer;
  134. Xstatic int CompDataCount;
  135. Xstatic UBYTE CompData[256];
  136. X
  137. Xstatic UWORD Prefix[4096];
  138. Xstatic UBYTE Suffix[4096];
  139. Xstatic UBYTE OutCode[1025];
  140. X
  141. Xstatic UBYTE ByteBuf;
  142. X
  143. Xint ReadCode(fh)
  144. X   FILE *fh;
  145. X   {
  146. X   register int temp;
  147. X   register int DstMasked;
  148. X   register int DstMask;
  149. X   long size;
  150. X   temp = 0;                             
  151. X   DstMasked = 1L << CodeSize;           
  152. X   for (DstMask = 1; DstMask != DstMasked; DstMask <<= 1)
  153. X      {                                  
  154. X      if (!ReadMask)                     
  155. X         {                               
  156. X         if (CompDataPointer == CompDataCount)
  157. X            {
  158. X            if ((size = fgetc(fh)) == -1)
  159. X               {                         
  160. X               printf("\nI/O Error during decompression.\n");
  161. X               ReadError = 1;            
  162. X               return EOFCode;           
  163. X               }                         
  164. X            if (fread((char *)CompData,1,size,fh) != size)
  165. X               {                         
  166. X               printf("\nI/O Error during decompression.\n");
  167. X               ReadError = 1;            
  168. X               return EOFCode;           
  169. X               }                         
  170. X            CompDataCount = size;        
  171. X            CompDataPointer = 0;         
  172. X            }                            
  173. X         ReadMask = 1;                   
  174. X         ByteBuf = CompData[CompDataPointer++];
  175. X         }                               
  176. X      if (ByteBuf & ReadMask) temp |= DstMask;
  177. X      ReadMask <<= 1;                    
  178. X      }                                  
  179. X   return temp;                          
  180. X   }                                     
  181. X                                         
  182. Xvoid AddPixel(index)                     
  183. X   UBYTE index;                          
  184. X   {                                     
  185. X   register UWORD XStore;
  186. X   register UWORD YStore;
  187. X   XStore = Xpos + idesc.id_Left;        
  188. X   YStore = Ypos + idesc.id_Top;         
  189. X   BitPlane[YStore][XStore] = index;
  190. X   if (++Xpos == idesc.id_Width)         
  191. X      {                                  
  192. X      Xpos = 0;                          
  193. X      Ypos += LeaveStep[interleave];
  194. X      if (Ypos >= idesc.id_Height) Ypos = LeaveFirst[++interleave];
  195. X      }                                  
  196. X   }                                     
  197. X                                         
  198. XBOOL DoImage(fh)                         
  199. X   FILE *fh;                             
  200. X   {                                     
  201. X   register int index;
  202. X   register int colours;
  203. X   int Code;
  204. X   printf("Image #%ld encountered.\n", ImageNumber++);
  205. X   if (fread((char *)&idesc,1,9,fh) != 9)
  206. X      ERROR("Error reading image descriptor.\n");
  207. X   FlipWord(&idesc.id_Left);             
  208. X   FlipWord(&idesc.id_Top);              
  209. X   FlipWord(&idesc.id_Width);            
  210. X   FlipWord(&idesc.id_Height);           
  211. X   interleave = idesc.id_Info & 1L << 6;
  212. X   if (interleave) interleave = 1;       
  213. X   printf("Xpos from %d to %d, Ypos from %d to %d, %sinterlaced.\n",
  214. X      idesc.id_Left, idesc.id_Left + idesc.id_Width - 1,
  215. X      idesc.id_Top, idesc.id_Top + idesc.id_Height - 1,
  216. X      interleave ? "" : "not ");         
  217. X   if (idesc.id_Info & 1L << 7)          
  218. X      {                                  
  219. X      colours = 1L << ((idesc.id_Info & 7) + 1);
  220. X      printf("Local colour map contains %d entries.\n", colours);
  221. X      for (index = 0; index < colours; index++)
  222. X        if (fread(&LocalColourTable[index],1,3,fh) != 3)
  223. X            ERROR("......Error reading local colour\n");
  224. X      }                                  
  225. X   else                                  
  226. X      {                                  
  227. X      colours = 1L << ((gdesc.gd_ColInfo & 7) + 1);
  228. X      for (index=0; index<colours; index++)
  229. X        LocalColourTable[index]=GlobalColourTable[index];
  230. X      }                                  
  231. X   Xpos = Ypos = 0;                      
  232. X                                         
  233. X   {                                     
  234. X      int MaxCode, ClearCode, CurCode,   
  235. X          OldCode, InCode, FreeCode;     
  236. X      int OutCount;                      
  237. X      int FirstFree;                     
  238. X      UBYTE InitCodeSize, FinChar, BitMask;
  239. X      if ((CodeSize = fgetc(fh)) == -1)
  240. X         ERROR("\n......I/O Error during decompression.\n");
  241. X      ClearCode = 1L << CodeSize;        
  242. X      EOFCode = ClearCode + 1;           
  243. X      FreeCode = FirstFree = ClearCode + 2;
  244. X      CodeSize++;                        
  245. X      InitCodeSize = CodeSize;           
  246. X      MaxCode = 1L << CodeSize;          
  247. X      ReadError = ReadMask = OutCount = 0;
  248. X      CompDataPointer = CompDataCount = 0;
  249. X      BitMask = colours - 1;             
  250. X      Code = ReadCode(fh);               
  251. X      while (Code != EOFCode)            
  252. X         {                               
  253. X         if (ReadError) return TRUE;     
  254. X         if (Code == ClearCode)          
  255. X            {                            
  256. X            CodeSize = InitCodeSize;     
  257. X            MaxCode = 1L << CodeSize;    
  258. X            FreeCode = FirstFree;        
  259. X            FinChar = CurCode = OldCode = Code = ReadCode(fh);
  260. X            AddPixel(FinChar);           
  261. X            }                            
  262. X         else                            
  263. X            {                            
  264. X            CurCode = InCode = Code;     
  265. X            if (CurCode >= FreeCode)     
  266. X               {                         
  267. X               CurCode = OldCode;        
  268. X               OutCode[OutCount++] = FinChar;
  269. X               }                         
  270. X            while (CurCode > BitMask)    
  271. X               {                         
  272. X               if (OutCount > 1024)      
  273. X                  {                      
  274. X                  printf("\nCorrupt GIF file (OutCount)\n");
  275. X                  return TRUE;           
  276. X                  }                      
  277. X                  OutCode[OutCount++] = Suffix[CurCode];
  278. X                  CurCode = Prefix[CurCode];
  279. X               }                         
  280. X            FinChar = CurCode;           
  281. X            AddPixel(FinChar);           
  282. X            for (index = OutCount - 1; index >= 0; index--)
  283. X              AddPixel(OutCode[index]);
  284. X            OutCount = 0;                
  285. X            Prefix[FreeCode] = OldCode;
  286. X            Suffix[FreeCode] = FinChar;
  287. X            OldCode = InCode;            
  288. X            if (++FreeCode >= MaxCode)   
  289. X               {                         
  290. X               if (CodeSize < 12)        
  291. X                  {                      
  292. X                  CodeSize++;            
  293. X                  MaxCode <<= 1;         
  294. X                  }                      
  295. X               }                         
  296. X            }                            
  297. X         Code = ReadCode(fh);            
  298. X      }                                  
  299. X   }                                     
  300. X   if ((Code = fgetc(fh)) == -1) return TRUE;
  301. X   if (Code != 0) printf("Warning:  Unaligned packet.\n");
  302. X   return FALSE;                         
  303. X   }                                     
  304. X                                         
  305. X/* #define gx 79 */
  306. X/* #define gy 23 */
  307. X#define base 5                           
  308. X#define colors 16
  309. X
  310. Xchar *colortab[colors] =
  311. X   {".",",",":",";","+","=","i",")","I","T","L","H","O","X","8","#"};
  312. X                                         
  313. Xvoid show(name)
  314. X   char *name;
  315. X   {
  316. X   register int i,j,x,y;
  317. X   register int ix,iy,ii,jj;
  318. X   struct RGB colour;
  319. X   char Cbuf [1];
  320. X   int flag, cc, zz, dx, dy, z, dcnt, g, gc;
  321. X   x=y=ix=iy=dx=dy=i=j=zz=z=dcnt=g=0;
  322. X   gc=20;
  323. X   cc=1;
  324. X   dx=(idesc.id_Width<<base)/gx;
  325. X   dy=(idesc.id_Height<<base)/gy;
  326. X   do                                    
  327. X   {                                     
  328. X   printf("\n(v)iew (z Z)oom (c)opy (l,r,u,d)=PAN (g)rey (+)(-) (s)wap (1-4)=MIX (h)elp: ");
  329. X   while ((flag=getchar())==(char)10);
  330. X   if (flag == 'v' || flag == 'z' || flag == 'Z' ||
  331. X       flag == 'l' || flag == 'h' || flag == 'c' ||
  332. X       flag == 'r' || flag == 'u' || flag == 'd' || flag == 's' ||
  333. X       flag == 'g' || flag == 'G' || flag == '1' || flag == '2' ||
  334. X       flag == '3' || flag == '4' || flag == '+' || flag == '-'); else return;
  335. X   if (flag=='v')cc=1;
  336. X   if (flag=='1'){cc=1; printf("\nDefault Mix\n");}
  337. X   if (flag=='2'){cc=2; printf("\nRed Mix Blocked\n");}
  338. X   if (flag=='3'){cc=3; printf("\nGreen Mix Blocked\n");}
  339. X   if (flag=='4'){cc=4; printf("\nBlue Mix Blocked\n");}
  340. X   if (flag=='g'){cc=5; printf("\nAssuming This Is A Grey Scale Gif\n");}
  341. X   if (flag=='+'){cc=5; gc+=5; printf("\nRaising Sensitivity To %d, Assuming This Is A Grey Scale Gif\n", gc);}
  342. X   if (flag=='-'){cc=5; gc-=5; printf("\nLowering Sensitivity To %d Assuming This Is A Grey Scale Gif\n", gc);}
  343. X   if (flag=='s'){cc=5;if (g==0)g=1; else g=0; printf("\nSwapping Background For Grey Scale Gif, Assuming This Is A Grey Scale Gif\n");}
  344. X   if (flag=='c'){
  345. X      printf("\nAppending copy of screen to file ascgifs\n");
  346. X      if (!(CAPT = fopen("ascgifs","a"))) ERROR("Open error\n");
  347. X      Cbuf[0] = 10;
  348. X      if(fwrite(Cbuf,1,1,CAPT) != 1)
  349. X         ERROR("Unable to write to ascgifs.\n");
  350. X      if(fwrite(name,1,strlen(name),CAPT) != strlen(name))
  351. X          ERROR("Unable to write to ascgifs.\n");
  352. X      }
  353. X   if (flag=='u'){if(iy>=dy*gy/4) iy=iy-dy*gy/4;};
  354. X   if (flag=='d'){if(iy+dy*gy+2*dy<((idesc.id_Height)<<base)) iy=iy+dy*gy/4;};
  355. X   if (flag=='z'){
  356. X      dx>>=1;                            
  357. X      dy>>=1;
  358. X      ix=ix+dx*gx/2;
  359. X      iy=iy+dy*gy/2;
  360. X      };
  361. X   if (flag=='Z'){
  362. X      dx=(idesc.id_Width<<base)/gx;
  363. X      dy=(idesc.id_Height<<base)/gy;
  364. X      ix=0;
  365. X      iy=0;
  366. X      };
  367. X   if (flag=='r'){if(ix+dx*gx+2*dx<((idesc.id_Width)<<base)) ix=ix+dx*gx/4;};
  368. X   if (flag=='l'){if(ix>=dx*gx/4) ix=ix-dx*gx/4;};
  369. X   y=iy;
  370. X   if (zz == 0){
  371. X      colour=LocalColourTable[BitPlane[(y>>base)+idesc.id_Top]
  372. X                       [(x>>base)+idesc.id_Left]];
  373. X      zz=(colour.rgb_Red+colour.rgb_Green+colour.rgb_Blue)/3;
  374. X   }
  375. X   if (flag == 'h'){
  376. X   printf("\nv = View The Gif\n");
  377. X   printf("z = Zoom In On The Center\n");
  378. X   printf("Z = Zoom Out To Normal Size\n");
  379. X   printf("c = Capture screen\n");
  380. X   printf("l = Pan Left\n");
  381. X   printf("r = Pan Right\n");
  382. X   printf("u = Pan Up\n");
  383. X   printf("d = Pan Down\n");
  384. X   printf("g = Display A Grey Scale Gif, Use Only With A Grey Scale Gif\n");
  385. X   printf("+ = Raise Sensitivity For A Grey Scale Gif\n");
  386. X   printf("- = Lower Sensitivity For A Grey Scale Gif\n");
  387. X   printf("s = Swap Background For Grey Scale Gif From/To Black/White\n");
  388. X   printf("1 = Default Mix\n");
  389. X   printf("2 = Red Mix Blocked\n");
  390. X   printf("3 = Green Mix Blocked\n");
  391. X   printf("4 = Blue Mix Blocked\n");
  392. X   printf("Any other character will quit\n");
  393. X   }
  394. X   else {
  395. X   for (j=0; j<gy; j++)
  396. X      {
  397. X      if (flag== 'c'){
  398. X        Cbuf[0] = 10;
  399. X        if(fwrite(Cbuf,1,1,CAPT) != 1)
  400. X          ERROR("Unable to write to ascgifs.\n");
  401. X      }
  402. X      printf("\n");
  403. X      x=ix;
  404. X      for (i=0; i<gx; i++)
  405. X         {                               
  406. X         if (cc==5){
  407. X          dcnt=0;
  408. X           for (jj=y; jj-y<dy; jj+=4){
  409. X              for (ii=x; ii-x<dx; ii+=4){
  410. X                colour=LocalColourTable[BitPlane[(jj>>base)+idesc.id_Top]
  411. X                                             [(ii>>base)+idesc.id_Left]];
  412. X                z=(colour.rgb_Red+colour.rgb_Green+colour.rgb_Blue)/3;
  413. X                if (g == 1){
  414. X                  if (zz==z)dcnt++;}
  415. X                else if (zz!=z) dcnt++;
  416. X              }
  417. X           };
  418. X           z=dcnt/(dx/gc+dy/gc);
  419. X           if (z<1)z=1;
  420. X           if (z>256)z=256;
  421. X         }
  422. X         else {
  423. X          colour=LocalColourTable[BitPlane[(y>>base)+idesc.id_Top]
  424. X                                         [(x>>base)+idesc.id_Left]];
  425. X          if (cc==2){
  426. X            z=(colour.rgb_Green+colour.rgb_Blue)/2;}
  427. X          else if (cc==3){
  428. X                 z=(colour.rgb_Red+colour.rgb_Blue)/2;}
  429. X              else if (cc==4){
  430. X                      z=(colour.rgb_Red+colour.rgb_Green)/2;}
  431. X                   else {
  432. X                        z=(colour.rgb_Red+colour.rgb_Green+colour.rgb_Blue)/3;
  433. X                        };
  434. X         }
  435. X         if (flag=='c'){
  436. X           Cbuf[0] = *colortab[(z+gc-20)*colors/0x100];
  437. X           if(fwrite(Cbuf,1,1,CAPT) != 1)
  438. X             ERROR("Unable to write to ascgifs.\n");
  439. X         }
  440. X         printf(colortab[(z+gc-20)*colors/0x100]);
  441. X         x+=dx;
  442. X         if (x<0)return;
  443. X      }
  444. X      y+=dy;                             
  445. X      }
  446. X      }
  447. X   if (flag== 'c') fclose(CAPT);
  448. X   } while (TRUE);
  449. X   }                                     
  450. X                                         
  451. Xmain(argc,argv)                          
  452. X   int argc;
  453. X   char *argv[];
  454. X   {                                     
  455. X   register int index;
  456. X   char sig[7];
  457. X   int size;
  458. X   int error;                            
  459. X   int colours;                          
  460. X   long cmdcode;                         
  461. X   if (argc < 2) ERROR("ascgif(1.6) use: ascgif name.gif <output width> <output height>\n");
  462. X   if (!(GIFfh = fopen(argv[1],"r"))) ERROR("Open error\n"); /*"rb" for pc, "r" for SOME mainframes */
  463. X   if (argc > 2){
  464. X     if (!(gx=atoi(argv[2]))) ERROR("3rd parameter not numeric, (width)\n");
  465. X     if (!(gy=atoi(argv[3]))) ERROR("4th parameter not numeric, (height)\n");
  466. X     }
  467. X   else { gx = 79;
  468. X          gy = 23;
  469. X        };
  470. X   sig[6] = '\0';
  471. X   if (fread(sig,1,6,GIFfh) != 6 || strcmp("GIF87a", sig))
  472. X      ERROR("Not an 87a GIF file...\n");
  473. X   if (fread((char *)&gdesc,1,7,GIFfh) != 7)
  474. X      ERROR("Error reading screen descriptor\n");
  475. X   FlipWord(&gdesc.gd_Width);
  476. X   FlipWord(&gdesc.gd_Height);           
  477. X   printf("Ascgif Ver 1.6\n");
  478. X   printf("Signature = \"%s\", Width = %u, Height = %u\n",
  479. X      sig, gdesc.gd_Width, gdesc.gd_Height);
  480. X   colours = 1L << ((gdesc.gd_ColInfo & 7) + 1);
  481. X   if (!(gdesc.gd_ColInfo & 1L << 7))    
  482. X      {                                  
  483. X      printf("No global colour map supplied, using internal.\n");
  484. X      for (index = 0; index < colours; index++)
  485. X         {                               
  486. X         GlobalColourTable[index].rgb_Red   =
  487. X         GlobalColourTable[index].rgb_Green =
  488. X         GlobalColourTable[index].rgb_Blue  = index;
  489. X         }                               
  490. X      }                                  
  491. X   else                                  
  492. X      {                                  
  493. X      printf("Global colour map contains %d entries.\n", colours);
  494. X      for (index = 0; index < colours; index++)
  495. X         if (fread(&GlobalColourTable[index],1,3,GIFfh) != 3)
  496. X            ERROR("Error reading global colour\n");
  497. X      }
  498. X   size = ((gdesc.gd_Width + 7) / 8) + 1;
  499. X   size += (size + 127) >> 7;
  500. X   if (!(BitPlane = (UBYTE **)malloc(gdesc.gd_Height * sizeof(UBYTE *))))
  501. X      ERROR("Not enough memory\n");
  502. X   size = (gdesc.gd_Width + 1) * sizeof(UBYTE);
  503. X   for (index = 0; index < gdesc.gd_Height; index++)
  504. X      if (!(BitPlane[index] = (UBYTE *)malloc(size)))
  505. X         ERROR("Not enough memory\n");
  506. X   ImageNumber = 1;
  507. X   for (error = FALSE; error == FALSE;)
  508. X      {
  509. X      if ((cmdcode = fgetc(GIFfh)) == -1) break;
  510. X      if (cmdcode ==
  511. X          GIF_IMAGE){
  512. X            error = DoImage(GIFfh);
  513. X            } else
  514. X      if (cmdcode ==
  515. X           GIF_EXTENSION){
  516. X            error = TRUE;                
  517. X           } else
  518. X      if (cmdcode ==
  519. X           GIF_TERMINATOR){
  520. X            show(argv[1]);
  521. X            break;
  522. X           }
  523. X           else {
  524. X            printf("Unknown directive encountered.\n");                         
  525. X            error = TRUE;                
  526. X           }
  527. X      }                                  
  528. X      printf("End of GIF session\n");    
  529. X      exit(0);                           
  530. X   } 
  531. X
  532. END_OF_FILE
  533.   if test 17535 -ne `wc -c <'ascgif.c'`; then
  534.     echo shar: \"'ascgif.c'\" unpacked with wrong size!
  535.   fi
  536.   # end of 'ascgif.c'
  537. fi
  538. echo shar: End of archive.
  539. exit 0
  540. exit 0 # Just in case...
  541.  
  542.  
  543. --
  544. Stan Reeves
  545. Auburn University, Department of Electrical Engineering, Auburn, AL  36849
  546. INTERNET: sjreeves@eng.auburn.edu
  547.