home *** CD-ROM | disk | FTP | other *** search
/ Dr. CD ROM (Annual Premium Edition) / premium.zip / premium / DOSGRAPH / JPGVIEW.ZIP / LEADSHOW.C next >
Text File  |  1992-08-06  |  14KB  |  344 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=99;
  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("LEADTOOLS Sharwareis for Evaluation purposes only. Your license to use this\n");
  49.      printf("software will expire after 3 weeks from the date you receive it.\n");
  50.      printf("You are free to distribute this sharware copy of LEADTOOLS as long as all \n");
  51.      printf("files listed (TOOL.C TOOL4.EXE LEADSHOW.C LEADSHOW.EXE LEADCOMP.C\n");
  52.      printf("LEADCOMP.EXE LEADECOM.C LEADECOM.EXE) are all included. You may not distribute\n");
  53.      printf("any of the files separately.\n");
  54.      printf("If you do not have the above list of files please contact LEAD Technologies \n");
  55.      printf("Inc. for the complete list.\n");
  56.      printf("All .EXE programs are not designed as end user products.  They all are a quick\n");
  57.      printf("collection of calls to LEADTOOLS functions.  Menus were not included to avoid\n");
  58.      printf("confusion when evaluating the code as to the processing calls verses the\n");
  59.      printf("menuing code..........................PRESS ANY KEY TO CONTINUE.\n");
  60.      L_SleepKey(20);
  61.      printf("\nDOS - File to screen software deompression utility Version 4.0\n");
  62.      printf("USEAGE: LEADSHOW <source file> [/option1] [/option2] [/option3] [/option4]\n\n");
  63.      printf("<source file> is any LEAD, JFIF, or JTIF compressed file formats\n");
  64.      printf("              or TGA, TIFF, PCX, GIF, BMP image file formats\n");
  65.      printf("[option1] /TA for TARGA16, TARGA24, or TARGA32\n");
  66.      printf(" or       /V320  display to FAST SUPER VGA 320X200\n");
  67.      printf("          /V640  display to FAST SUPER VGA 640X480\n");
  68.      printf("          /V800  display to FAST SUPER VGA 800X600\n");
  69.      printf("          /V1024 display to FAST SUPER VGA 1024X768\n");
  70.      printf("[option2] /T# number of seconds to keep image displayed on the screen\n");
  71.      printf("[option3] /X# the X (horizontal) position of the image displayed on the screen\n");
  72.      printf("[option4] /Y# the Y (vertical) position of the image displayed on the screen\n\n");
  73.      printf("EXAMPLE LEADSHOW *.* /T4 /X20 /Y20\n");
  74.      printf("Will display all image files to the VGA/SuperVGA screen at the best resolution\nfor the selected image file\n");
  75.      exit(0);
  76.   }
  77.  
  78.  
  79.   for (i = 2; i<=argc; i++)
  80.    {
  81.       strupr(argv[i]);
  82.       if(argv[i][0]=='/')
  83.          if(get_value(&argv[i][1])==BAD_COMMAND)
  84.            {
  85.              printf("COPYRIGHT (C) LEAD Technologies, Inc. 1991,1992 ALL RIGHTS RESERVED.\n");
  86.              printf("              8701 Mallard Creek Rd.\n");
  87.              printf("              Charlotte NC 28262\n");
  88.              printf("              tel# (704)549-5532\n");
  89.              L_SleepKey(1);
  90.              printf("\nDOS - File to screen software deompression utility Version 4.0\n");
  91.              printf("USEAGE: LEADSHOW <source file> [/option1] [/option2] [/option3] [/option4]\n\n");
  92.              printf("<source file> is any LEAD, JFIF, or JTIF compressed file formats\n");
  93.              printf("              or TGA, TIFF, PCX, GIF, BMP image file formats\n");
  94.              printf("[option1] /TA for TARGA16, TARGA24, or TARGA32\n");
  95.              printf(" or       /V320  display to FAST SUPER VGA 320X200\n");
  96.              printf("          /V640  display to FAST SUPER VGA 640X480\n");
  97.              printf("          /V800  display to FAST SUPER VGA 800X600\n");
  98.              printf("          /V1024 display to FAST SUPER VGA 1024X768\n");
  99.              printf("[option2] /T# number of seconds to keep image displayed on the screen\n");
  100.              printf("[option3] /X# the X (horizontal) position of the image displayed on the screen\n");
  101.              printf("[option4] /Y# the Y (vertical) position of the image displayed on the screen\n\n");
  102.              printf("EXAMPLE LEADSHOW *.* /T4 /X20 /Y20\n");
  103.              printf("Will display all image files to the VGA/SuperVGA screen at the best resolution\nfor the selected image file\n\n\n");
  104.              printf("BAD COMMAND %s\n",argv[i-1]);
  105.               exit(0);
  106.            }
  107.    }
  108.    get_pathname(argv[1], pathname);
  109.    result = _dos_findfirst(argv[1], 0 , &file);
  110.    if (result)   /* if result has any value rather that 0 then  */
  111.       printf("LEADSHOW: no such file %s\n",argv[1]);
  112.    else
  113.       while(!result)  /* Stop when _dos_findnext returns */
  114.        {
  115.           strcpy(infile, pathname);
  116.           strcat(infile, file.name);
  117.           if (L_FileInfo(infile, &FileInformation)==SUCCESS)
  118.            {
  119.               if(video==VGA)
  120.                {
  121.                   L_SetVideoMode(mode,page);
  122.                   printf("COPYRIGHT (C) LEAD Technologies, Inc. 1991,1992 ALL RIGHTS RESERVED.\n");
  123.                   printf("              8701 Mallard Creek Rd.\n");
  124.                   printf("              Charlotte NC 28262\n");
  125.                   printf("              tel# (704)549-5532\n");
  126.                   printf("\nDOS - File to screen software deompression utility Version 4.0\n");
  127.                   printf("Viewing image file %s to VGA screen", infile);
  128.                   if( FileInformation.Format == FILE_TGA)
  129.                    {
  130.                       error=L_ShowTGAScreen(infile,Width,Hight,Xorigin,Yorigin);
  131.                    }
  132.                   else if( FileInformation.Format == FILE_TIF)
  133.                    {
  134.                       error=L_ShowTIFScreen(infile,Width,Hight,Xorigin,Yorigin);
  135.                    }
  136.                   else if( FileInformation.Format == FILE_BMP)
  137.                    {
  138.                       error=L_ShowBMPScreen(infile,Width,Hight,Xorigin,Yorigin);
  139.                    }
  140.                   else if( FileInformation.Format == FILE_OS2)
  141.                    {
  142.                       error=L_ShowBMPScreen(infile,Width,Hight,Xorigin,Yorigin);
  143.                    }
  144.                   else if( FileInformation.Format == FILE_PCX)
  145.                    {
  146.                       error=L_ShowPCXScreen(infile,Width,Hight,Xorigin,Yorigin);
  147.                    }
  148.                   else if( FileInformation.Format == FILE_GIF)
  149.                    {
  150.                       error=L_ShowGIFScreen(infile,Width,Hight,Xorigin,Yorigin);
  151.                    }
  152.                   else if( FileInformation.Format == FILE_CMP)
  153.                    {
  154.                       error=L_DecompressVGAScreen(infile,Xorigin,Yorigin);
  155.                    }
  156.                   else if( FileInformation.Format == FILE_JFIF)
  157.                    {
  158.                       error=L_DecompressVGAScreen(infile,Xorigin,Yorigin);
  159.                    }
  160.                   else if( FileInformation.Format == FILE_JTIF)
  161.                    {
  162.                       error=L_DecompressVGAScreen(infile,Xorigin,Yorigin);
  163.                    }
  164.             
  165.                  if(error==SUCCESS)
  166.                   {
  167.                      L_SleepKey(time);
  168.                   }
  169.                  else
  170.                    {
  171.                       printf("COPYRIGHT (C) LEAD Technologies, Inc. 1991,1992 ALL RIGHTS RESERVED.\n");
  172.                       printf("              8701 Mallard Creek Rd.\n");
  173.                       printf("              Charlotte NC 28262\n");
  174.                       printf("              tel# (704)549-5532\n");
  175.                       printf("\nDOS - File to screen software deompression utility Version 4.0\n");
  176.                       printf("ERROR %d VIEWING IMAGE FILE %s\n",error,file.name);
  177.                       l_SleepKey(2);
  178.                    }
  179.               }
  180.               else if(video==TARGAOLD)
  181.                {
  182.                  printf("COPYRIGHT (C) LEAD Technologies, Inc. 1991,1992 ALL RIGHTS RESERVED.\n");
  183.                  printf("              8701 Mallard Creek Rd.\n");
  184.                  printf("              Charlotte NC 28262\n");
  185.                  printf("              tel# (704)549-5532\n");
  186.                  printf("\nDOS - File to screen software deompression utility Version 4.0\n");
  187.                  printf("Viewing image file %s to TARGA screen",file.name);
  188.                  if( FileInformation.Format == FILE_TGA)
  189.                   {
  190.                      error=L_ShowTGATarga(infile,Width,Hight,Xorigin,Yorigin);
  191.                   }
  192.                  else if( FileInformation.Format == FILE_TIF)
  193.                   {
  194.                      error=L_ShowTIFTarga(infile,Width,Hight,Xorigin,Yorigin);
  195.                   }
  196.                  else if( FileInformation.Format == FILE_BMP)
  197.                   {
  198.                      error=L_ShowBMPTarga(infile,Width,Hight,Xorigin,Yorigin);
  199.                   }
  200.                  else if( FileInformation.Format == FILE_OS2)
  201.                   {
  202.                      error=L_ShowBMPTarga(infile,Width,Hight,Xorigin,Yorigin);
  203.                   }
  204.                  else if( FileInformation.Format == FILE_PCX)
  205.                   {
  206.                      error=L_ShowPCXTarga(infile,Width,Hight,Xorigin,Yorigin);
  207.                   }
  208.                  else if( FileInformation.Format == FILE_GIF)
  209.                   {
  210.                      error=L_ShowGIFTarga(infile,Width,Hight,Xorigin,Yorigin);
  211.                   }
  212.                  else if( FileInformation.Format == FILE_CMP)
  213.                   {
  214.                      error=L_DecompressTARGAScreen(infile,Xorigin,Yorigin);
  215.                   }
  216.                  else if( FileInformation.Format == FILE_JFIF)
  217.                   {
  218.                      error=L_DecompressTARGAScreen(infile,Xorigin,Yorigin);
  219.                   }
  220.                  else if( FileInformation.Format == FILE_JTIF)
  221.                   {
  222.                      error=L_DecompressTARGAScreen(infile,Xorigin,Yorigin);
  223.                   }
  224.             
  225.                 if(error==SUCCESS)
  226.                   L_SleepKey(time);
  227.                 else
  228.                   {
  229.                      printf("COPYRIGHT (C) LEAD Technologies, Inc. 1991,1992 ALL RIGHTS RESERVED.\n");
  230.                      printf("              8701 Mallard Creek Rd.\n");
  231.                      printf("              Charlotte NC 28262\n");
  232.                      printf("              tel# (704)549-5532\n");
  233.                      printf("\nDOS - File to screen software deompression utility Version 4.0\n");
  234.                      printf("ERROR %d VIEWING IMAGE FILE %s\n",error,file.name);
  235.                      l_SleepKey(2);
  236.                   }
  237.                }
  238.               L_SetVideoMode(mode,page);
  239.            }
  240.           else
  241.            {
  242.               L_SetVideoMode(mode,page);
  243.               printf("COPYRIGHT (C) LEAD Technologies, Inc. 1991,1992 ALL RIGHTS RESERVED.\n");
  244.               printf("              8701 Mallard Creek Rd.\n");
  245.               printf("              Charlotte NC 28262\n");
  246.               printf("              tel# (704)549-5532\n");
  247.               printf("\nDOS - File to screen software deompression utility Version 4.0\n");
  248.               printf("ERROR %d VIEWING IMAGE FILE %s\n",error,file.name);
  249.               printf("LEADSHOW: error opening file %s\n",file.name);
  250.               putch(7);
  251.            }
  252.          result = _dos_findnext(&file);
  253.        }
  254. }
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262. get_value(char *string)
  263. {
  264.  int ret=OK;
  265.  
  266.  if (string[0] == 'X')
  267.   {
  268.      Xorigin = atoi(string+1);
  269.      if (Xorigin <= 0 || Xorigin > 1024)
  270.         return(BAD_COMMAND);
  271.      else
  272.         return(ret);
  273.   }
  274.  
  275.  if (string[0] == 'Y')
  276.   {
  277.      Yorigin = atoi(string+1);
  278.      if (Yorigin <= 0 || Yorigin > 1024)
  279.         return(BAD_COMMAND);
  280.      else
  281.         return(ret);
  282.   }
  283.  
  284.  if (string[0] == 'T' && string[1] != 'A')
  285.   {
  286.      time = atoi(string+1);
  287.      if (time < 0)
  288.         return(BAD_COMMAND);
  289.      else
  290.         return(ret);
  291.   }
  292.  
  293.  if (string[0] == 'T' && string[1] == 'A')
  294.   {
  295.      video=TARGAOLD;
  296.      if(L_TARGAInit()==0)
  297.       {
  298.          printf("TARGA Initialization error\n\n");
  299.          exit(0);
  300.       }
  301.   }
  302.  
  303.  
  304.  if(string[0] == 'V')
  305.   {
  306.      video=VGA;
  307.      if(strstr(string,"V320"))
  308.         L_SetVGASize(SIZE_320x200);
  309.      else if(strstr(string,"V640"))
  310.         L_SetVGASize(SIZE_640x480);
  311.      else if(strstr(string,"V800"))
  312.         L_SetVGASize(SIZE_800x600);
  313.      else if(strstr(string,"V1024"))
  314.         L_SetVGASize(SIZE_1024x768);
  315.   }
  316.  return(ret);
  317. }
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328. get_pathname(char in[], char pathname[])
  329. {
  330.  int i;
  331.  
  332.  strcpy(pathname, in);
  333.  for (i = strlen(in)-1; i >= 0; i--)
  334.   {
  335.     if( (in[i] == '\\') || (in[i] == ':') )
  336.       break;
  337.   }
  338.  
  339.  if (i == 0)
  340.     pathname[0] = 0;
  341.  else
  342.     pathname[i+1] = 0;
  343. }
  344.