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

  1. /*
  2.  * HCTGAV.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 "hctarga.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(
  22.  
  23. 1);
  24.     }
  25.  
  26. int main(int argc,char *argv[]) {
  27.  
  28.     int err,mode,w,h,ox,oy,pixsize,ttype,comp,map,commentsize;
  29.     unsigned char comment[256];
  30.  
  31.     if (argc!=2)
  32.         error("Usage: HCVTGA tgafilename");
  33.  
  34.     strcpy(infilename,argv[1]);
  35.  
  36.                         /* Get size of TGA file */
  37.  
  38.     err=hctgasize(infilename,&w,&h,&pixsize,&ox,&oy,&ttype,&comp,&map,&commentsize,&comment);
  39.     switch (err) {
  40.         case HCTGACANTOPEN:
  41.             error("Can't open input file!");
  42.             break;
  43.         case HCTGANOMEM:
  44.             error("Not enough memory to load file!");
  45.         case HCTGANOTSUPPORTED:
  46.             error("File type not supported!");
  47.         case HCTGACANTREAD:
  48.             error("Error reading file!");
  49.         }
  50.  
  51.                         /* Set Hicolor mode */
  52.     mode=hcmodesize(w,h);
  53.     if (mode<2) mode=2;
  54.     if (mode>3) mode=3;
  55.  
  56.     if (!hcsetmode(mode,FALSE))
  57.         error("Can't set HiColor mode.");
  58.  
  59.  
  60.                         /* View TGA file */
  61.  
  62.     err=hctgaview(infilename,-1,-1,-1,-1,0,0);
  63.     switch (err) {
  64.         case HCTGACANTOPEN:
  65.             error("Can't open input file!");
  66.             break;
  67.         case HCTGANOMEM:
  68.             error("Not enough memory to load file!");
  69.         case HCTGANOTSUPPORTED:
  70.             error("File type not supported!");
  71.         case HCTGACANTREAD:
  72.             error("Error reading file!");
  73.         }
  74.  
  75.     getch();                               /* Exit */
  76.  
  77.     hctextmode();
  78.  
  79.     return 0;
  80.     }
  81.  
  82.  
  83.