home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / grphutil / leadjpeg.arj / LEADSHOW.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-05  |  13.8 KB  |  347 lines

  1. /****************************************************************************/
  2. /* FILE NAME: LEADSHOW.C SOFTWARE DECOMPRESS FILE TO SCREEN                 */
  3. /* PROGRAMER: MOHAMMAD DAHER                                                */
  4. /* DATE:      03/12/1992                                                    */
  5. /*                                                                          */
  6. /*     COPYRIGHT (c) LEAD Technologies Inc. ALL RIGHTS RESEVED              */
  7. /****************************************************************************/
  8.  
  9.  
  10. #include <stdio.h>
  11. #include <dos.h>
  12. #include"v:\leadview\toolkit\L_Bitmap.h"
  13. #include"v:\leadview\toolkit\L_error.h"
  14. #include"v:\leadview\toolkit\toolapp.h"  
  15.  
  16.  
  17. #define OK 1
  18. #define BAD_COMMAND -2
  19. #define TARGAOLD 1
  20. #define VGA   2
  21.  
  22.  
  23.  
  24. int Width=0,Hight=0,Xorigin=0,Yorigin=0;
  25. int time=1;
  26. int video=VGA;
  27.  
  28.  
  29.  
  30. main(int argc, char *argv[])
  31. {
  32.   FILEINFO FileInformation;
  33.   struct find_t file;
  34.   int result;
  35.   int i;
  36.   char string[256], infile[128], pathname[128];
  37.   int lines=0;
  38.   int mode,page;
  39.   int error;
  40.  
  41.   L_GetVideoMode(&mode,&page);
  42.  
  43.   if(argc<=1)
  44.   {
  45.      printf("COPYRIGHT (C) LEAD Technologies, Inc. 1991,1992 ALL RIGHTS RESERVED.\n");
  46.      printf("              8701 Mallard Creek Rd.\n");
  47.      printf("              Charlotte NC 28262      Tel# (704)549-5532\n\n");
  48.      printf("\nIf you find this utility suitable for your use, please register this program\n");
  49.      printf("for $49.00 and receive the latest version.\n");
  50.      printf("Send $129.00 and receive in addition to the above, LEADVIEW, an easy to use\n");
  51.      printf("user interface that incorporates image compression/decompression, file\n"); 
  52.      printf("conversion to and from 8bit TGA, 16bit TGA, 24bit TGA, 32bit TGA, 8bit TIFF,\n"); 
  53.      printf("24bit TIFF, 4bit BMP, 8bit BMP 24bit BMP, PCX, GIF, BIN with resize/flip/rotate\n"); 
  54.      printf("options, and a communication module. A DOS version (which can be used from\n");   
  55.      printf("within a TSR taking only 6K of conventional memory) or Windows 3.X version is\n"); 
  56.      printf("available.\n\n");
  57.      printf("Other LEAD products include LEADVIEW Turbo and LEADVIEW 255 hardware\n");
  58.      printf("accelerator board (faster versions of LEADVIEW supporting real-time\n");
  59.      printf("compression/decompression) and LEADTOOLS, a run-time library of 'C' routines \n");
  60.      printf("for DOS or LEADTOOLS DLL for Windows 3.x that gives developers the ability to\n");
  61.      printf("incorporate compression, decompression, and conversion features into their\n");
  62.      printf("own applications.\n\n"); 
  63.      L_SleepKey(20);
  64.      printf("\nDOS - File to screen software deompression utility Version 3.1\n");
  65.      printf("USEAGE: LEADSHOW <source file> [/option1] [/option2] [/option3] [/option4]\n\n");
  66.      printf("<source file> is any LEAD, JFIF, or JTIF compressed file formats\n");
  67.      printf("              or TGA, TIFF, PCX, GIF, BMP image file formats\n");
  68.      printf("[option1] /TA for TARGA16, TARGA24, or TARGA32\n");
  69.      printf(" or       /V320  display to FAST SUPER VGA 320X200\n");
  70.      printf("          /V640  display to FAST SUPER VGA 640X480\n");
  71.      printf("          /V800  display to FAST SUPER VGA 800X600\n");
  72.      printf("          /V1024 display to FAST SUPER VGA 1024X768\n");
  73.      printf("[option2] /T# number of seconds to keep image displayed on the screen\n");
  74.      printf("[option3] /X# the X (horizontal) position of the image displayed on the screen\n");
  75.      printf("[option4] /Y# the Y (vertical) position of the image displayed on the screen\n\n");
  76.      printf("EXAMPLE LEADSHOW *.* /T4 /X20 /Y20\n");
  77.      printf("Will display all image files to the VGA/SuperVGA screen at the best resolution\nfor the selected image file\n");
  78.      exit(0);
  79.   }
  80.  
  81.  
  82.   for (i = 2; i<=argc; i++)
  83.    {
  84.       strupr(argv[i]);
  85.       if(argv[i][0]=='/')
  86.          if(get_value(&argv[i][1])==BAD_COMMAND)
  87.            {
  88.              printf("COPYRIGHT (C) LEAD Technologies, Inc. 1991,1992 ALL RIGHTS RESERVED.\n");
  89.              printf("              8701 Mallard Creek Rd.\n");
  90.              printf("              Charlotte NC 28262\n");
  91.              printf("              tel# (704)549-5532\n");
  92.              L_SleepKey(1);
  93.              printf("\nDOS - File to screen software deompression utility Version 3.1\n");
  94.              printf("USEAGE: LEADSHOW <source file> [/option1] [/option2] [/option3] [/option4]\n\n");
  95.              printf("<source file> is any LEAD, JFIF, or JTIF compressed file formats\n");
  96.              printf("              or TGA, TIFF, PCX, GIF, BMP image file formats\n");
  97.              printf("[option1] /TA for TARGA16, TARGA24, or TARGA32\n");
  98.              printf(" or       /V320  display to FAST SUPER VGA 320X200\n");
  99.              printf("          /V640  display to FAST SUPER VGA 640X480\n");
  100.              printf("          /V800  display to FAST SUPER VGA 800X600\n");
  101.              printf("          /V1024 display to FAST SUPER VGA 1024X768\n");
  102.              printf("[option2] /T# number of seconds to keep image displayed on the screen\n");
  103.              printf("[option3] /X# the X (horizontal) position of the image displayed on the screen\n");
  104.              printf("[option4] /Y# the Y (vertical) position of the image displayed on the screen\n\n");
  105.              printf("EXAMPLE LEADSHOW *.* /T4 /X20 /Y20\n");
  106.              printf("Will display all image files to the VGA/SuperVGA screen at the best resolution\nfor the selected image file\n\n\n");
  107.              printf("BAD COMMAND %s\n",argv[i-1]);
  108.               exit(0);
  109.            }
  110.    }
  111.    get_pathname(argv[1], pathname);
  112.    result = _dos_findfirst(argv[1], 0 , &file);
  113.    if (result)   /* if result has any value rather that 0 then  */
  114.       printf("LEADSHOW: no such file %s\n",argv[1]);
  115.    else
  116.       while(!result)  /* Stop when _dos_findnext returns */
  117.        {
  118.           strcpy(infile, pathname);
  119.           strcat(infile, file.name);
  120.           if (L_FileInfo(infile, &FileInformation)==SUCCESS)
  121.            {
  122.               if(video==VGA)
  123.                {
  124.                   L_SetVideoMode(mode,page);
  125.                   printf("COPYRIGHT (C) LEAD Technologies, Inc. 1991,1992 ALL RIGHTS RESERVED.\n");
  126.                   printf("              8701 Mallard Creek Rd.\n");
  127.                   printf("              Charlotte NC 28262\n");
  128.                   printf("              tel# (704)549-5532\n");
  129.                   printf("\nDOS - File to screen software deompression utility Version 3.1\n");
  130.                   printf("Viewing image file %s to VGA screen", infile);
  131.                   if( FileInformation.Format == FILE_TGA)
  132.                    {
  133.                       error=L_ShowTGAScreen(infile,Width,Hight,Xorigin,Yorigin);
  134.                    }
  135.                   else if( FileInformation.Format == FILE_TIF)
  136.                    {
  137.                       error=L_ShowTIFScreen(infile,Width,Hight,Xorigin,Yorigin);
  138.                    }
  139.                   else if( FileInformation.Format == FILE_BMP)
  140.                    {
  141.                       error=L_ShowBMPScreen(infile,Width,Hight,Xorigin,Yorigin);
  142.                    }
  143.                   else if( FileInformation.Format == FILE_OS2)
  144.                    {
  145.                       error=L_ShowBMPScreen(infile,Width,Hight,Xorigin,Yorigin);
  146.                    }
  147.                   else if( FileInformation.Format == FILE_PCX)
  148.                    {
  149.                       error=L_ShowPCXScreen(infile,Width,Hight,Xorigin,Yorigin);
  150.                    }
  151.                   else if( FileInformation.Format == FILE_GIF)
  152.                    {
  153.                       error=L_ShowGIFScreen(infile,Width,Hight,Xorigin,Yorigin);
  154.                    }
  155.                   else if( FileInformation.Format == FILE_CMP)
  156.                    {
  157.                       error=L_DecompressVGAScreen(infile,Xorigin,Yorigin);
  158.                    }
  159.                   else if( FileInformation.Format == FILE_JFIF)
  160.                    {
  161.                       error=L_DecompressVGAScreen(infile,Xorigin,Yorigin);
  162.                    }
  163.                   else if( FileInformation.Format == FILE_JTIF)
  164.                    {
  165.                       error=L_DecompressVGAScreen(infile,Xorigin,Yorigin);
  166.                    }
  167.             
  168.                  if(error==SUCCESS)
  169.                   {
  170.                      L_SleepKey(time);
  171.                   }
  172.                  else
  173.                    {
  174.                       printf("COPYRIGHT (C) LEAD Technologies, Inc. 1991,1992 ALL RIGHTS RESERVED.\n");
  175.                       printf("              8701 Mallard Creek Rd.\n");
  176.                       printf("              Charlotte NC 28262\n");
  177.                       printf("              tel# (704)549-5532\n");
  178.                       printf("\nDOS - File to screen software deompression utility Version 3.1\n");
  179.                       printf("ERROR %d VIEWING IMAGE FILE %s\n",error,file.name);
  180.                       l_SleepKey(2);
  181.                    }
  182.               }
  183.               else if(video==TARGAOLD)
  184.                {
  185.                  printf("COPYRIGHT (C) LEAD Technologies, Inc. 1991,1992 ALL RIGHTS RESERVED.\n");
  186.                  printf("              8701 Mallard Creek Rd.\n");
  187.                  printf("              Charlotte NC 28262\n");
  188.                  printf("              tel# (704)549-5532\n");
  189.                  printf("\nDOS - File to screen software deompression utility Version 3.1\n");
  190.                  printf("Viewing image file %s to TARGA screen",file.name);
  191.                  if( FileInformation.Format == FILE_TGA)
  192.                   {
  193.                      error=L_ShowTGATarga(infile,Width,Hight,Xorigin,Yorigin);
  194.                   }
  195.                  else if( FileInformation.Format == FILE_TIF)
  196.                   {
  197.                      error=L_ShowTIFTarga(infile,Width,Hight,Xorigin,Yorigin);
  198.                   }
  199.                  else if( FileInformation.Format == FILE_BMP)
  200.                   {
  201.                      error=L_ShowBMPTarga(infile,Width,Hight,Xorigin,Yorigin);
  202.                   }
  203.                  else if( FileInformation.Format == FILE_OS2)
  204.                   {
  205.                      error=L_ShowBMPTarga(infile,Width,Hight,Xorigin,Yorigin);
  206.                   }
  207.                  else if( FileInformation.Format == FILE_PCX)
  208.                   {
  209.                      error=L_ShowPCXTarga(infile,Width,Hight,Xorigin,Yorigin);
  210.                   }
  211.                  else if( FileInformation.Format == FILE_GIF)
  212.                   {
  213.                      error=L_ShowGIFTarga(infile,Width,Hight,Xorigin,Yorigin);
  214.                   }
  215.                  else if( FileInformation.Format == FILE_CMP)
  216.                   {
  217.                      error=L_DecompressTARGAScreen(infile,Xorigin,Yorigin);
  218.                   }
  219.                  else if( FileInformation.Format == FILE_JFIF)
  220.                   {
  221.                      error=L_DecompressTARGAScreen(infile,Xorigin,Yorigin);
  222.                   }
  223.                  else if( FileInformation.Format == FILE_JTIF)
  224.                   {
  225.                      error=L_DecompressTARGAScreen(infile,Xorigin,Yorigin);
  226.                   }
  227.             
  228.                 if(error==SUCCESS)
  229.                   L_SleepKey(time);
  230.                 else
  231.                   {
  232.                      printf("COPYRIGHT (C) LEAD Technologies, Inc. 1991,1992 ALL RIGHTS RESERVED.\n");
  233.                      printf("              8701 Mallard Creek Rd.\n");
  234.                      printf("              Charlotte NC 28262\n");
  235.                      printf("              tel# (704)549-5532\n");
  236.                      printf("\nDOS - File to screen software deompression utility Version 3.1\n");
  237.                      printf("ERROR %d VIEWING IMAGE FILE %s\n",error,file.name);
  238.                      l_SleepKey(2);
  239.                   }
  240.                }
  241.               L_SetVideoMode(mode,page);
  242.            }
  243.           else
  244.            {
  245.               L_SetVideoMode(mode,page);
  246.               printf("COPYRIGHT (C) LEAD Technologies, Inc. 1991,1992 ALL RIGHTS RESERVED.\n");
  247.               printf("              8701 Mallard Creek Rd.\n");
  248.               printf("              Charlotte NC 28262\n");
  249.               printf("              tel# (704)549-5532\n");
  250.               printf("\nDOS - File to screen software deompression utility Version 3.1\n");
  251.               printf("ERROR %d VIEWING IMAGE FILE %s\n",error,file.name);
  252.               printf("LEADSHOW: error opening file %s\n",file.name);
  253.               putch(7);
  254.            }
  255.          result = _dos_findnext(&file);
  256.        }
  257. }
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265. get_value(char *string)
  266. {
  267.  int ret=OK;
  268.  
  269.  if (string[0] == 'X')
  270.   {
  271.      Xorigin = atoi(string+1);
  272.      if (Xorigin <= 0 || Xorigin > 1024)
  273.         return(BAD_COMMAND);
  274.      else
  275.         return(ret);
  276.   }
  277.  
  278.  if (string[0] == 'Y')
  279.   {
  280.      Yorigin = atoi(string+1);
  281.      if (Yorigin <= 0 || Yorigin > 1024)
  282.         return(BAD_COMMAND);
  283.      else
  284.         return(ret);
  285.   }
  286.  
  287.  if (string[0] == 'T' && string[1] != 'A')
  288.   {
  289.      time = atoi(string+1);
  290.      if (time < 0)
  291.         return(BAD_COMMAND);
  292.      else
  293.         return(ret);
  294.   }
  295.  
  296.  if (string[0] == 'T' && string[1] == 'A')
  297.   {
  298.      video=TARGAOLD;
  299.      if(L_TARGAInit()==0)
  300.       {
  301.          printf("TARGA Initialization error\n\n");
  302.          exit(0);
  303.       }
  304.   }
  305.  
  306.  
  307.  if(string[0] == 'V')
  308.   {
  309.      video=VGA;
  310.      if(strstr(string,"V320"))
  311.         L_SetVGASize(SIZE_320x200);
  312.      else if(strstr(string,"V640"))
  313.         L_SetVGASize(SIZE_640x480);
  314.      else if(strstr(string,"V800"))
  315.         L_SetVGASize(SIZE_800x600);
  316.      else if(strstr(string,"V1024"))
  317.         L_SetVGASize(SIZE_1024x768);
  318.   }
  319.  return(ret);
  320. }
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331. get_pathname(char in[], char pathname[])
  332. {
  333.  int i;
  334.  
  335.  strcpy(pathname, in);
  336.  for (i = strlen(in)-1; i >= 0; i--)
  337.   {
  338.     if( (in[i] == '\\') || (in[i] == ':') )
  339.       break;
  340.   }
  341.  
  342.  if (i == 0)
  343.     pathname[0] = 0;
  344.  else
  345.     pathname[i+1] = 0;
  346. }
  347.