home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Graphics / graphics-16000.iso / win3x / viewers / hcsvga / hcgifv.c < prev    next >
C/C++ Source or Header  |  1993-12-06  |  1KB  |  80 lines

  1. /*
  2.  * HCGIFV.C
  3.  *
  4.  * Copyright 1990,1991 Synergrafix Consulting
  5.  *          All Rights Reserved.
  6.  *
  7.  * December 31,1991
  8.  *
  9.  */
  10.  
  11. #include <stdio.h>
  12. #include "hcgif.h"
  13.  
  14. char infilename[128];
  15. char errmsg[256];
  16.  
  17. void error(char *s) {
  18.     fcloseall();
  19.     hctextmode();
  20.     printf("%s\n",s);
  21.     exit(1);
  22.     }
  23.  
  24. int main(int argc,char *argv[]) {
  25.  
  26.     int err,mode,w,h;
  27.  
  28.     if (argc!=2)
  29.         error("Usage: HCGIFV giffilename");
  30.  
  31.     strcpy(infilename,argv[1]);
  32.  
  33.                         /* Get size of GIF file */
  34.  
  35.     err=hcgifsize(infilename,&w,&h,0L);
  36.     switch (err) {
  37.         case HCGIFCANTOPEN:
  38.             error("Can't open input file!");
  39.             break;
  40.         case HCGIFNOMEM:
  41.             error("Not enough memory to load file!");
  42.         case HCGIFNOTGIF:
  43.             error("Not a GIF File!");
  44.         case HCGIFBADGIF:
  45.             error("Error reading file!");
  46.         }
  47.  
  48.                         /* Set Hicolor mode */
  49.     mode=hcmodesize(w,h);
  50.     if (mode<2) mode=2;
  51.     if (mode>3) mode=3;
  52.  
  53.     if (!hcsetmode(mode,FALSE))
  54.         error("No HiColor DAC, or can't set mode!");
  55.  
  56.  
  57.                         /* View GIF file */
  58.  
  59.     err=hcgifview(infilename,-1,-1,0L,1);
  60.     switch (err) {
  61.         case HCGIFCANTOPEN:
  62.             error("Can't open input file!");
  63.             break;
  64.         case HCGIFNOMEM:
  65.             error("Not enough memory to load file!");
  66.         case HCGIFNOTGIF:
  67.             error("Not a GIF File!");
  68.         case HCGIFBADGIF:
  69.             error("Error reading file!");
  70.         }
  71.  
  72.     getch();                               /* Exit */
  73.  
  74.     hctextmode();
  75.  
  76.     return 0;
  77.     }
  78.  
  79.  
  80.