home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / vc / pro16 / demo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-24  |  137.0 KB  |  2,840 lines

  1. /*****************************************************************************
  2.  *  Last Modified:  12/1/92                                                   *
  3.  *  Filenanme   : DEMO.C                                                     *
  4.  *                 This is an example program that demonstrates some         *
  5.  *                 of the most commonly called LEADTOOLS functions.          *
  6.  *                 and use LEADTOOLS compression/decompression,              *
  7.  *                 viewing, conversion, and all the BitMap load, flip,       *
  8.  *                 reverse functions for both TARGA and VGA/SuperVGA         *
  9.  *                 graphics card.                                            *
  10.  *                                                                           *
  11.  *                 This example uses both TARGA and VGA display in the same  *
  12.  *                 program. If your application uses only the TARGA display  *
  13.  *                 then do not use the L_Load???Screen() functions (where    *
  14.  *                 ??? is the file format). Also, if you are writing only    *
  15.  *                 for VGA display, then do not use the L_Load???Targa()     *
  16.  *                 functions. If both are used, then the EXE file will be    *
  17.  *                 larger than necessary since these routine are not         *
  18.  *                 applicable to the hardware.                               *
  19.  *                                                                           *
  20.  ****************************************************************************/
  21.  
  22. #include  <ctype.h>                /* Standard C header files */
  23. #include  <conio.h>
  24. #include  <stdio.h>
  25. #include  <stdlib.h>
  26. #include  <string.h>
  27.  
  28. /********* INCLUDES  *********/
  29. #include  ".\include\l_toolap.h"             /* Application tools for the toolkit */
  30. #include  ".\include\l_error.h"              /* Error return codes                */
  31. #include  ".\include\l_bitmap.h"             /* Bitmap file information           */
  32.  
  33.  
  34. #if __BORLANDC__
  35.     extern unsigned _stklen = 14000U;
  36. #endif
  37.  
  38. /* A define used in get_qfactor for transforming the characters typed for
  39. LEAD's Compression formats enhanced options to their equivalent
  40. integer defines. */
  41.  
  42. #define NUMEXTENSIONS 9
  43. #define XCHR 8
  44. #define YCHR 18
  45.  
  46. /*********************** Global Variables ***********************/
  47.  
  48. char TEXTP[200]; /* TEXT for the print functions*/
  49.  
  50. /********************** Decalare Functions ********************/
  51. int get_qfactor(char *string);     /* Convert the characters typed for the
  52.                                       ImageQfactor to the equivalent integer
  53.                                       defines. */
  54. int video_size;      /* Select a video mode */
  55. int device_bits;
  56.  
  57. void printscreen(void);            /* Prints the user input screen */
  58. void getint(int *, int, int);                /* Gets an integer from the keyboard*/
  59. void getstring(char *,int ,int);      /* Gets a string from the keyboard*/
  60. void ClearTheScreen(void);         /* Blanks the screen                    */
  61. void main(int argc, char *argv[]);
  62.  
  63.  
  64. /****************************************************************************
  65.  *                                main()                                    *
  66.  ****************************************************************************/
  67. void main(int argc, char *argv[])
  68. {
  69.   int TARGA_FLAG;       /* Flag used to verify if a TARGA board is present */
  70.   int function_type;    /* Switch to determine which function to call      */
  71.   int ret;              /* Function return values                          */
  72.   int videotype;        /* To determine the VGA/SuperVGA graphics card type */
  73.   int width;            /* Image width       */
  74.   int height;           /* Image height      */
  75.   int BitsPerPixel;     /* As it says        */
  76.   int alloc_bitmap = 0; /* Flag to determine if there is a BitMap allocated
  77.                            in memory                                       */
  78.  
  79.   int compress_format; /* Compression method to be used, either
  80.                           LEAD, JFIF, or JTIF */
  81.   int qfactor;         /* To determine the degree of compression for
  82.                           CMP, JFIF and JTIF */
  83.  
  84.   int new_width,       /* For resizing an image */
  85.       new_height; 
  86.   int xpos, ypos;      /* For viewing image at different locations on
  87.                           the screen */
  88.   int save_palette;    /* Flag for saving the VGA palette in a compressed
  89.                           file or not */
  90.   int output_format;   /* For saving an image into the desired file format */
  91.   int TIFCMP;          /* to save tif as LZW or uncompressed */
  92.   int video_memory;    /* Amount of video memory in KBytes
  93.                           available in the VGA/SuperVGA card */
  94.   int input_format;    /* For selecting the input file format in the
  95.                           file to file conversion process */
  96.   int intinput;            /* value for input bits/pxel */
  97.   char input_filename[160], /* Strings for input and output DOS file names */
  98.        output_filename[160];
  99.  
  100.   char compress_qfactor[100]; /* String for entering compression Q factor */
  101.   
  102.   BITMAPHANDLE Bitmap;    /* The main BITMAPHANLE used in the program */
  103.   BITMAPHANDLE NewBitmap; /* A BitMap handle used for the resizing,
  104.                              optimizing, and viewing functions */
  105.   FILEINFO     FileInfo;  /* Structure that L_FileInfo will fill to return
  106.                              important information about an image file */
  107.  
  108.   int format; /* used for BMP windows or PM */
  109.   int i;
  110.   char path[200];
  111.  
  112. #ifdef FOR_TEST
  113.    int port;
  114.    FILE far *Stream;
  115. #endif
  116.  
  117.   strcpy(path, argv[0]);
  118.  
  119.   for (i = strlen(path)-1; i > 0; i--)
  120.    {
  121.    if (path[i] == '\\' || path[i] == ':')
  122.       break;
  123.    }
  124.      path[i+1] = 0;
  125.   i=0;
  126.  
  127.  
  128.   /* Initialize the TARGA graphics environment. This function must be called
  129.      before any other function to communicate with the TARGA. */
  130.   if (L_TARGAInit() <= 0)
  131.       {
  132.        puts("TARGA board initialization error or TARGA not present!");
  133.        puts("You Can Use you SVGA Display.");
  134.        puts("But Do not attempt to use any of the TARGA functions!");
  135.        putch(7);
  136.        L_SleepKey(3);
  137.        TARGA_FLAG=0;
  138.       }
  139.       else
  140.         TARGA_FLAG=1;
  141.  
  142.     L_GetVideoInfo(&videotype, &width, &height);
  143.     if (videotype != VIDEO_SVGA)
  144.      {
  145.       printf("You must have a SuperVGA with 512K or more memory to run this demo\n");
  146.       exit(0);
  147.      }
  148.  
  149.    L_SetVGASize(SIZE_640x480);
  150.    L_GetVideoDeviceBits(&device_bits);
  151.    L_SetVGAPalette(RGBFixedPalette);
  152.  
  153.    L_SetCompressFormatJFIFCMP();
  154.    L_SetCompressFormatJTIF();
  155.    L_SetDecompressFormatJTIF();
  156.    L_SetDecompressFormatJFIFCMP();
  157.  
  158.     for(;;)       /* Loops until user enters 100 to exit program */
  159.         {
  160.          printscreen();                              
  161.  
  162.          getint(&function_type,39,9);    /* Get user input                  */
  163.  
  164.          switch (function_type)     /* Main switch on user's input     */
  165.          {
  166.           case 1:/* Case load TGA file to a BitMap           */
  167.                  /* If a BitMap exists we need to free it    */
  168.  
  169.                    if (alloc_bitmap == 1)
  170.                    {
  171.                     L_FreeBitmap( &Bitmap );
  172.                     alloc_bitmap = 0;
  173.                    }
  174.                   /*Font,   vertical,      text,     for color,  back color, X, Y*/
  175.                    L_GraphText( FONT8X16, 0,"Input file name: ", WHITE, RED, 5, 9);
  176.                    getstring(input_filename,18,9);
  177.                    /* Load the TGA filename directly into the BitMap handle.*/
  178.                    if ( (ret=L_LoadTGATarga( input_filename,
  179.                                              &Bitmap,OUTPUT_BITMAP,
  180.                                              TYPE_NOCONV, 0, 0 )) == SUCCESS )
  181.                    { /* It alocated a BitMap sucessfully */
  182.                      alloc_bitmap = 1;
  183.                      sprintf(TEXTP,"%s loaded to the BitMap. Press any key to continue.",input_filename);
  184.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  185.                    }
  186.                    else 
  187.                    { /* An error occured while loading the TGA file */
  188.                      sprintf(TEXTP,"Error: %d loading TGA to BitMap. Press any key to continue.", ret);
  189.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  190.                      putch(7);
  191.                    }
  192.           break;
  193.  
  194.           case 2:/* Case save a BitMap to TGA file */
  195.                  /* Make sure BitMap is being used and filled with image data */
  196.                  if (alloc_bitmap == 1)
  197.                   {
  198.                     sprintf(TEXTP,"Output file name: ");
  199.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  200.                     getstring(output_filename,19,9);
  201.                     sprintf(TEXTP,"BitsPerPixel (8, 16, 24 or 32): ");
  202.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  203.                     getint(&BitsPerPixel,33,9);
  204.                     /* Save the image Data in BitMap to a TGA file */
  205.                     if ( (ret=L_SaveTGABitmap( output_filename,
  206.                                                &Bitmap,BitsPerPixel )) == SUCCESS )
  207.                      {
  208.                       sprintf(TEXTP,"%s saved OK.  Press any key to continue.",output_filename);
  209.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  210.                      }
  211.                      else
  212.                      { /* Error saving the TGA BitMap to the file */
  213.                       sprintf(TEXTP,"Error: %d saving BitMap to TGA. Press any key to continue.", ret);
  214.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  215.                       putch(7);
  216.                      }
  217.                   }
  218.                   else
  219.                    { /* Trying to save an empty BitMap */
  220.                      sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
  221.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  222.                      putch(7);
  223.                     }
  224.           break;
  225.  
  226.           case 3:/* Case load a PCX file to the BitMap */
  227.                  /* Make sure BitMap used and is filled with image */
  228.                  if (alloc_bitmap == 1)
  229.                   {
  230.                    L_FreeBitmap( &Bitmap );
  231.                    alloc_bitmap = 0;
  232.                   }
  233.                   sprintf(TEXTP,"Input file name: ");
  234.                   L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  235.                   getstring(input_filename,18,9);
  236.                   /* Load the PCX filename directly into the BitMap handle.*/
  237.                   if ( (ret=L_LoadPCXScreen( input_filename,
  238.                                              &Bitmap, OUTPUT_BITMAP,
  239.                                              TYPE_NOCONV, 0, 0 )) == SUCCESS )
  240.                    {/* If the PCX file was successfuly loaded to the BitMap */
  241.                      alloc_bitmap = 1;
  242.                      sprintf(TEXTP,"%s loaded to BitMap. Press any key to continue.",input_filename);
  243.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  244.                    }
  245.                   else
  246.                    {
  247.                     sprintf(TEXTP,"Error: %d loading PCX to BitMap. Press any key to continue.", ret);
  248.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  249.                     putch(7);
  250.                    }
  251.           break;
  252.  
  253.           case 4:/* Case save a BitMap to a PCX file */
  254.                  /* Make sure BitMap is already being used and is filled with image data */
  255.                  if (alloc_bitmap == 1)
  256.                   {
  257.                    sprintf(TEXTP,"Output file name: ");
  258.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  259.                    getstring(output_filename,18,9);
  260.                    sprintf(TEXTP,"BitsPerPixel (1, 4, 8, or 24): ");
  261.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  262.                    getint(&BitsPerPixel,31,9);
  263.                    /* Save the image Data in BitMap to a PCX file*/
  264.                    if ( (ret=L_SavePCXBitmap( output_filename,&Bitmap,
  265.                                               BitsPerPixel )) == SUCCESS )
  266.                     {
  267.                       sprintf(TEXTP,"%s saved OK.  Press any key to continue.",output_filename);
  268.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  269.                     }
  270.                    else
  271.                     {
  272.                      sprintf(TEXTP,"Error: %d saving BitMap to PCX. Press any key to continue.", ret);
  273.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  274.                      putch(7);
  275.                     }
  276.                   }
  277.                  else
  278.                   {  /* Trying to save an empty BitMap */
  279.                    sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
  280.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  281.                    putch(7);
  282.                   }
  283.           break;
  284.  
  285.           case 5:/* Case Load GIF to BitMap */
  286.                  /* If a BitMap is already being used we need to free it */
  287.                  if (alloc_bitmap == 1)
  288.                   {
  289.                    L_FreeBitmap( &Bitmap );
  290.                    alloc_bitmap = 0;
  291.                   }
  292.                   sprintf(TEXTP,"Input file name: ");
  293.                   L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  294.                   getstring(input_filename,18,9);
  295.                   /* Load a GIF file to a BitMap */
  296.                   if ( (ret=L_LoadGIFScreen( input_filename,
  297.                                              &Bitmap, OUTPUT_BITMAP,
  298.                                              TYPE_NOCONV, 0, 0 )) == SUCCESS )
  299.                    {
  300.                     alloc_bitmap = 1;
  301.                     sprintf(TEXTP,"%s loaded to BitMap. Press any key to continue.",input_filename);
  302.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  303.                    }
  304.                   else
  305.                    {
  306.                     sprintf(TEXTP,"Error: %d loading GIF to the BitMap. Press any key to continue.", ret);
  307.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  308.                     putch(7);
  309.                    }
  310.           break;
  311.  
  312.           case 6:/* Case save a BitMap as GIF file */
  313.                  /* Make sure BitMap is already being used and filled with image data */
  314.                  if (alloc_bitmap == 1)
  315.                   {
  316.                    sprintf(TEXTP,"Output file name: ");
  317.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  318.                    getstring(output_filename,18,9);
  319.                    /* Saving the BitMap to a GIF file */
  320.                    if ( (ret=L_SaveGIFBitmap( output_filename,
  321.                                              &Bitmap, 8 )) == SUCCESS )
  322.                     {
  323.                      sprintf(TEXTP,"%s saved OK.  Press any key to continue.",output_filename);
  324.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  325.                     }
  326.                    else
  327.                     {
  328.                      sprintf(TEXTP,"Error: %d saving the BitMap to GIF. Press any key to continue.", ret);
  329.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  330.                      putch(7);
  331.                     }
  332.                   }
  333.                  else
  334.                   {
  335.                    sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
  336.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  337.                    putch(7);
  338.                   }
  339.           break;
  340.  
  341.           case 7:/* Case Load a TIF file to a BitMap */
  342.                  /* If a BitMap is already being used free it */
  343.                  if (alloc_bitmap == 1)
  344.                   {
  345.                    L_FreeBitmap( &Bitmap );
  346.                    alloc_bitmap = 0;
  347.                   }
  348.                   sprintf(TEXTP,"Input file name: ");
  349.                   L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  350.                   getstring(input_filename,18,9);
  351.                   /* Load the TIF file to a BitMap */
  352.                  if ( (ret=L_LoadTIFScreen( input_filename, &Bitmap,
  353.                                             OUTPUT_BITMAP, TYPE_NOCONV, 0, 0 )) == SUCCESS )
  354.                   {
  355.                    alloc_bitmap = 1;
  356.                    sprintf(TEXTP,"%s loaded to BitMap. Press any key to continue.",input_filename);
  357.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  358.                   }
  359.                  else
  360.                   {
  361.                    sprintf(TEXTP,"Error: %d loading TIF to the BitMap. Press any key to continue.", ret);
  362.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  363.                    putch(7);
  364.                   }
  365.           break;
  366.  
  367.           case 8:/* Case save a BitMap to a TIF file */
  368.                  /* Make sure BitMap is already being used and is filled with image data */
  369.                  if (alloc_bitmap == 1)
  370.                   {
  371.                    sprintf(TEXTP,"Output file name: ");
  372.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  373.                    getstring(output_filename,18,9);
  374.                    sprintf(TEXTP,"BitsPerPixel (1, 8, 16, or 24): ");
  375.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  376.                    getint(&BitsPerPixel,32,9);
  377.                    sprintf(TEXTP,"Compression type: (0 Uncompressed) (1 LZW compressed): ");
  378.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  379.                    getint(&TIFCMP,57,9);
  380.                    /* Save the BitMap to a TIF file */
  381.                    if ( (ret=L_SaveTIFBitmap( output_filename, &Bitmap,
  382.                                               BitsPerPixel, TIFCMP)) == SUCCESS )
  383.                     {
  384.                      sprintf(TEXTP,"%s saved OK.  Press any key to continue.",output_filename);
  385.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  386.                     }
  387.                    else
  388.                     {
  389.                      sprintf(TEXTP,"Error: %d saving the BitMap to TIF. Press any key to continue.", ret);
  390.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  391.                      putch(7);
  392.                     }
  393.                   }
  394.                  else
  395.                   {
  396.                    sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
  397.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  398.                    putch(7);
  399.                   }
  400.           break;
  401.  
  402.           case 9:/* Case Load a BMP file to a BitMap */
  403.                  /* If a BitMap is already being used free it */
  404.                  if (alloc_bitmap == 1)
  405.                   {
  406.                    L_FreeBitmap( &Bitmap );
  407.                    alloc_bitmap = 0;
  408.                   }
  409.                  sprintf(TEXTP,"Input file name: ");
  410.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  411.                  getstring(input_filename,18,9);
  412.                  /* Load a BMP file to the BitMap */
  413.                  if ( (ret=L_LoadBMPScreen( input_filename, &Bitmap,
  414.                                             OUTPUT_BITMAP, TYPE_NOCONV, 0, 0 )) == SUCCESS )
  415.                   {
  416.                    alloc_bitmap = 1;
  417.                    sprintf(TEXTP,"%s loaded to BitMap. Press any key to continue.",input_filename);
  418.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  419.                   }
  420.                  else
  421.                  {
  422.                   sprintf(TEXTP,"Error: %d loading BMP to the BitMap. Press any key to continue.", ret);
  423.                   L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  424.                   putch(7);
  425.                  }
  426.           break;
  427.  
  428.           case 10:/* Case save a BitMap to a BMP file */
  429.                   /* Make sure BitMap is already being used and is filled with image data */
  430.                   if (alloc_bitmap == 1)
  431.                    {
  432.                     sprintf(TEXTP,"Output file name: ");  
  433.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  434.                     getstring(output_filename,18,9);
  435.                     sprintf(TEXTP,"BitsPerPixel (4, 8, or 24): ");
  436.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  437.                     getint(&BitsPerPixel,29,9);
  438.                     sprintf(TEXTP,"type 0 for (WINDOWS BMP), or 1 for (PM BMP): ");
  439.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  440.                     getint(&format,46,9);
  441.                     if(format==0)
  442.                        format=TYPE_WIN;
  443.                     else if(format==1)
  444.                         format=TYPE_OS2;
  445.                      else
  446.                         {
  447.                          sprintf(TEXTP,"%d not a valid option",format);
  448.                          L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  449.                          getch();
  450.                          break;
  451.                         }
  452.                     /* Save the BitMap to a BMP file */
  453.                     if ( (ret=L_SaveBMPBitmap( output_filename,&Bitmap,
  454.                                              BitsPerPixel, format )) == SUCCESS )
  455.                      {
  456.                       sprintf(TEXTP,"%s saved OK.  Press any key to continue.",output_filename);
  457.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  458.                      }
  459.                     else
  460.                      {
  461.                       sprintf(TEXTP,"Error: %d saving the BitMap to BMP. Press any key to continue.", ret);
  462.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  463.                       putch(7);
  464.                      }
  465.                    }
  466.                   else
  467.                    {
  468.                     sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
  469.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  470.                     putch(7);
  471.                    }
  472.           break;
  473.  
  474.           case 11:/* Decompress a compressed file to a BitMap*/
  475.                   /* If a BitMap is already being used free it */
  476.                   if (alloc_bitmap == 1)
  477.                    {
  478.                     L_FreeBitmap( &Bitmap );
  479.                     L_InitBitmap( &Bitmap, 0, 0, 0);
  480.                     alloc_bitmap = 0;
  481.                    }
  482.                   sprintf(TEXTP,"Input file name: ");
  483.                   L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  484.                   getstring(input_filename,18,9);
  485.                   /* See if the file is a valid one */
  486.                   if (L_FileInfo(input_filename, &FileInfo) == SUCCESS)
  487.                    {
  488.                     if((FileInfo.Format != FILE_TIF) && (FileInfo.BitsPerPixel >= 8))
  489.                      {
  490.                       /* Decompress a LEAD, JTIF, or JFIF compressed file format
  491.                          directly to a BitMap*/
  492.                       if ( (ret=L_DecompressBitmap ( input_filename,
  493.                                                 &Bitmap, BIT24 )) == SUCCESS )
  494.                        {
  495.                         alloc_bitmap = 1;
  496.                         sprintf(TEXTP,"Image decompressed to a BitMap. Press any key to continue.");
  497.                         L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  498.                        }
  499.                       else
  500.                        {
  501.                         sprintf(TEXTP,"Error: %d Decompressing to the BitMap. Press any key to continue.", ret);
  502.                         L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  503.                         putch(7);
  504.                        }
  505.                      }
  506.                     else
  507.                      {
  508.                       if( L_DecompressBitmap1Bit(input_filename,&Bitmap) == SUCCESS)
  509.                        {
  510.                         alloc_bitmap = 1;
  511.                         sprintf(TEXTP,"Image decompressed to a BitMap. Press any key to continue.");
  512.                         L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  513.                        }
  514.                       else
  515.                        {
  516.                         sprintf(TEXTP,"Error: %d Decompressing to the BitMap. Press any key to continue.", ret);
  517.                         L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  518.                         putch(7);
  519.                        }
  520.                      }
  521.                    }
  522.                   else
  523.                    {
  524.                     /* not a valid file format */
  525.                     sprintf(TEXTP,"Invalid file format or file not found. Press any key to continue.");
  526.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  527.                    }
  528.           break;
  529.           
  530.           case 12:/* Case compress a BitMap to a compressed format */
  531.                   /* Make sure BitMap is already being used and is filled with image data */
  532.                   if (alloc_bitmap == 1)
  533.                    {
  534.                     sprintf(TEXTP,"Output file name: ");
  535.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  536.                     getstring(output_filename,18,9);
  537.                     if( Bitmap.BitsPerPixel > 1 )
  538.                        {
  539.                        sprintf(TEXTP,"0 LEAD, 1 JFIF, 2 JTIF, 3 LEAD1JFIF, 4 LEAD1JTIF, 5 LEAD2JFIF, 6 LEAD2JTF ?.");
  540.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  541.                        getint(&compress_format,77,9);
  542.                        sprintf(TEXTP,"Qfactor 1 to 255 or LEAD defined PQ1, PQ2, QFS, QMS, QS, SQS, SQT, MCQ, MC ");
  543.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  544.                        getstring(compress_qfactor,75,9);
  545.                        strupr(compress_qfactor);
  546.                        /* Check for a correct Qfactor entered */
  547.                        if ( (qfactor = get_qfactor(compress_qfactor)) == ERROR_QFACTOR)
  548.                         {
  549.                          sprintf(TEXTP,"Bad qfactor. Press any key to continue.");
  550.                          L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  551.                          putch(7);
  552.                          break;
  553.                         }
  554.                        /* If the user selected the LEAD compressed file format
  555.                           then ask to see if he/she would also like to save the
  556.                           VGA palette */
  557.                        if (compress_format != 0)
  558.                            save_palette = 0;
  559.                        else
  560.                         {
  561.                          sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
  562.                          L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  563.                          getint(&save_palette,36,9);
  564.                          while( (save_palette != 0) && (save_palette != 1) )
  565.                           {
  566.                            sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
  567.                            L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  568.                            getint(&save_palette,36,9);
  569.                           }
  570.                         }
  571.                        /* Compress the BitMap to a compressed file */
  572.                        if ( (ret = L_CompressBitmap ( &Bitmap,
  573.                                                    output_filename, compress_format,
  574.                                                    qfactor, save_palette )) == SUCCESS )
  575.                         {
  576.                          sprintf(TEXTP,"BitMap compressed. Press any key to continue.");
  577.                          L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  578.                         }
  579.                       }
  580.                    else /* If the bitmap is a 1Bit then you must use  L_CompressBitmap1Bit */
  581.                       {
  582.                        sprintf(TEXTP,"1 - CCITT, 2 - LEAD0, 3 - LEAD1, 10 - CCITTG31D, 11 - CCITTG32D, 12 - CCITTG4");
  583.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  584.                        getint(&compress_format,78,9);
  585.                        ret = L_CompressBitmap1Bit( &Bitmap, 
  586.                                                    output_filename, 
  587.                                                    compress_format ) ;
  588.                        sprintf(TEXTP,"BitMap compressed. Press any key to continue.");
  589.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  590.  
  591.                       }
  592.  
  593.                    if( ret != SUCCESS )
  594.                      {
  595.                       sprintf(TEXTP,"Error: %d compressing the BitMap. Press any key to continue.", ret);
  596.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  597.                       putch(7);
  598.                      }
  599.  
  600.                    }
  601.                   else
  602.                    {
  603.                     sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
  604.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  605.                     putch(7);
  606.                    }
  607.           break;
  608.  
  609.           case 13: /* Case Flip a BitMap */
  610.                    /* Flip vertical      */
  611.                    /* Make sure BitMap is already being used and is filled with image data */
  612.                    if ( alloc_bitmap == 0 )
  613.                     {
  614.                      sprintf(TEXTP,"Error: No storage has been allocated for a BitMap. Press any key to continue.");
  615.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  616.                      putch(7);
  617.                      break;
  618.                     }
  619.                     /* Flip an image in the BitMap (top to bottom) */
  620.                     if ( (ret = L_FlipBitmap( &Bitmap )) == SUCCESS)
  621.                      {
  622.                       sprintf(TEXTP,"Image fliped. Press any key to continue.");
  623.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  624.                      }
  625.                     else
  626.                      {
  627.                       sprintf(TEXTP,"Error: %d could not flip image. Press any key to continue.", ret);
  628.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  629.                       putch(7);
  630.                      }
  631.           break;
  632.  
  633.           case 14: /* Case reverse an image in a BitMap */
  634.                    /* Flip horizontal                   */
  635.                    /* Make sure BitMap is already being used and is filled with image data */
  636.                    if ( alloc_bitmap == 0 )
  637.                     {
  638.                      sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
  639.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  640.                      putch(7);
  641.                      break;
  642.                     }
  643.                     /* Reverse an image in a BitMap (left to right) */
  644.                     if ( (ret = L_ReverseBitmap( &Bitmap )) == SUCCESS)
  645.                      {
  646.                       sprintf(TEXTP,"Image reversed. Press any key to continue.");
  647.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  648.                      }
  649.                     else
  650.                      {
  651.                       sprintf(TEXTP,"Error: %d Reversing the image. Press any key to continue.", ret);
  652.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  653.                       putch(7);
  654.                      }
  655.           break;
  656.  
  657.          case 15: /* Case resize the image in the BitMap */
  658.                   /* Make sure BitMap is already being used and is filled with image data */
  659.                   if ( alloc_bitmap == 0 )
  660.                    {
  661.                     sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
  662.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  663.                     putch(7);
  664.                     break;
  665.                    }
  666.                    sprintf(TEXTP,"New BitMap width: ");
  667.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  668.                    getint(&new_width,19,9);
  669.                    sprintf(TEXTP,"New BitMap height: ");
  670.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  671.                    getint(&new_height,20,9);
  672.                   /* Will alocate room and initialize a new Bitmap while keeping
  673.                      the original BitMap. Then the original BitMap location is released. */
  674.                   /* Initialize fields in a BitMap handle.                       */
  675.                      L_InitBitmap( &NewBitmap, new_width, new_height,
  676.                                    Bitmap.BitsPerPixel ) ;
  677.           
  678.                   /* Allocate storage to hold an image in a BitMap handle.       */
  679.                   if ( (ret = L_AllocateBitmap( &NewBitmap,
  680.                                              TYPE_NOCONV   )) == SUCCESS )
  681.                    {
  682.                    /* Resizes image currently in BitMap handle, to the output BitMap
  683.                       handle. Since the new BitMap structure contains the new width
  684.                       and height just call L_ResizeBitmap()                      */
  685.                     if ( (ret = L_ResizeBitmap( &Bitmap, &NewBitmap ))
  686.                                                                   == SUCCESS )
  687.                      {
  688.                       L_FreeBitmap( &Bitmap );    /* Free the old BitMap */
  689.                       L_CopyBitmapHandle( &Bitmap, &NewBitmap ); /* Copy the old BitMap handle
  690.                                                                     to the new one */
  691.                       sprintf(TEXTP,"BitMap resized in NewBitMap.");
  692.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  693.                      }
  694.                     else
  695.                      {
  696.                       sprintf(TEXTP,"Error: %d Resizing the BitMap. Press any key to continue.", ret);
  697.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  698.                       putch(7);
  699.                      }
  700.                    }
  701.                   else
  702.                    {
  703.                     sprintf(TEXTP,"Error: %d Alloctating a new bitmap for resizing. Press any key to continue.", ret);
  704.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  705.                     putch(7);
  706.                   }
  707.          break;
  708.  
  709.         case 16: /* Rotate an image in a bitmap */
  710.                  if ( alloc_bitmap == 0 )
  711.                   {
  712.                    sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
  713.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  714.                    putch(7);
  715.                    break;
  716.                   }
  717.                  sprintf(TEXTP,"Rotate by (degrees):");
  718.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  719.                  getint( &xpos,21,3 ) ;
  720.                  sprintf(TEXTP,"Resize? (0=No, 1=Yes):");
  721.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  722.                  getint( &output_format,23,3 ) ;
  723.                  L_RotateBitmap( &Bitmap, xpos, output_format ) ;
  724.                  sprintf(TEXTP,"Bitmap Rotated! Press any key to continue.");
  725.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  726.         break;
  727.  
  728.          case 17: /* Case Dither an image for 256 colors LEAD's Fixed Palette  */
  729.                   /* Make sure BitMap is already being used and is filled with image data */
  730.                   if ( alloc_bitmap == 0 )
  731.                    {
  732.                     sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
  733.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  734.                     putch(7);
  735.                     break;
  736.                    }
  737.                    /* Make sure that the image needs to be optimized
  738.                       to 256 colors */
  739.                    if (Bitmap.BitsPerPixel >= 8)
  740.                     {
  741.                     /* Dither the bitmap to LEAD's 256 color Fixed palette */
  742.                     if ( L_LoadRGBFixedPalette(path) != SUCCESS)
  743.                       {
  744.                         sprintf(TEXTP,"Error: Can't load table FIXED.DAT.  Press any key to continue.", ret);
  745.                         L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  746.                         putch(7);
  747.                         break ;
  748.                       }
  749.  
  750.                      if ( (ret = L_DitherBitmap( &Bitmap, BURKES_DITHERING, 8 )) == SUCCESS)
  751.                       {
  752.                        sprintf(TEXTP,"Bitmap Ditherd OK.  Press any key to continue.");
  753.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  754.                        L_FreeRGBFixedPalette() ;
  755.                       }
  756.                      else
  757.                       {
  758.                        sprintf(TEXTP,"Error: %d Optimizing the BitMap.  Press any key to continue.", ret);
  759.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  760.                        L_FreeRGBFixedPalette() ;
  761.                        putch(7);
  762.                       }
  763.                     }
  764.                    else
  765.                     { /* You cannot Dither 4 bits/pixel image */
  766.                      sprintf(TEXTP,"Cannot Dither a %d bits/pixel BitMap. Press any key to continue.",Bitmap.BitsPerPixel);
  767.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,RED,9);
  768.                      putch(7);
  769.                     }
  770.          break;
  771.  
  772.          case 18: /* Case optimize an image for 256 colors */
  773.                   /* Make sure BitMap is already being used and is filled with image data */
  774.                   if ( alloc_bitmap == 0 )
  775.                    {
  776.                     sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
  777.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  778.                     putch(7);
  779.                     break;
  780.                    }
  781.                    /* Make sure that the image needs to be optimized
  782.                       to 256 colors */
  783.                    if (Bitmap.BitsPerPixel >= 16)
  784.                     {
  785.                     /* Selecting the best 256 colors to represent the image.
  786.                        This function will allocate and put the 256 color image
  787.                        in NewBitmap */
  788.                      if ( (ret = L_OptimizeBitmap ( &Bitmap, &NewBitmap, NO_DITHERING, 256 )) == SUCCESS)
  789.                       {
  790.                        /* Free the storage for the old BitMap */
  791.                        L_FreeBitmap( &Bitmap );    
  792.                        /* Copy the old BitMap handle to the new one */
  793.                        L_CopyBitmapHandle( &Bitmap, &NewBitmap );
  794.                        sprintf(TEXTP,"Bitmap optimized.  Press any key to continue.");
  795.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  796.                       }
  797.                      else
  798.                       {
  799.                        sprintf(TEXTP,"Error: %d Optimizing the BitMap.  Press any key to continue.", ret);
  800.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  801.                        putch(7);
  802.                       }
  803.                     }
  804.                    else
  805.                     { /* You cannot optimize 4 or 8 bits/pixel image */
  806.                      sprintf(TEXTP,"Cannot optimize a %d bits/pixel BitMap. Press any key to continue.",Bitmap.BitsPerPixel);
  807.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,RED,9);
  808.                      putch(7);
  809.                     }
  810.          break;
  811.  
  812.  
  813.  
  814.          case 19: /* Case clear a BitMap */
  815.                   /* Make sure BitMap is already being used and is filled with image data */
  816.                   if ( alloc_bitmap == 0 )
  817.                    {
  818.                     sprintf(TEXTP,"Error: No image in BitMap allocated. Press any key to continue.");
  819.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  820.                     putch(7);
  821.                     break;
  822.                    }
  823.                    /* Clear the BitMap and fill it with zeros */
  824.                    if ( (ret = L_ClearBitmap( &Bitmap )) == SUCCESS )
  825.                     {
  826.                      sprintf(TEXTP,"BitMap cleared and filled with zeros OK. Press any key to continue.");
  827.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  828.                     }
  829.                    else
  830.                     {
  831.                      sprintf(TEXTP,"Error: %d Clearing the BitMap. Press any key to continue.", ret);
  832.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  833.                      putch(7);
  834.                     }
  835.          break;
  836.  
  837.          case 20: /* Case change BitMap bosition */
  838.                   /* Make sure BitMap is already being used and is filled with image data */
  839.                   if ( alloc_bitmap == 0 )
  840.                    {
  841.                     sprintf(TEXTP,"Error: No image in BitMap allocated. Press any key to continue.");
  842.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  843.                     putch(7);
  844.                     break;
  845.                    }
  846.                    sprintf(TEXTP,"New BitMap X position: ");
  847.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  848.                    getint(&xpos,24,9);
  849.                    sprintf(TEXTP,"New BitMap Y position: ");
  850.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  851.                    getint(&ypos,24,9);
  852.                    /* Set new X, Y positions in a BitMap handle.
  853.                       The X and Y positions will be used as the starting
  854.                       offset when displaying this BitMap */
  855.                    L_SetBitmapPos( &Bitmap, xpos, ypos);
  856.                    sprintf(TEXTP,"Set BitMap position OK.  Press any key to continue.");
  857.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  858.          break;
  859.  
  860.          case 21: /* Case view BitMap to TARGA */
  861.                   /* Is a TARGA installed OK? */
  862.                  if (TARGA_FLAG)
  863.                   {
  864.                    /* Make sure BitMap is already being used and is filled with image data */
  865.                    if ( alloc_bitmap == 0 )
  866.                     {
  867.                      sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
  868.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  869.                      putch(7);
  870.                      break;
  871.                     }
  872.                     /* View the BitMap to the TARGA graphics adapter */
  873.                     if ( (ret = L_ViewBitmapTarga( &Bitmap, 0, 0 )) == SUCCESS )
  874.                      {
  875.                       sprintf(TEXTP,"BitMap viewed to TARGA successfully.  Press any key to continue.");
  876.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  877.                      }
  878.                     else
  879.                      {
  880.                       sprintf(TEXTP,"Error: %d viewing to the TARGA screen.  Press any key to continue.", ret);
  881.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  882.                       putch(7);
  883.                      }
  884.                   }
  885.                  else
  886.                   {
  887.                    sprintf(TEXTP,"Error: TARGA board initialization.  Press any key to continue.");
  888.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  889.                    putch(7);
  890.                   }
  891.          break;
  892.  
  893.          case 22: /* Case view a BitMap on the VGA/SuperVGA screen */
  894.                   /* Make sure BitMap is already being used and is filled with image data */
  895.                   if ( alloc_bitmap == 0 )
  896.                    {
  897.                     sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
  898.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  899.                     putch(7);
  900.                     break;
  901.                    }
  902.                    /* Make sure that the image has no more than 256 colors */
  903.                      sprintf(TEXTP,"New viewing screen width 0 for no resize: ");
  904.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  905.                      getint(&new_width,43,9);
  906.                      sprintf(TEXTP,"New viewing screen height 0 for no resize: ");
  907.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  908.                      getint(&new_height,43,9);
  909.                      /* View the BitMap with the new width and height.
  910.                         This will display the image with the new width and height
  911.                         but will not change the original BitMap's width and height */
  912.                     if( L_ViewBitmapScreen(&Bitmap,new_width,new_height) == ERROR_NOT_256_COLOR )
  913.                        {
  914.                        ClearTheScreen();
  915.                        sprintf(TEXTP,"This is a %d bit/pixel image containing more that 256 colors.", Bitmap.BitsPerPixel);
  916.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,480-YCHR);
  917.                        sprintf(TEXTP,"An 8bit VGA/SuperVGA card can only handle up to 256 colors.");
  918.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,480-(YCHR*2));
  919.                        sprintf(TEXTP,"To view this image you must first Dither the BitMap to LEAD's fixed palette.");
  920.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,480-(YCHR*3));
  921.                        sprintf(TEXTP,"This will convert the bitmap to LEAD's Fixed 256 color palette.");
  922.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,480-(YCHR*5));
  923.                        sprintf(TEXTP,"Or Optimize the the Bitmap to the best 256 colors to represent the image.");
  924.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,480-(YCHR*6));
  925.                        sprintf(TEXTP,"Press any key to continue.");
  926.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,480-(YCHR*7));
  927.                        putch(7);
  928.                        }
  929.          break;
  930.  
  931.          case 23: /* Case view TGA file to TARGA screen */
  932.                   /* Is a TARGA installed OK? */
  933.                   if (TARGA_FLAG)
  934.                    {
  935.                     sprintf(TEXTP,"Input file name: ");
  936.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  937.                     getstring(input_filename,18,9);
  938.                     sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
  939.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  940.                     getint(&xpos,56,9);
  941.                     sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
  942.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  943.                     getint(&ypos,56,9);
  944.                     sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
  945.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  946.                     getint(&width,52,9);
  947.                     sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
  948.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  949.                     getint(&height,52,9);
  950.                     if ( (ret = L_ShowTGATarga(input_filename,width,height,xpos, ypos)) ==SUCCESS)
  951.                      {
  952.                       sprintf(TEXTP,"%s successfully loaded to TARGA. Press any key to continue.",input_filename);
  953.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  954.                      }  
  955.                     else
  956.                      {
  957.                       sprintf(TEXTP,"Error: %d Viewing to the TARGA. Press any key to continue.", ret);
  958.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  959.                       putch(7);
  960.                      }
  961.                   }
  962.                  else
  963.                   {
  964.                    sprintf(TEXTP,"Error: TARGA board initialization.  Press any key to continue.");
  965.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  966.                    putch(7);
  967.                   }
  968.          break;
  969.  
  970.          case 24: /* Case view TGA file to VGA screen */
  971.                   sprintf(TEXTP,"Input file name: ");
  972.                   L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  973.                   getstring(input_filename,18,9);
  974.                   /* See if the file is a valid format and fill the FileInfo structure */
  975.                   if (L_FileInfo(input_filename, &FileInfo) == SUCCESS)
  976.                    {
  977.                     if (FileInfo.Format == FILE_TGA)
  978.                      {
  979.                       sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
  980.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  981.                       getint(&xpos,56,9);
  982.                       sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
  983.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  984.                       getint(&ypos,56,9);
  985.                       sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
  986.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  987.                       getint(&width,52,9);
  988.                       sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
  989.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  990.                       getint(&height,52,9);
  991.  
  992.                       if ( device_bits == 8 && L_LoadRGBFixedPalette(path) != SUCCESS)
  993.                          {
  994.                          sprintf(TEXTP,"Error: cannot load fixed palette data file FIXED.DAT.");
  995.                          L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  996.                          break ;
  997.                          }
  998.                       if ( (ret = L_ShowTGAScreen(input_filename,width,height,
  999.                                                             xpos, ypos)) == SUCCESS)
  1000.                        {
  1001.                         /* Displayed to VGA OK */
  1002.                         /*Free the RGB table from memory*/
  1003.                         if (device_bits == 8)
  1004.                            L_FreeRGBFixedPalette();
  1005.                        }
  1006.                       else
  1007.                        {
  1008.                         /*Free the RGB table from memory*/
  1009.                         if (device_bits == 8)
  1010.                            L_FreeRGBFixedPalette();
  1011.                         sprintf(TEXTP,"Error: %d viewing VGA. Press any key to continue.", ret);
  1012.                         L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1013.                         putch(7);
  1014.                        }
  1015.                      }  
  1016.                     else
  1017.                      {
  1018.                       sprintf(TEXTP,"Error: %s invalid TGA file format. Press any key to continue.", input_filename);
  1019.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1020.                       putch(7);
  1021.                      }
  1022.                    }
  1023.                   else
  1024.                    {
  1025.                       sprintf(TEXTP,"Error: %s not a supported file format. Press any key to continue.", input_filename);
  1026.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1027.                       putch(7);
  1028.                    }
  1029.          break;
  1030.  
  1031.          case 25: /* Case view PCX file to TARGA */
  1032.                   /* Is a TARGA installed OK */
  1033.                   if (TARGA_FLAG)
  1034.                    {
  1035.                     sprintf(TEXTP,"Input file name: ");
  1036.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1037.                     getstring(input_filename,18,9);
  1038.                     sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
  1039.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1040.                     getint(&xpos,56,9);
  1041.                     sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
  1042.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1043.                     getint(&ypos,56,9);
  1044.                     sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
  1045.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1046.                     getint(&width,52,9);
  1047.                     sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
  1048.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1049.                     getint(&height,52,9);
  1050.                     if ( (ret = L_ShowPCXTarga(input_filename,width,
  1051.                                                       height,xpos, ypos)) ==SUCCESS)
  1052.                      {
  1053.                       sprintf(TEXTP,"%s successfully loaded to TARGA. Press any key to continue.",input_filename);
  1054.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1055.                      }
  1056.                     else
  1057.                      {
  1058.                       sprintf(TEXTP,"Error: %d viewing to the TARGA. Press any key to continue.", ret);
  1059.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1060.                       putch(7);
  1061.                      }
  1062.                   }
  1063.                  else
  1064.                   {
  1065.                    sprintf(TEXTP,"Error: TARGA board initialization.  Press any key to continue.");
  1066.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1067.                    putch(7);
  1068.                   }
  1069.          break;
  1070.  
  1071.          case 26: /* Case view PCX file to VGA */
  1072.                   sprintf(TEXTP,"Input file name: ");
  1073.                   L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1074.                   getstring(input_filename,18,9);
  1075.                   sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
  1076.                   L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1077.                   getint(&xpos,56,9);
  1078.                   sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
  1079.                   L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1080.                   getint(&ypos,56,9);
  1081.                   sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
  1082.                   L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1083.                   getint(&width,52,9);
  1084.                   sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
  1085.                   L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1086.                   getint(&height,52,9);
  1087.                   if ( device_bits == 8 && L_LoadRGBFixedPalette(path) != SUCCESS)
  1088.                     {
  1089.                      sprintf(TEXTP,"Error: cannot load fixed palette data file FIXED.DAT.");
  1090.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1091.                      break ;
  1092.                     }
  1093.                   if ( (ret = L_ShowPCXScreen(input_filename,width,height,
  1094.                                                             xpos, ypos)) ==SUCCESS)
  1095.                    {
  1096.                     /* displayed to VGA OK */
  1097.                     /*Free the RGB Fixed Palette*/
  1098.                    if (device_bits == 8)
  1099.                       L_FreeRGBFixedPalette();
  1100.                    }
  1101.                   else
  1102.                    {
  1103.                     /*Free the RGB table from memory*/
  1104.                     if (device_bits == 8)
  1105.                        L_FreeRGBFixedPalette();
  1106.                     sprintf(TEXTP,"Error: %d viewing to VGA. Press any key to continue.", ret);
  1107.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1108.                     putch(7);
  1109.                    }
  1110.          break;
  1111.  
  1112.          case 27: /* Case view GIF file to TARGA */
  1113.                   /* Is a TARGA installed OK */
  1114.                   if (TARGA_FLAG)
  1115.                    {
  1116.                     sprintf(TEXTP,"Input file name: ");
  1117.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1118.                     getstring(input_filename,18,9);
  1119.                     sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
  1120.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1121.                     getint(&xpos,56,9);
  1122.                     sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
  1123.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1124.                     getint(&ypos,56,9);
  1125.                     sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
  1126.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1127.                     getint(&width,52,9);
  1128.                     sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
  1129.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1130.                     getint(&height,52,9);
  1131.                     if ( (ret = L_ShowGIFTarga(input_filename,width,height,
  1132.                                                             xpos, ypos)) ==SUCCESS)
  1133.                      {
  1134.                       sprintf(TEXTP,"%s successfully loaded to TARGA. Press any key to continue.",input_filename);
  1135.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1136.                      }
  1137.                     else
  1138.                      {
  1139.                       sprintf(TEXTP,"Error: %d viewing to TARGA. Press any key to continue.", ret);
  1140.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1141.                       putch(7);
  1142.                      }
  1143.                    }
  1144.                   else
  1145.                    {
  1146.                     sprintf(TEXTP,"Error: TARGA board initialization.  Press any key to continue.");
  1147.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1148.                     putch(7);
  1149.                    }
  1150.          break;
  1151.  
  1152.         case 28: /* Case view GIF to VGA */
  1153.                  sprintf(TEXTP,"Input file name: ");
  1154.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1155.                  getstring(input_filename,18,9);
  1156.                  sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
  1157.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1158.                  getint(&xpos,56,9);
  1159.                  sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
  1160.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1161.                  getint(&ypos,56,9);
  1162.                  sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
  1163.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1164.                  getint(&width,52,9);
  1165.                  sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
  1166.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1167.                  getint(&height,52,9);
  1168.                  if ( (ret = L_ShowGIFScreen(input_filename,width,height,
  1169.                                                          xpos, ypos)) ==SUCCESS)
  1170.                   {
  1171.                    /* displayed to VGA OK */
  1172.                   }
  1173.                  else
  1174.                   {
  1175.                    sprintf(TEXTP,"Error: %d viewing VGA. Press any key to continue.", ret);
  1176.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1177.                    putch(7);
  1178.                   }
  1179.         break;
  1180.  
  1181.         case 29: /* Case view TIF to TARGA */
  1182.                   /* Is a TARGA installed OK */
  1183.                   if (TARGA_FLAG)
  1184.                    {
  1185.                     sprintf(TEXTP,"Input file name: ");
  1186.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1187.                     getstring(input_filename,18,9);
  1188.                     sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
  1189.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1190.                     getint(&xpos,56,9);
  1191.                     sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
  1192.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1193.                     getint(&ypos,56,9);
  1194.                     sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
  1195.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1196.                     getint(&width,52,9);
  1197.                     sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
  1198.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1199.                     getint(&height,52,9);
  1200.                     if ( (ret = L_ShowTIFTarga(input_filename,width,height,
  1201.                                                             xpos, ypos)) ==SUCCESS)
  1202.                      {
  1203.                       sprintf(TEXTP,"%s successfully loaded to TARGA. Press any key to continue.",input_filename);
  1204.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1205.                      }
  1206.                     else
  1207.                      {
  1208.                       sprintf(TEXTP,"Error: %d viewing to the TARGA. Press any key to continue.", ret);
  1209.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1210.                       putch(7);
  1211.                      }
  1212.                    }
  1213.                   else
  1214.                    {
  1215.                     sprintf(TEXTP,"Error: TARGA board initialization.  Press any key to continue.");
  1216.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1217.                     putch(7);
  1218.                    }
  1219.         break;
  1220.  
  1221.         case 30: /* Case view TIF to VGA */
  1222.                  sprintf(TEXTP,"Input file name: ");
  1223.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1224.                  getstring(input_filename,18,9);
  1225.                  /* See if the file is a valid format and fill the FileInfo structure */
  1226.                   if (L_FileInfo(input_filename, &FileInfo) == SUCCESS)
  1227.                    {
  1228.                     if (FileInfo.Format == FILE_TIF)
  1229.                      {
  1230.                        sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
  1231.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1232.                        getint(&xpos,56,9);
  1233.                        sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
  1234.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1235.                        getint(&ypos,56,9);
  1236.                        sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
  1237.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1238.                        getint(&width,52,9);
  1239.                        sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
  1240.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1241.                        getint(&height,52,9);
  1242.                        if ( device_bits == 8 && L_LoadRGBFixedPalette(path) != SUCCESS)
  1243.                         {
  1244.                          sprintf(TEXTP,"Error: cannot load fixed palette data file FIXED.DAT .");
  1245.                          L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1246.                          break ;
  1247.                         }
  1248.                        if ( (ret = L_ShowTIFScreen(input_filename,width,height,
  1249.                                                              xpos, ypos)) ==SUCCESS)
  1250.                         {
  1251.                         /* Displayed to VGA OK */
  1252.                         /*Free the RGB table from memory*/
  1253.                         if (device_bits == 8)
  1254.                            L_FreeRGBFixedPalette();
  1255.                         }
  1256.                       else
  1257.                        {
  1258.                         /*Free the RGB table from memory*/
  1259.                         if (device_bits == 8)
  1260.                            L_FreeRGBFixedPalette();
  1261.                         sprintf(TEXTP,"Error: %d viewing VGA. Press any key to continue.", ret);
  1262.                         L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1263.                         putch(7);
  1264.                        }
  1265.                      }  
  1266.                     else
  1267.                      {
  1268.                       sprintf(TEXTP,"Error: %s Invalid TIF file format. Press any key to continue.",input_filename);
  1269.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1270.                       putch(7);
  1271.                      }
  1272.                    }
  1273.                   else
  1274.                    {
  1275.                      sprintf(TEXTP,"Error: %s not a supported file format. Press any key to continue.", input_filename);
  1276.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1277.                      putch(7);
  1278.                    }
  1279.         break;
  1280.  
  1281.         case 31: /* Case view BMP to TARGA */
  1282.                   /* Is a TARGA installed OK */
  1283.                   if (TARGA_FLAG)
  1284.                    {
  1285.                     sprintf(TEXTP,"Input file name: ");
  1286.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1287.                     getstring(input_filename,18,9);
  1288.                     sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
  1289.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1290.                     getint(&xpos,56,9);
  1291.                     sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
  1292.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1293.                     getint(&ypos,56,9);
  1294.                     sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
  1295.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1296.                     getint(&width,52,9);
  1297.                     sprintf(TEXTP,"Display height, or 0 for current Heigth in the file: ");
  1298.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1299.                     getint(&height,52,9);
  1300.                     if ( (ret = L_ShowBMPTarga(input_filename,width,height,
  1301.                                                             xpos, ypos)) ==SUCCESS)
  1302.                      {
  1303.                       sprintf(TEXTP,"%s successfully loaded to TARGA. Press any key to continue.",input_filename);
  1304.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1305.                      }
  1306.                     else
  1307.                      {
  1308.                       sprintf(TEXTP,"Error: %d viewing to the TARGA. Press any key to continue.", ret);
  1309.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1310.                       putch(7);
  1311.                      }
  1312.                    }
  1313.                   else
  1314.                    {
  1315.                     sprintf(TEXTP,"Error: TARGA board initialization. Press any key to continue.");
  1316.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1317.                     putch(7);
  1318.                    }
  1319.         break;
  1320.  
  1321.         case 32: /* Case view BMP to VGA */
  1322.                  sprintf(TEXTP,"Input file name: ");
  1323.                  L_GraphText(FONT8X16,0,TEXTP,WHITE,RED,0,9);
  1324.                  getstring(input_filename,18,9);
  1325.                  /* See if the file is a valid format and fill the FileInfo structure */
  1326.                   if (L_FileInfo(input_filename, &FileInfo) == SUCCESS)
  1327.                    {
  1328.                     if (FileInfo.Format == FILE_BMP)
  1329.                      {
  1330.                       sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
  1331.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1332.                       getint(&xpos,56,9);
  1333.                       sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
  1334.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1335.                       getint(&ypos,56,9);
  1336.                       sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
  1337.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1338.                       getint(&width,52,9);
  1339.                       sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
  1340.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1341.                       getint(&height,52,9);
  1342.                       if ( device_bits == 8 && L_LoadRGBFixedPalette(path) != SUCCESS)
  1343.                        {
  1344.                         sprintf(TEXTP,"Error: cannot load fixed palette data file FIXED.DAT.");
  1345.                         L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1346.                         break ;
  1347.                        }
  1348.                       if ( (ret = L_ShowBMPScreen(input_filename,width,height,
  1349.                                                             xpos, ypos)) ==SUCCESS)
  1350.                        {
  1351.                        /* Displayed to VGA OK */
  1352.                        /*Free the RGB table from memory*/
  1353.                        if (device_bits == 8)
  1354.                           L_FreeRGBFixedPalette();
  1355.                        }
  1356.                       else
  1357.                        {
  1358.                         /*Free the RGB table from memory*/
  1359.                         if (device_bits == 8)
  1360.                            L_FreeRGBFixedPalette();
  1361.                         sprintf(TEXTP,"Error: %d viewing VGA. Press any key to continue.", ret);
  1362.                         L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1363.                         putch(7);
  1364.                        }
  1365.                      }  
  1366.                     else
  1367.                      {
  1368.                       sprintf(TEXTP,"Error: %s invalid BMP file format. Press any key to continue.", input_filename);
  1369.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1370.                       putch(7);
  1371.                      }
  1372.                    }
  1373.                   else
  1374.                    {
  1375.                       sprintf(TEXTP,"Error: %s Not a supported file format. Press any key to continue.", input_filename);
  1376.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1377.                       putch(7);
  1378.                    }
  1379.         break;
  1380.  
  1381.         case 33: /* Case decompress or display a compressed file to TARGA screen */
  1382.                  /* Is a TARGA installed OK */
  1383.                  if (TARGA_FLAG)
  1384.                   {
  1385.                    sprintf(TEXTP,"Input file name: ");
  1386.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1387.                    getstring(input_filename,18,9);
  1388.                    sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
  1389.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1390.                    getint(&xpos,56,9);
  1391.                    sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
  1392.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1393.                    getint(&ypos,56,9);
  1394.                    if ( (ret = L_DecompressTARGAScreen(input_filename,
  1395.                                                          0, 0, xpos, ypos)) == SUCCESS)
  1396.                     {
  1397.                      sprintf(TEXTP,"Decompress %s to TARGA screen. Press any key to continue.",input_filename );
  1398.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1399.                     }
  1400.                    else
  1401.                     {
  1402.                      sprintf(TEXTP,"Error: %d Decompressing to TARGA. Press any key to continue.", ret);
  1403.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1404.                      putch(7);
  1405.                     }
  1406.                   }
  1407.                 else
  1408.                  {
  1409.                   sprintf(TEXTP,"Error: Cannot initialize TARGA board.  Press any key to continue.");
  1410.                   L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1411.                   putch(7);
  1412.                  }
  1413.         break;
  1414.  
  1415.         case 34: /* Decompress a compressed file to the VGA screen */
  1416.                  sprintf(TEXTP,"Input file name: ");
  1417.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1418.                  getstring(input_filename,18,9);
  1419.                  sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
  1420.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1421.                  getint(&xpos,56,9);
  1422.                  sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
  1423.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1424.                  getint(&ypos,56,9);
  1425.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1426.                  sprintf(TEXTP,"Display width, or 0 for current Width in the file:     ");
  1427.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1428.                  getint(&width,52,9);
  1429.                  sprintf(TEXTP,"Display height, or 0 for current Height in the file:   ");
  1430.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1431.                  getint(&height,52,9);
  1432.                  if (device_bits == 8)
  1433.                    {
  1434.                     /**** load the fixed palette table to memory ****/
  1435.                    if ( L_LoadFixedPalette(path) != SUCCESS)
  1436.                       {
  1437.                       sprintf(TEXTP,"Error: cannot load fixed palette data file FIXEDPAL.DAT.");
  1438.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1439.                       break ;
  1440.                       }
  1441.                    }
  1442.  
  1443.                  if ( (ret = L_DecompressVGAScreenFP(input_filename, width, height,xpos, ypos)) == SUCCESS)
  1444.                   {
  1445.                    /*free the fixed palette table FIXEDPAL.DAT*/
  1446.                    if (device_bits == 8)
  1447.                        L_FreeFixedPalette();
  1448.                    /* Decompression to VGA was OK */
  1449.                    ;
  1450.                   }
  1451.                 else
  1452.                  {
  1453.                   /*free the fixed palette table FIXEDPAL.DAT*/
  1454.                   if (device_bits == 8)
  1455.                      L_FreeFixedPalette();
  1456.                   sprintf(TEXTP,"Error: %d Decompressing to VGA. Press any key to continue.", ret);
  1457.                   L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1458.                   putch(7);
  1459.                  }
  1460.         break;
  1461.  
  1462.         case 35: /* Case compress TGA file */
  1463.                  sprintf(TEXTP,"Input file name: ");
  1464.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1465.                  getstring(input_filename,18,9);
  1466.                  sprintf(TEXTP,"Output file name: ");
  1467.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1468.                  getstring(output_filename,18,9);
  1469.                  sprintf(TEXTP,"0 LEAD, 1 JFIF, 2 JTIF, 3 LEAD1JFIF, 4 LEAD1JTIF, 5 LEAD2JFIF, 6 LEAD2JTF ?.");
  1470.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1471.                  getint(&compress_format,77,9);
  1472.                  sprintf(TEXTP,"Qfactor 1 to 255 or LEAD defined PQ1, PQ2, QFS, QMS, QS, SQS, SQT, MCQ, MC ");
  1473.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1474.                  getstring(compress_qfactor,75,9);
  1475.                  if (compress_format != 0)
  1476.                   save_palette = 0;
  1477.                  else
  1478.                   {
  1479.                    sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
  1480.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1481.                    getint(&save_palette,36,9);
  1482.                    while( (save_palette != 0) && (save_palette != 1) )
  1483.                     {
  1484.                      sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
  1485.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1486.                      getint(&save_palette,36,9);
  1487.                     }
  1488.                   }
  1489.                 strupr(compress_qfactor);
  1490.                 if ( (qfactor = get_qfactor(compress_qfactor)) == ERROR_QFACTOR)
  1491.                  {
  1492.                   sprintf(TEXTP,"Error: Bad qfactor. Press any key to continue.");
  1493.                   L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1494.                   putch(7);
  1495.                   break;
  1496.                  }
  1497.                 if ( (ret = L_CompressTGA(input_filename, output_filename, compress_format,
  1498.                                         qfactor, save_palette, 0)) == SUCCESS)
  1499.                  {
  1500.                   sprintf(TEXTP,"File: %s compressed to %s. Press any key to continue.",input_filename,output_filename);
  1501.                   L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1502.                  }
  1503.                 else
  1504.                  {
  1505.                   sprintf(TEXTP,"Error: %d compressing %s. Press any key to continue.", ret,input_filename);
  1506.                   L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1507.                   putch(7);
  1508.                  }
  1509.         break;
  1510.  
  1511.         case 36: /* Case decompress to TGA file */
  1512.                  sprintf(TEXTP,"Input file name: ");
  1513.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1514.                  getstring(input_filename,18,9);
  1515.                  sprintf(TEXTP,"Output file name: ");
  1516.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1517.                  getstring(output_filename,18,9);
  1518.                  sprintf(TEXTP,"Output format 1 - TGA8, 2 - TGA16, 3 - TGA24, 4 - TGA32: ");
  1519.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1520.                  getint(&intinput,58,9);
  1521.                  if(intinput==1)
  1522.                   {
  1523.                     if ( L_LoadRGBFixedPalette(path) != SUCCESS)
  1524.                      {
  1525.                        sprintf(TEXTP,"Error: Can't load FIXED.DAT fixed palette file.  Press any key to continue.", ret);
  1526.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1527.                        putch(7);
  1528.                        break ;
  1529.                      }
  1530.                    output_format=TGA8;
  1531.                   }
  1532.                  else if(intinput==2)
  1533.                    output_format=TGA16;
  1534.                  else if(intinput==3)
  1535.                    output_format=TGA24;
  1536.                  else if(intinput==4)
  1537.                    output_format=TGA32;
  1538.                  else
  1539.                    {
  1540.                       sprintf(TEXTP,"%d not a valid option",intinput);
  1541.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1542.                       getch();
  1543.                       break;
  1544.                    }
  1545.                  if ( (ret = L_DecompressTGA(input_filename, output_filename, output_format))
  1546.                                            == SUCCESS)
  1547.                   {
  1548.                    sprintf(TEXTP,"File: %s Decompressed to %s (TGA). Press any key to continue. ",input_filename,output_filename);
  1549.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1550.                    if(output_format==TGA8)
  1551.                      L_FreeRGBFixedPalette();
  1552.                   }
  1553.                  else
  1554.                   {
  1555.                    sprintf(TEXTP,"Error: %d Decompressing to TGA. Press any key to continue. ", ret);
  1556.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1557.                    if(output_format==TGA8)
  1558.                        L_FreeRGBFixedPalette();
  1559.                    putch(7);
  1560.                   }
  1561.         break;
  1562.  
  1563.         case 37: /* Case compress PCX file */
  1564.                  sprintf(TEXTP,"Input file name: ");
  1565.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1566.                  getstring(input_filename,18,9);
  1567.                  sprintf(TEXTP,"Output file name: ");
  1568.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1569.                  getstring(output_filename,18,9);
  1570.                  sprintf(TEXTP,"0 LEAD, 1 JFIF, 2 JTIF, 3 LEAD1JFIF, 4 LEAD1JTIF, 5 LEAD2JFIF, 6 LEAD2JTF ?.");
  1571.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1572.                  getint(&compress_format,77,9);
  1573.                  sprintf(TEXTP,"Qfactor 1 to 255 or LEAD defined PQ1, PQ2, QFS, QMS, QS, SQS, SQT, MCQ, MC ");
  1574.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1575.                  getstring(compress_qfactor,75,9);
  1576.                  if (compress_format != 0)
  1577.                   save_palette = 0;
  1578.                  else
  1579.                   {
  1580.                    sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
  1581.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1582.                    getint(&save_palette,36,9);
  1583.                    while( (save_palette != 0) && (save_palette != 1) )
  1584.                     {
  1585.                      sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
  1586.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1587.                      getint(&save_palette,36,9);
  1588.                     }
  1589.                   }
  1590.                  strupr(compress_qfactor);
  1591.                  if ( (qfactor = get_qfactor(compress_qfactor)) == ERROR_QFACTOR)
  1592.                   {
  1593.                    sprintf(TEXTP,"Error: Bad qfactor.");
  1594.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1595.                    break;
  1596.                   }
  1597.                  if ( (ret = L_CompressPCX(input_filename, output_filename, compress_format,
  1598.                                          qfactor, save_palette)) == SUCCESS)
  1599.                   {
  1600.                    sprintf(TEXTP,"File: %s compressed to %s. Press any key to continue.",input_filename,output_filename);
  1601.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1602.                   }
  1603.                  else
  1604.                   {
  1605.                    sprintf(TEXTP,"Error: %d compressing %s. Press any key to continue.", ret,input_filename);
  1606.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1607.                    putch(7);
  1608.                   }
  1609.         break;
  1610.    
  1611.         case 38: /* Case decompress to PCX file*/
  1612.                  sprintf(TEXTP,"Input file name: ");
  1613.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1614.                  getstring(input_filename,18,9);
  1615.                  sprintf(TEXTP,"Output file name: ");
  1616.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1617.                  getstring(output_filename,18,9);
  1618.                  sprintf(TEXTP,"Output format 1 - PCX8, 2 - PCX24: ");
  1619.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1620.                  getint(&intinput,38,9);
  1621.                  if(intinput==1)
  1622.                   {
  1623.                    if ( L_LoadRGBFixedPalette(path) != SUCCESS)
  1624.                     {
  1625.                       sprintf(TEXTP,"Error: Can't load FIXED.DAT fixed palette file.  Press any key to continue.", ret);
  1626.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1627.                       putch(7);
  1628.                       break ;
  1629.                     }
  1630.                    output_format=PCX8;
  1631.                   }
  1632.                  else if(intinput==2)
  1633.                    output_format=PCX24;
  1634.                  else
  1635.                    {
  1636.                       sprintf(TEXTP,"%d not a valid option",intinput);
  1637.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1638.                       getch();
  1639.                       break;
  1640.                    }
  1641.                  if ( (ret = L_DecompressPCX(input_filename, output_filename, output_format))
  1642.                       == SUCCESS)
  1643.                   {
  1644.                    sprintf(TEXTP,"%s Decompressed to %s (PCX). Press any key to continue. ",input_filename,output_filename);
  1645.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1646.                    if(output_format==PCX8)
  1647.                      L_FreeRGBFixedPalette();
  1648.  
  1649.                   }
  1650.                  else
  1651.                   {
  1652.                    sprintf(TEXTP,"Error: %d Decompressing to PCX. Press any key to continue. ", ret);
  1653.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1654.                    if( (output_format==PCX8) && (FileInfo.BitsPerPixel==8))
  1655.                      L_FreeFixedPalette();
  1656.                    else if(output_format==PCX8)
  1657.                      L_FreeRGBFixedPalette();
  1658.                    putch(7);
  1659.                   }
  1660.         break;
  1661.  
  1662.         case 39: /* Case compress GIF file */
  1663.                  sprintf(TEXTP,"Input file name: ");
  1664.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1665.                  getstring(input_filename,18,9);
  1666.                  sprintf(TEXTP,"Output file name: ");
  1667.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1668.                  getstring(output_filename,18,9);
  1669.                  sprintf(TEXTP,"0 LEAD, 1 JFIF, 2 JTIF, 3 LEAD1JFIF, 4 LEAD1JTIF, 5 LEAD2JFIF, 6 LEAD2JTF ?.");
  1670.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1671.                  getint(&compress_format,77,9);
  1672.                  sprintf(TEXTP,"Qfactor 1 to 255 or LEAD defined PQ1, PQ2, QFS, QMS, QS, SQS, SQT, MCQ, MC ");
  1673.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1674.                  getstring(compress_qfactor,75,9);
  1675.                  if (compress_format != 0)
  1676.                    save_palette = 0;
  1677.                  else
  1678.                   {
  1679.                    sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
  1680.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1681.                    getint(&save_palette,36,9);
  1682.                    while( (save_palette != 0) && (save_palette != 1) )
  1683.                     {
  1684.                      sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
  1685.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1686.                      getint(&save_palette,36,9);
  1687.                     }
  1688.                   }
  1689.                  strupr(compress_qfactor);
  1690.                  if ( (qfactor = get_qfactor(compress_qfactor)) == ERROR_QFACTOR)
  1691.                   {
  1692.                    sprintf(TEXTP,"Error: Bad qfactor. Press any key to continue.");
  1693.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1694.                    putch(7);
  1695.                    break;
  1696.                   }
  1697.                  if ( (ret = L_CompressGIF(input_filename, output_filename, compress_format,
  1698.                                          qfactor, save_palette)) == SUCCESS)
  1699.                   {
  1700.                    sprintf(TEXTP,"File: %s compressed to %s. Press any key to continue.",input_filename,output_filename);
  1701.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1702.                   }
  1703.                  else
  1704.                   {
  1705.                    sprintf(TEXTP,"Error: %d compressing %s. Press any key to continue.", ret,input_filename);
  1706.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1707.                    putch(7);
  1708.                   }
  1709.         break;
  1710.        
  1711.         case 40: /* Case decompress to GIF file */
  1712.                  sprintf(TEXTP,"Input file name: ");
  1713.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1714.                  getstring(input_filename,18,9);
  1715.                  sprintf(TEXTP,"Output file name: ");
  1716.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1717.                  getstring(output_filename,18,9);
  1718.                  if (L_FileInfo(input_filename, &FileInfo) == SUCCESS)
  1719.                   {
  1720.                    if ( L_LoadRGBFixedPalette(path) != SUCCESS)
  1721.                       {
  1722.                         sprintf(TEXTP,"Error: Can't load FIXED.DAT fixed palette file.  Press any key to continue.", ret);
  1723.                         L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1724.                         putch(7);
  1725.                         break ;
  1726.                       }
  1727.                    output_format=GIF8;
  1728.                   }
  1729.                  if ( (ret = L_DecompressGIF(input_filename, output_filename, output_format))
  1730.                             == SUCCESS)
  1731.                    {
  1732.                     sprintf(TEXTP,"File: %s decompressed to %s (GIF). Press any key to continue. ",input_filename,output_filename);
  1733.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1734.                     L_FreeRGBFixedPalette();
  1735.                    }
  1736.                   else
  1737.                    {
  1738.                     sprintf(TEXTP,"Error: %d Decompressing to GIF. Press any key to continue. ", ret);
  1739.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1740.                     L_FreeRGBFixedPalette();
  1741.                     putch(7);
  1742.                    }
  1743.         break;
  1744.  
  1745.         case 41: /* Case compress TIF file */
  1746.                  sprintf(TEXTP,"Input file name: ");
  1747.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1748.                  getstring(input_filename,18,9);
  1749.                  sprintf(TEXTP,"Output file name: ");
  1750.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1751.                  getstring(output_filename,18,9);
  1752.                  sprintf(TEXTP,"0 LEAD, 1 JFIF, 2 JTIF, 3 LEAD1JFIF, 4 LEAD1JTIF, 5 LEAD2JFIF, 6 LEAD2JTF ?.");
  1753.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1754.                  getint(&compress_format,77,9);
  1755.                  sprintf(TEXTP,"Qfactor 1 to 255 or LEAD defined PQ1, PQ2, QFS, QMS, QS, SQS, SQT, MCQ, MC ");
  1756.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1757.                  getstring(compress_qfactor,75,9);
  1758.                  if (compress_format != 0)
  1759.                    save_palette = 0;
  1760.                  else
  1761.                   {
  1762.                    sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
  1763.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1764.                    getint(&save_palette,36,9);
  1765.                    while( (save_palette != 0) && (save_palette != 1) )
  1766.                     {
  1767.                      sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
  1768.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1769.                      getint(&save_palette,36,9);
  1770.                     }
  1771.                   }
  1772.                  strupr(compress_qfactor);
  1773.                  if ( (qfactor = get_qfactor(compress_qfactor)) == ERROR_QFACTOR)
  1774.                   {
  1775.                    sprintf(TEXTP,"Error: Bad qfactor. Press any key to continue.");
  1776.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1777.                    break;
  1778.                   }
  1779.                  if ( (ret = L_CompressTIF(input_filename, output_filename, compress_format,
  1780.                                          qfactor, save_palette)) == SUCCESS)
  1781.                   {
  1782.                    sprintf(TEXTP,"File %s compressed to %s. Press any key to continue.",input_filename,output_filename);
  1783.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1784.                   }
  1785.                  else
  1786.                   {
  1787.                    sprintf(TEXTP,"Error: %d compressing %s. Press any key to continue.", ret,input_filename);
  1788.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1789.                    putch(7);
  1790.                   }
  1791.         break;
  1792.  
  1793.         case 42: /* Case decompress to a TIF file */
  1794.                  sprintf(TEXTP,"Input file name: ");
  1795.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1796.                  getstring(input_filename,18,9);
  1797.                  sprintf(TEXTP,"Output file name: ");
  1798.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1799.                  getstring(output_filename,18,9);
  1800.                  sprintf(TEXTP,"Output format 1 - TIF8, 2 - TIF16, 3 - TIF24: ");
  1801.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1802.                  getint(&intinput,47,9);
  1803.                  if(intinput==1)
  1804.                   {
  1805.                    if ( L_LoadRGBFixedPalette(path) != SUCCESS)
  1806.                       {
  1807.                         sprintf(TEXTP,"Error: Can't load FIXED.DAT fixed palette file.  Press any key to continue.", ret);
  1808.                         L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1809.                         putch(7);
  1810.                         break ;
  1811.                       }
  1812.                    output_format=TIF8;
  1813.                   }
  1814.                  else if(intinput==2)
  1815.                    output_format=TIF16;
  1816.                  else if(intinput==3)
  1817.                    output_format=TIF24;
  1818.                  else
  1819.                    {
  1820.                       sprintf(TEXTP,"%d not a valid option",intinput);
  1821.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1822.                       getch();
  1823.                       break;
  1824.                    }
  1825.                  if ( (ret = L_DecompressTIF(input_filename, output_filename, output_format))
  1826.                             == SUCCESS)
  1827.                   {
  1828.                    sprintf(TEXTP,"File: %s Decompressed to %s (TIF). Press any key to continue. ",input_filename,output_filename);
  1829.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1830.                    if(output_format==TIF8)
  1831.                      L_FreeRGBFixedPalette();
  1832.                   }
  1833.                  else
  1834.                   {
  1835.                    sprintf(TEXTP,"Error: %d Decompressiing to TIF. Press any key to continue. ", ret);
  1836.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1837.                    putch(7);
  1838.                    if(output_format==TIF8)
  1839.                      L_FreeRGBFixedPalette();
  1840.                   }
  1841.         break;
  1842.  
  1843.         case 43: /* Case compress a BMP file */
  1844.                  sprintf(TEXTP,"Input file name: ");
  1845.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1846.                  getstring(input_filename,18,9);
  1847.                  sprintf(TEXTP,"Output file name: ");
  1848.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1849.                  getstring(output_filename,18,9);
  1850.                  sprintf(TEXTP,"0 LEAD, 1 JFIF, 2 JTIF, 3 LEAD1JFIF, 4 LEAD1JTIF, 5 LEAD2JFIF, 6 LEAD2JTF ?.");
  1851.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1852.                  getint(&compress_format,77,9);
  1853.                  sprintf(TEXTP,"Qfactor 1 to 255 or LEAD defined PQ1, PQ2, QFS, QMS, QS, SQS, SQT, MCQ, MC ");
  1854.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1855.                  getstring(compress_qfactor,18,9);
  1856.                  if (compress_format != 0)
  1857.                    save_palette = 0;
  1858.                  else
  1859.                   {
  1860.                    sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
  1861.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1862.                    getint(&save_palette,36,9);
  1863.                    while( (save_palette != 0) && (save_palette != 1) )
  1864.                     {
  1865.                      sprintf(TEXTP,"Save VGA palette? to? 0 - No, 1 - YES: ");
  1866.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1867.                      getint(&save_palette,39,9);
  1868.                     }
  1869.                   }
  1870.                  strupr(compress_qfactor);
  1871.                  if ( (qfactor = get_qfactor(compress_qfactor)) == ERROR_QFACTOR)
  1872.                   {
  1873.                    sprintf(TEXTP,"Error: Bad qfactor. Press any key to continue.");
  1874.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1875.                    break;
  1876.                   }
  1877.                  if ( (ret = L_CompressBMP(input_filename, output_filename, compress_format,
  1878.                                          qfactor, save_palette)) == SUCCESS)
  1879.                   {
  1880.                    sprintf(TEXTP,"File: %s compressed to %s. Press any key to continue.",input_filename,output_filename);
  1881.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1882.                   }
  1883.                  else
  1884.                   {
  1885.                    sprintf(TEXTP,"Error: %d compressing %s. Press any key to continue.", ret,input_filename);
  1886.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1887.                    putch(7);
  1888.                   }
  1889.         break;
  1890.  
  1891.  
  1892.         case 44: /* Case decompress to BMP file */
  1893.                  sprintf(TEXTP,"Input file name: ");
  1894.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1895.                  getstring(input_filename,18,9);
  1896.                  sprintf(TEXTP,"Output file name: ");
  1897.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1898.                  getstring(output_filename,18,9);
  1899.                  sprintf(TEXTP,"Output format 1 -BMP8, 2 -BMP24, 3 -PM8, 4 -PM24: ");
  1900.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1901.                  getint(&intinput,36,9);
  1902.                  if(intinput==1)
  1903.                   {
  1904.                    if ( L_LoadRGBFixedPalette(path) != SUCCESS)
  1905.                     {
  1906.                       sprintf(TEXTP,"Error: Can't load FIXED.DAT fixed palette file.  Press any key to continue.", ret);
  1907.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1908.                       putch(7);
  1909.                       break ;
  1910.                     }
  1911.                    output_format=BMP8;
  1912.                   }
  1913.                  else if(intinput==2)
  1914.                    output_format=BMP24;
  1915.                  else if(intinput==3)
  1916.                   {
  1917.                    if ( L_LoadRGBFixedPalette(path) != SUCCESS)
  1918.                     {
  1919.                       sprintf(TEXTP,"Error: Can't load FIXED.DAT fixed palette file.  Press any key to continue.", ret);
  1920.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1921.                       putch(7);
  1922.                       break ;
  1923.                     }
  1924.                    output_format=PM8;
  1925.                   }
  1926.                  else if(intinput==4)
  1927.                    output_format=PM24;
  1928.                  else
  1929.                    {
  1930.                       sprintf(TEXTP,"%d not a valid option",intinput);
  1931.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1932.                       getch();
  1933.                       break;
  1934.                    }
  1935.                  if ( (ret = L_DecompressBMP(input_filename, output_filename, output_format))
  1936.                            == SUCCESS)
  1937.                   {
  1938.                    sprintf(TEXTP,"File: %s decompressed to %s (BMP). Press any key to continue. ",input_filename,output_filename);
  1939.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1940.                    if( (output_format==PM8)||(output_format==PM8) )
  1941.                      L_FreeRGBFixedPalette();
  1942.                   }
  1943.                else
  1944.                 {
  1945.                  sprintf(TEXTP,"Error: %d Decompressing to BMP. Press any key to continue. ", ret);
  1946.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1947.                  L_FreeRGBFixedPalette();
  1948.                  putch(7);
  1949.                 }
  1950.         break;
  1951.  
  1952.         case 45: /* Case compress TARGA screen */
  1953.                  /* Is a TARGA installed OK */
  1954.                  if (TARGA_FLAG)
  1955.                   {
  1956.                    sprintf(TEXTP,"Output file name: ");
  1957.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1958.                    getstring(output_filename,18,9);
  1959.                    sprintf(TEXTP,"0 LEAD, 1 JFIF, 2 JTIF, 3 LEAD1JFIF, 4 LEAD1JTIF, 5 LEAD2JFIF, 6 LEAD2JTF ?.");
  1960.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1961.                    getint(&compress_format,77,9);
  1962.                    sprintf(TEXTP,"Qfactor 1 to 255 or LEAD defined PQ1, PQ2, QFS, QMS, QS, SQS, SQT, MCQ, MC ");
  1963.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1964.                    getstring(compress_qfactor,75,9);
  1965.                    strupr(compress_qfactor);
  1966.                    if ( (qfactor = get_qfactor(compress_qfactor)) == ERROR_QFACTOR)
  1967.                     {
  1968.                      sprintf(TEXTP,"Error: Bad qfactor. Press any key to continue.");
  1969.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1970.                      putch(7);
  1971.                      break;
  1972.                     }
  1973.                    if ( (ret = L_CompressTarga(output_filename, compress_format,
  1974.                                                qfactor )) == SUCCESS )
  1975.                     {
  1976.                      sprintf(TEXTP,"File: %s TARGA screen compressed. Press any key to continue.",output_filename);
  1977.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1978.                     }
  1979.                    else
  1980.                     {
  1981.                      sprintf(TEXTP,"Error: %d TARGA screen compression.", ret);
  1982.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1983.                      putch(7);
  1984.                     }
  1985.                   }
  1986.                  else
  1987.                   {
  1988.                    sprintf(TEXTP,"Error: Cannot initialize TARGA board.  Press any key to continue.");
  1989.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1990.                    putch(7);
  1991.                   }
  1992.         break;
  1993.  
  1994.  
  1995.         case 46: /* Gase get file info */
  1996.                  sprintf(TEXTP,"Input file name: ");
  1997.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  1998.                  getstring(input_filename,18,9);
  1999.                  if (L_FileInfo(input_filename, &FileInfo) != SUCCESS)
  2000.                   {
  2001.                    sprintf(TEXTP,"Error: %s Unrecognized file format.  Press any key to continue.",input_filename);
  2002.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2003.                    putch(7);
  2004.                    break;
  2005.                   }
  2006.                   if (FileInfo.Format == FILE_PCX)
  2007.                    {
  2008.                     sprintf(TEXTP,"%s Format=PCX, Width=%d, Height=%d, Bits/Pixel=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
  2009.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2010.                    }
  2011.                   else
  2012.                     if (FileInfo.Format == FILE_GIF)
  2013.                   {    
  2014.                     sprintf(TEXTP,"%s Format=GIF, Width=%d, Height=%d, Bits/Pixel=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
  2015.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2016.                   }
  2017.                  else
  2018.                   if (FileInfo.Format == FILE_TIF)
  2019.                   {
  2020.                     sprintf(TEXTP,"%s Format=TIF, Width=%d, Height=%d, Bits/Pixel=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
  2021.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2022.                   }
  2023.                  else
  2024.                   if (FileInfo.Format == FILE_TGA)
  2025.                    {
  2026.                     sprintf(TEXTP,"%s Format=TGA, Width=%d, Height=%d, Bits/Pixel=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
  2027.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2028.                    }
  2029.                   else
  2030.                    if (FileInfo.Format == FILE_CMP)
  2031.                   {
  2032.                     sprintf(TEXTP,"%s Format=LEAD CMP, Width=%d, Height=%d, Bits/Pixel=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
  2033.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2034.                    }
  2035.                   else
  2036.                    if (FileInfo.Format == FILE_BMP)
  2037.                   {
  2038.                     sprintf(TEXTP,"%s Format=Windows BMP, Width=%d, Height=%d, Bits/Pixel=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
  2039.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2040.                   }
  2041.                   else
  2042.                    if (FileInfo.Format == FILE_OS2)
  2043.                   {
  2044.                     sprintf(TEXTP,"%s Format=OS2 BMP, Width=%d, Height=%d, Bits/Pixel=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
  2045.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2046.                   }
  2047.  
  2048.                  else
  2049.                   if (FileInfo.Format == FILE_JFIF)
  2050.                   {
  2051.                     sprintf(TEXTP,"%s JPEG File Interchange Format, Width=%d, Height=%d, B/P=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
  2052.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2053.                   }
  2054.                  else
  2055.                   if (FileInfo.Format == FILE_JTIF)
  2056.                    {
  2057.                     sprintf(TEXTP,"%s JPEG TIF Width=%d, Height=%d, B/P=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
  2058.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2059.                    }
  2060.         break;
  2061.  
  2062.  
  2063.  
  2064.         case 47: /* Case convert a file */
  2065.                  sprintf(TEXTP,"Input file name: ");
  2066.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2067.                  getstring(input_filename,18,9);
  2068.                  if (L_FileInfo(input_filename, &FileInfo) != SUCCESS)  
  2069.                   {
  2070.                    sprintf(TEXTP,"Error: %s Unknown file format.  Press any key to continue.",input_filename);
  2071.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2072.                    putch(7);
  2073.                    break;
  2074.                   }
  2075.                  input_format = FileInfo.Format;
  2076.                  sprintf(TEXTP,"Output file name: ");
  2077.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2078.                  getstring(output_filename,18,9);
  2079.                  sprintf(TEXTP,"Output format 1 -PCX, 2 -GIF, 3 -TIF, 4 -TGA, 5 -Windows BMP, 6 -OS2 BMP : ");
  2080.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2081.                  getint(&intinput,76,9);
  2082.                  if(intinput==1)
  2083.                    output_format=FILE_PCX;
  2084.                  else if(intinput==2)
  2085.                    output_format=FILE_GIF;
  2086.                  else if(intinput==3)
  2087.                    output_format=FILE_TIF;
  2088.                  else if(intinput==4)
  2089.                    output_format=FILE_TGA;
  2090.                  else if(intinput==5)
  2091.                    output_format=FILE_BMP;
  2092.                  else if(intinput==6)
  2093.                    output_format=FILE_OS2;
  2094.                  else
  2095.                    {
  2096.                       sprintf(TEXTP,"%d not a valid option",intinput);
  2097.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2098.                       getch();
  2099.                       break;
  2100.                    }
  2101.                  if ( (output_format != FILE_PCX) && (output_format != FILE_GIF)
  2102.                      && (output_format != FILE_TIF) && (output_format != FILE_TGA)
  2103.                      && (output_format != FILE_BMP)
  2104.                      && (output_format != FILE_OS2) )
  2105.                   {
  2106.                    sprintf(TEXTP,"Error: Unknown file format. Press any key to continue.");
  2107.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2108.                    putch(7);
  2109.                    break;
  2110.                   }
  2111.                  sprintf(TEXTP,"New width or 0 for same as original: ");
  2112.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2113.                  getint(&new_width,37,9);
  2114.                  sprintf(TEXTP,"New height or 0 for same as original: ");
  2115.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2116.                  getint(&new_height,38,9);
  2117.                  sprintf(TEXTP,"BitsPerPixel: ");
  2118.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2119.                  getint(&BitsPerPixel,14,9);
  2120.                  if (output_format == FILE_PCX)
  2121.                   {
  2122.                    if ( (BitsPerPixel != 1) && (BitsPerPixel != 4) && (BitsPerPixel != 8) && (BitsPerPixel != 24))
  2123.                     {
  2124.                      sprintf(TEXTP,"Error: PCX can only be 1, 4, or 8-Bits/pixel. Press any key to continue.");
  2125.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2126.                      putch(7);
  2127.                      break;
  2128.                     }
  2129.                   }
  2130.                  else
  2131.                   if (output_format == FILE_GIF)
  2132.                    {
  2133.                     if ( (BitsPerPixel != 8) )
  2134.                      {
  2135.                       sprintf(TEXTP,"Error: GIF can only be 8-Bits/pixel. Press any key to continue.");
  2136.                       L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2137.                       putch(7);
  2138.                       break;
  2139.                      }
  2140.                    }
  2141.                   else
  2142.                    if (output_format == FILE_TIF)
  2143.                     {
  2144.                      if ( (BitsPerPixel != 1) && (BitsPerPixel != 8)
  2145.                          && (BitsPerPixel != 16) && (BitsPerPixel != 24) )
  2146.                       {
  2147.                        sprintf(TEXTP,"Error: TIF can only be 1, 8, or 24-Bits/pixel. Press any key to continue.");
  2148.                        L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2149.                        putch(7);
  2150.                        break;
  2151.                       }
  2152.                     }
  2153.                    else
  2154.                     if (output_format == FILE_TGA)
  2155.                      {
  2156.                       if ( (BitsPerPixel != 8) && (BitsPerPixel != 16)
  2157.                           && (BitsPerPixel != 24) && (BitsPerPixel != 32) )
  2158.                        {
  2159.                         sprintf(TEXTP,"Error: TGA can only be 8, 16, 24, or 32-Bits/pixel. Press any key to continue.");
  2160.                         L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2161.                         putch(7);
  2162.                         break;
  2163.                        }
  2164.                      }
  2165.                     else
  2166.                      if (output_format == FILE_BMP || output_format == FILE_OS2)
  2167.                        {
  2168.                        if ( (BitsPerPixel != 4) && (BitsPerPixel != 8)
  2169.                            && (BitsPerPixel != 24) )
  2170.                         {
  2171.                          sprintf(TEXTP,"Error: BMP can only be 4, 8, or 24 Bits/pixel. Press any key to continue.");
  2172.                          L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2173.                          putch(7);
  2174.                          break;
  2175.                         }
  2176.                       }
  2177.                  if ( (ret=L_FileConvert( input_filename,input_format,
  2178.                                        output_filename, output_format, new_width,
  2179.                                        new_height, BitsPerPixel )) == SUCCESS)
  2180.                   {
  2181.                    sprintf(TEXTP,"File: %s converted to %s successfully.", input_filename, output_filename);
  2182.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2183.                   }
  2184.                  else
  2185.                   {
  2186.                    sprintf(TEXTP,"Error: %d File convert. Press any key to continue.", ret);
  2187.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2188.                    putch(7);
  2189.                   }
  2190.         break;
  2191.  
  2192.       
  2193.         case 48: /* Case get video information */
  2194.                  L_GetVideoInfo(&videotype, &width, &height);
  2195.                  if (videotype == VIDEO_EGA)
  2196.                   {
  2197.                    sprintf(TEXTP,"VIDEO TYPE =  EGA Width = %d, Height = %d",width, height);
  2198.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2199.                   }
  2200.                  else
  2201.                   if (videotype == VIDEO_VGA)
  2202.                   {
  2203.                    sprintf(TEXTP,"VIDEO TYPE = Standared VGA with 256K of memory Width = %d, Height = %d",width, height);
  2204.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2205.                   }
  2206.                  else
  2207.                   if (videotype == VIDEO_SVGA)
  2208.                   {
  2209.                    sprintf(TEXTP,"VIDEO TYPE =  SuperVGA with 512K or more memory Width = %d, Height = %d",width, height);
  2210.                    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2211.                   }
  2212.         break;
  2213.  
  2214.         case 49: /* Case set video resolution */
  2215.         #ifdef TARGA   /* If TARGA 16,24,32 is used not a TARGA+.
  2216.                           The TARGA+ can be chages to multiple resolutions
  2217.                           I cant not chage the old TARGA 16,24,32 only TARGA+*/
  2218.                  sprintf(TEXTP,"MAX VGA resolution 0-320x200, 1-640x350, 2-640x480, 3-800x600, 4-1024x768. ");
  2219.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2220.                  getint(&video_size,74,9);
  2221.                 /* Checks for legal VGA/SuperVGA resolution */
  2222.                  if ( (video_size != SIZE_640x350)
  2223.                       && (video_size != SIZE_640x480) && (video_size != SIZE_800x600)
  2224.                       && (video_size != SIZE_1024x768) )
  2225.                   {
  2226.                    if(video_size == SIZE_320x200)
  2227.                     {
  2228.                      sprintf(TEXTP,"This demo must run at 640X480 or higher resolution.",width, height);
  2229.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2230.                      putch(7);
  2231.                      break;
  2232.                     }
  2233.                    else
  2234.                     {
  2235.                      sprintf(TEXTP,"Error: Unknown VGA resolution %d. Press any key to continue.",video_size);
  2236.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2237.                      putch(7);
  2238.                      break;
  2239.                     }
  2240.                   }
  2241.                  L_SetVideoMode(3, 0);
  2242.                  L_SetVGASize(video_size) ;
  2243.                  L_GetVideoDeviceBits(&device_bits);
  2244.                  sprintf(TEXTP,"VGA size set OK!  Press any key to continue.");
  2245.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2246.         #else    /** If TARGA+ is used NOT a TARGA 16, 24, 32**/
  2247.                  sprintf(TEXTP," 0 - Set VGA resolution. 1 - Set TARGA+ resolution.");
  2248.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2249.                  getint(&input_format,52,9);
  2250.                  if (input_format == 0)
  2251.                     {
  2252.                      sprintf(TEXTP,"MAX VGA resolution 0-320x200, 1-640x350, 2-640x480, 3-800x600, 4-1024x768: ");
  2253.                      L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2254.                      getint(&video_size,75,9);
  2255.                     /* Checks for legal VGA/SuperVGA resolution */
  2256.                     if ( (video_size != SIZE_640x350)
  2257.                        && (video_size != SIZE_640x480) && (video_size != SIZE_800x600)
  2258.                        && (video_size != SIZE_1024x768) )
  2259.                        {
  2260.                         if(video_size == SIZE_320x200)
  2261.                          {
  2262.                           sprintf(TEXTP,"This demo must run at 640X480 or higher resolution.",width, height);
  2263.                           L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2264.                           putch(7);
  2265.                           break;
  2266.                          }
  2267.                         else
  2268.                          {
  2269.                           sprintf(TEXTP,"Error: Unknown VGA resolution %d. Press any key to continue.",video_size);
  2270.                           L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2271.                           putch(7);
  2272.                           break;
  2273.                          }
  2274.                        }
  2275.                     L_SetVideoMode(3, 0);
  2276.                     L_SetVGASize(video_size) ;        /* Set new VGA resolution */
  2277.                     L_GetVideoDeviceBits(&device_bits);
  2278.                     sprintf(TEXTP,"VGA size set OK!  Press any key to continue.");
  2279.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2280.                     }
  2281.                  else if(input_format == 1)
  2282.                     {
  2283.                     ClearTheScreen();
  2284.  
  2285.                     sprintf(TEXTP,"  0 - Interlaced 512x400x16.");        /* TARGA+ modes available */
  2286.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-YCHR);
  2287.                     sprintf(TEXTP,"  1 - Noninterlaced 512x400x16.");
  2288.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*2));
  2289.                     sprintf(TEXTP,"  2 - Interlaced 512x400x32.");
  2290.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*3));
  2291.                     sprintf(TEXTP,"  3 - Noninterlaced 512x400x32.");
  2292.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*4));
  2293.                     sprintf(TEXTP,"  4 - Interlaced 512x486x16.");
  2294.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*5));
  2295.                     sprintf(TEXTP,"  5 - Noninterlaced 512x486x16.");
  2296.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*6));
  2297.                     sprintf(TEXTP,"  6 - Interlaced 512x486x32.");
  2298.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*7));
  2299.                     sprintf(TEXTP,"  7 - Noninterlaced 512x486x32.");
  2300.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*8));
  2301.                     sprintf(TEXTP,"  8 - Interlaced 640x480x16.");
  2302.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*9));
  2303.                     sprintf(TEXTP,"  9 - Noninterlaced 640x480x16.");
  2304.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*10));
  2305.                     sprintf(TEXTP," 10 - SquareInterlaced 640x486x16.");
  2306.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*11));
  2307.                     sprintf(TEXTP," 11 - SquareNoninterlaced 640x486x16.");
  2308.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*12));
  2309.                     sprintf(TEXTP," 12 - Interlaced 720x486x16.");
  2310.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*13));
  2311.                     sprintf(TEXTP," 13 - Noninterlaced 720x486x16.");
  2312.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*14));
  2313.                     sprintf(TEXTP," 14 - Interlaced 756x486x16.");
  2314.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*15));
  2315.                     sprintf(TEXTP," 15 - Noninterlaced 756x486x16.");
  2316.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*16));
  2317.                     sprintf(TEXTP," 16 - Interlaced 800x600x16.");
  2318.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*17));
  2319.                     sprintf(TEXTP," 17 - Interlaced 1024x768x16.");
  2320.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*18));
  2321.                     sprintf(TEXTP," 18 - Back to VGA mode.");
  2322.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*19));
  2323.                     sprintf(TEXTP,"Set Targa+ Mode To: ");
  2324.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*20));
  2325.                     getint(&videotype,38,9);
  2326.                     L_SetTARGAMode(videotype) ;            /* Set new TARGA+ mode */
  2327.                     ClearTheScreen();
  2328.                     sprintf(TEXTP,"Targa+ mode set!  Press any key to continue.");
  2329.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2330.                     }
  2331.                  else
  2332.                     {
  2333.                     sprintf(TEXTP,"Error: %d Unknown command number!");
  2334.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2335.                     putch(7);
  2336.                     }
  2337.         #endif
  2338.         break;
  2339.  
  2340.         case 50: /* Case set VGA memory */
  2341.                  sprintf(TEXTP,"VGA memory in Kbytes: ");
  2342.                  L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2343.                  getint(&video_memory,23,9);
  2344.                 if (video_memory < 256)
  2345.                  {
  2346.                   sprintf(TEXTP,"Error: %d Unknown VGA memory size", video_memory);
  2347.                   L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2348.                   break;
  2349.                  }
  2350.                 L_SetVideoMemory(video_memory) ;       /* Set new video memory */
  2351.                 sprintf(TEXTP,"VGA memory set! Press any key to continue.");
  2352.                 L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2353.         break;
  2354.  
  2355.        case 51: /* Case change brightness */
  2356.                   if ( alloc_bitmap == 0 )
  2357.                    {
  2358.                     sprintf(TEXTP,"Error: No image in BitMap allocated. Press any key to continue.");
  2359.                     L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2360.                     putch(7);
  2361.                     break;
  2362.                    }
  2363.                 sprintf(TEXTP,"+# Increase / -# Decrease Intensity by: ");
  2364.                 L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2365.                 getint( &ret,41,9 );
  2366.                 L_ChangeBitmapIntensity(&Bitmap, ret) ;    /* Set new intensity */
  2367.                 sprintf(TEXTP,"Change Intensity Successful!            ");
  2368.                 L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2369.         break;
  2370.  
  2371.         case 52: /* clear the screen */
  2372.                  ClearTheScreen();
  2373.                  L_GraphText(FONT8X16, 0,"Press any Key to Continue.",WHITE,RED,0,9);
  2374.                break;
  2375. #ifdef FOR_TEST
  2376.        case 53: /* Case capture VGA */
  2377.                 if (alloc_bitmap == 1)       /* Free BitMap information as before */
  2378.                    {
  2379.                     L_FreeBitmap( &Bitmap );
  2380.                     alloc_bitmap = 0;
  2381.                    }
  2382.                 /* The input file name can be any file format as long as it matches the */
  2383.                 /* function call below. For this program capturing the VGA screen       */
  2384.                 /* requires that the user enter a PCX file. It then loads the file to   */
  2385.                 /* a bitmap handle. Then it will save the bitmap using L_GetScreeBitMap.*/
  2386.                 /* When it is finished, it will release the bitmap.                     */
  2387.                 sprintf(TEXTP,"Input PCX file name: ");
  2388.                 L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2389.                 getstring(input_filename,23,9);
  2390.                 sprintf(TEXTP,"Starting X display position to capture: ");
  2391.                 L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2392.                 getint(&xpos,42,9);
  2393.                 sprintf(TEXTP,"Starting Y display position to capture: ");
  2394.                 L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2395.                 getint(&ypos,42,9);
  2396.                 sprintf(TEXTP,"Capture width: ");
  2397.                 L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2398.                 getint(&width,17,9);
  2399.                 sprintf(TEXTP,"Capture height: ");
  2400.                 L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2401.                 getint(&height,18,9);
  2402.  
  2403.                                  /* Puts it on the VGA screen and Bitmap handle */
  2404.                 if ( (ret = L_LoadPCXScreen(input_filename, &Bitmap, OUTPUT_BITMAP,
  2405.                                                              TYPE_CONV, 0, 0 )) == SUCCESS)
  2406.                  {
  2407.                   if ((ret=L_ViewBitmapScreen(&Bitmap, 0, 0)) == SUCCESS)
  2408.                    {
  2409.                     if ((ret = L_GetScreenBitmap(&NewBitmap, xpos, ypos, width, height)) == SUCCESS )
  2410.                      {
  2411.                      if ((ret = L_SavePCXBitmap("screen.pcx", &NewBitmap, 24)) != SUCCESS)
  2412.                         {
  2413.                         sprintf(TEXTP,"Error: %d saving Screen.pcx. Press any key to continue.", ret);
  2414.                         L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2415.                         putch(7);
  2416.                         }
  2417.                      else
  2418.                         {
  2419.                         sprintf(TEXTP,"Screen saved successfully in SCREEN.PCX");
  2420.                         L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2421.                         }
  2422.                       L_FreeBitmap(&NewBitmap); /* Release impage from the copy Bit map */
  2423.                       alloc_bitmap = 1;         /* Release image from the bitmap */
  2424.                      }
  2425.                    }
  2426.                  }
  2427.         break;
  2428.  
  2429.        case 54:
  2430.                if (alloc_bitmap == 1)       /* Free BitMap information as before */
  2431.                   {
  2432.                    L_FreeBitmap( &Bitmap );
  2433.                    alloc_bitmap = 0;
  2434.                   }
  2435.  
  2436.                 ret=L_SaveTargaWindow(256,256,400,400,&Bitmap,BIT24);
  2437.                 alloc_bitmap = 1;
  2438.  
  2439.               break;
  2440.  
  2441.        case 55: /* inter use */
  2442.             L_SetVideoSource(VideoInputRGB);
  2443.             L_SetTARGALiveMode();
  2444.             L_SleepKey(99);
  2445.             L_GrabTARGA();
  2446.             break;
  2447. #endif
  2448.         case 100: /* Case exit the program */
  2449.                   if (alloc_bitmap == 1)  /* Release BitMap information before quit */
  2450.                   {
  2451.                     L_FreeBitmap(&Bitmap);
  2452.                     alloc_bitmap = 0;
  2453.                    }
  2454.                   L_SetVideoMode(3, 0);            /* Set TEXT mode*/
  2455.                   L_TARGAEnd();
  2456.                     puts("EXIT DEMO\n\n");
  2457.                   puts("       COPYRIGHT (c) 1991 LEAD Technologies Inc. ALL RIGHTS RESERVED.");
  2458.                   puts("                           8701 Mallard Creek Rd.");
  2459.                   puts("                           Charlotte NC 28262");
  2460.                   puts("                           Tel # 704-549-5532");
  2461.                   puts("Running this program indicates your compliance with the following contract.");
  2462.                   puts("This software is owned by LEAD Technologies Inc. and is protected by");
  2463.                   puts("the United States copyright laws and international treaty provisions. You may");
  2464.                   puts("not copy, reverse engineer, decompile, or disassemble this software. LEAD");
  2465.                   puts("Technologies Inc. grants the right to use this copy of this software for");
  2466.                   puts("evaluation purposes only. \n\n");
  2467.                   exit(0);
  2468.  
  2469.         default:   /* Anything else is a wrong selection */
  2470.                sprintf(TEXTP," Wrong selection!  Press any key to continue.");
  2471.                L_GraphText(FONT8X16, 0,TEXTP,GRAY,RED,6,9);
  2472.                putch(7);
  2473.                break;
  2474.        }             /* End BIG switch */
  2475.  
  2476.   L_SleepKey(99);    /* Waits 99 seconds or until key is pressed */
  2477.  
  2478.  }                   /* BIG for loop  */
  2479.  
  2480. }                    /* end main(); */
  2481. /****************************END OF MAIN()***************************/
  2482.  
  2483.  
  2484. /*********** Function to get the qfactor **********/
  2485. /* Also it checks for a valid qfactor entered by the user */
  2486. int get_qfactor(char *string)   /* String to hold the Qfactor */
  2487. {
  2488.   char *exttab[NUMEXTENSIONS], *extptr1;
  2489.   int qfactor, source;
  2490.  
  2491.   /* The following is a reference table to find out which compression       */
  2492.   /* method the user wants to compress the file with.                       */
  2493.     exttab[0] = "PQ1";    /* Perfect quality compression                    */
  2494.     exttab[1] = "PQ2";    /* Perfect quality compression                    */
  2495.     exttab[2] = "QFS";   /* Quality by far more important than size         */
  2496.     exttab[3] = "QMS";   /* Quality more important than size                */
  2497.     exttab[4] = "QS";    /* Quality and size equally important              */
  2498.     exttab[5] = "SQS";   /* Size more important than quality - SHARP        */
  2499.     exttab[6] = "SQT";   /* Size more important than quality -  LESS TILING */
  2500.     exttab[7] = "MCQ";   /* Give maximum compression - HIGHT QUALITY        */
  2501.     exttab[8] = "MC";    /* Give maximum compression                        */
  2502.  
  2503. extptr1 = string;
  2504.  
  2505. for (source = 0; source < NUMEXTENSIONS; ++source)
  2506.      {if (!strcmp(extptr1, exttab[source]))
  2507.        break;
  2508.       }
  2509. /* Checks for bad qfactor */
  2510. if (source >= NUMEXTENSIONS)
  2511.    {
  2512.    qfactor = atoi(string);
  2513.    if (qfactor <= 0 || qfactor > 255)
  2514.       return(ERROR_QFACTOR);
  2515.    else
  2516.       return (qfactor);
  2517.    }
  2518. /* Else the extension is a predefined qfactor shown in the table above */
  2519. else
  2520.    {
  2521.    if (source == 0)         /* See the table above for types of compression */
  2522.       return(QFACTOR_PQ1);
  2523.    if (source == 1)
  2524.       return(QFACTOR_PQ2);
  2525.    if (source == 2)
  2526.       return(QFACTOR_QFS);
  2527.    if (source == 6)
  2528.       return(QFACTOR_QMS);
  2529.    if (source == 4)
  2530.       return(QFACTOR_QS);
  2531.    if (source == 5)
  2532.       return(QFACTOR_SQS);
  2533.    if (source == 6)
  2534.       return(QFACTOR_SQT);
  2535.    if (source == 7)
  2536.       return(QFACTOR_MCQ);
  2537.    if (source == 8)
  2538.       return(QFACTOR_MC);
  2539.    }
  2540. return(SUCCESS);
  2541. }
  2542.  
  2543. /********* Prints out the Main Menu *********/
  2544. void printscreen(void)
  2545. {
  2546.   int i;  /* For the loop to fill the BLANK screen and a */
  2547.           /* BLANK line storage array */
  2548.  
  2549.    L_SetVGAPalette(RGBFixedPalette);
  2550.  
  2551.    L_GraphFontSize(16,32);
  2552.    i=480-16;
  2553.    L_GraphText(FONT8X16, 0,"LEADTOOLS DOS Real Mode Demo",LIGHTYELLOW,KEEPBACKGROUND,80,i);
  2554.  
  2555.    L_GraphFontSize(0,0);
  2556.    i=i-30;
  2557.    L_GraphText(FONT8X16, 0,"1",WHITE,KEEPBACKGROUND,XCHR,i);
  2558.    sprintf(TEXTP,"   - Load TGA file to BitMap.              - Save BitMap as TGA file.");
  2559.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2560.    L_GraphText(FONT8X16, 0,"2",WHITE, KEEPBACKGROUND,42*XCHR,i);
  2561.    i=i-16;
  2562.  
  2563.    L_GraphText(FONT8X16, 0,"3",WHITE, KEEPBACKGROUND,XCHR,i);
  2564.    sprintf(TEXTP,"   - Load PCX file to BitMap.              - Save BitMap as PCX file.");
  2565.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2566.    L_GraphText(FONT8X16, 0,"4",WHITE, KEEPBACKGROUND,42*XCHR,i);
  2567.    i=i-16;
  2568.  
  2569.    L_GraphText(FONT8X16, 0,"5",WHITE, KEEPBACKGROUND,XCHR,i);
  2570.    sprintf(TEXTP,"   - Load GIF file to BitMap.              - Save BitMap as GIF file.");
  2571.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2572.    L_GraphText(FONT8X16, 0,"6",WHITE, KEEPBACKGROUND,42*XCHR,i);
  2573.    i=i-16;
  2574.  
  2575.    L_GraphText(FONT8X16, 0,"7",WHITE, KEEPBACKGROUND,XCHR,i);
  2576.    sprintf(TEXTP,"   - Load TIF file to BitMap.              - Save BitMap as TIF file.");
  2577.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2578.    L_GraphText(FONT8X16, 0,"8",WHITE, KEEPBACKGROUND,42*XCHR,i);
  2579.    i=i-16;
  2580.  
  2581.    L_GraphText(FONT8X16, 0,"9",WHITE, KEEPBACKGROUND,XCHR,i);
  2582.    sprintf(TEXTP,"   - Load BMP file to BitMap.              - Save BitMap as BMP file.");
  2583.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2584.    L_GraphText(FONT8X16, 0,"10",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2585.    i=i-16;
  2586.  
  2587.    L_GraphText(FONT8X16, 0,"11",WHITE, KEEPBACKGROUND,0,i);
  2588.    sprintf(TEXTP,"   - Load LEAD/JFIF/JTIF/CCITT to BitMap   - Save BitMap as LEAD/JFIF/JTIF/CCITT");
  2589.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2590.    L_GraphText(FONT8X16, 0,"12",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2591.    i=i-16;
  2592.  
  2593.    L_GraphText(FONT8X16, 0,"13",WHITE, KEEPBACKGROUND,0,i);
  2594.    sprintf(TEXTP,"   - Flip BitMap.                          - Reverse BitMap.");
  2595.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2596.    L_GraphText(FONT8X16, 0,"14",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2597.    i=i-16;
  2598.    
  2599.    L_GraphText(FONT8X16, 0,"15",WHITE, KEEPBACKGROUND,0,i);
  2600.    sprintf(TEXTP,"   - Resize BitMap.                        - Rotate Bitmap.");
  2601.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2602.    L_GraphText(FONT8X16, 0,"16",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2603.    i=i-16;
  2604.  
  2605.    L_GraphText(FONT8X16, 0,"17",WHITE, KEEPBACKGROUND,0,i);
  2606.    sprintf(TEXTP,"   - Dither BitMap to Fixed Palette.       - Optimize Bitmap.");
  2607.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);          
  2608.    L_GraphText(FONT8X16, 0,"18",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2609.    i=i-16;
  2610.  
  2611.    L_GraphText(FONT8X16, 0,"19",WHITE, KEEPBACKGROUND,0,i);
  2612.    sprintf(TEXTP,"   - Clear BitMap.                         - Change BitMap position.");
  2613.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2614.    L_GraphText(FONT8X16, 0,"20",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2615.    i=i-16;
  2616.  
  2617.    L_GraphText(FONT8X16, 0,"21",WHITE, KEEPBACKGROUND,0,i);
  2618.    sprintf(TEXTP,"   - View BitMap on TARGA.                 - View BitMap on VGA.");
  2619.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2620.    L_GraphText(FONT8X16, 0,"22",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2621.    i=i-16;
  2622.  
  2623.    L_GraphText(FONT8X16, 0,"23",WHITE, KEEPBACKGROUND,0,i);
  2624.    sprintf(TEXTP,"   - View TGA file on TARGA.               - View TGA file on VGA.");
  2625.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2626.    L_GraphText(FONT8X16, 0,"24",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2627.    i=i-16;
  2628.  
  2629.    L_GraphText(FONT8X16, 0,"25",WHITE, KEEPBACKGROUND,0,i);
  2630.    sprintf(TEXTP,"   - View PCX file on TARGA.               - View PCX file on VGA.");
  2631.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2632.    L_GraphText(FONT8X16, 0,"26",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2633.    i=i-16;
  2634.  
  2635.    L_GraphText(FONT8X16, 0,"27",WHITE, KEEPBACKGROUND,0,i);
  2636.    sprintf(TEXTP,"   - View GIF file on TARGA.               - View GIF file on VGA.");
  2637.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2638.    L_GraphText(FONT8X16, 0,"28",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2639.    i=i-16;
  2640.  
  2641.    L_GraphText(FONT8X16, 0,"29",WHITE, KEEPBACKGROUND,0,i);
  2642.    sprintf(TEXTP,"   - View TIF file on TARGA.               - View TIF file on VGA.");
  2643.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2644.    L_GraphText(FONT8X16, 0,"30",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2645.    i=i-16;
  2646.  
  2647.    L_GraphText(FONT8X16, 0,"31",WHITE, KEEPBACKGROUND,0,i);
  2648.    sprintf(TEXTP,"   - View BMP file on TARGA.               - View BMP file on VGA.");
  2649.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2650.    L_GraphText(FONT8X16, 0,"32",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2651.    i=i-16;
  2652.  
  2653.    L_GraphText(FONT8X16, 0,"33",WHITE, KEEPBACKGROUND,0,i);
  2654.    sprintf(TEXTP,"   - View LEAD/JFIF/JTIF file on TARGA.    - View LEAD/JFIF/JTIF file on VGA.");
  2655.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2656.    L_GraphText(FONT8X16, 0,"34",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2657.    i=i-16;
  2658.  
  2659.    L_GraphText(FONT8X16, 0,"35",WHITE, KEEPBACKGROUND,0,i);
  2660.    sprintf(TEXTP,"   - Compress TGA file.                    - Decompress to TGA file.");
  2661.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2662.    L_GraphText(FONT8X16, 0,"36",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2663.    i=i-16;
  2664.  
  2665.    L_GraphText(FONT8X16, 0,"37",WHITE, KEEPBACKGROUND,0,i);
  2666.    sprintf(TEXTP,"   - Compress PCX file.                    - Decompress to PCX file.");
  2667.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2668.    L_GraphText(FONT8X16, 0,"38",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2669.    i=i-16;
  2670.    
  2671.    L_GraphText(FONT8X16, 0,"39",WHITE, KEEPBACKGROUND,0,i);
  2672.    sprintf(TEXTP,"   - Compress GIF file.                    - Decompress to GIF file.");
  2673.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2674.    L_GraphText(FONT8X16, 0,"40",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2675.    i=i-16;
  2676.  
  2677.    L_GraphText(FONT8X16, 0,"41",WHITE, KEEPBACKGROUND,0,i);
  2678.    sprintf(TEXTP,"   - Compress TIF file.                    - Decompress to TIF file.");
  2679.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2680.    L_GraphText(FONT8X16, 0,"42",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2681.    i=i-16;
  2682.  
  2683.    L_GraphText(FONT8X16, 0,"43",WHITE, KEEPBACKGROUND,0,i);
  2684.    sprintf(TEXTP,"   - Compress BMP file.                    - Decompress to BMP file.");
  2685.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2686.    L_GraphText(FONT8X16, 0,"44",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2687.    i=i-16;
  2688.  
  2689.    L_GraphText(FONT8X16, 0,"45",WHITE, KEEPBACKGROUND,0,i);
  2690.    sprintf(TEXTP,"   - Compress TARGA screen.                - Get information on a file.");
  2691.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2692.    L_GraphText(FONT8X16, 0,"46",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2693.    i=i-16;
  2694.  
  2695.    L_GraphText(FONT8X16, 0,"47",WHITE, KEEPBACKGROUND,0,i);
  2696.    sprintf(TEXTP,"   - Convert a file.                       - Get VGA/SuperVGA information.");
  2697.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2698.    L_GraphText(FONT8X16, 0,"48",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2699.    i=i-16;
  2700.  
  2701. #ifdef TARGA
  2702.    L_GraphText(FONT8X16, 0,"49",WHITE, KEEPBACKGROUND,0,i);
  2703.    sprintf(TEXTP,"   - Set VGA/SuperVGA Resolution.          - Set VGA/SuperVGA memory size.");
  2704.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2705.    L_GraphText(FONT8X16, 0,"50",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2706.    i=i-16;
  2707. #else                         
  2708.    L_GraphText(FONT8X16, 0,"49",WHITE, KEEPBACKGROUND,0,i);
  2709.    sprintf(TEXTP,"   - Set VGA or TARGA+ Resolution.         - Set VGA/SuperVGA memory size.");
  2710.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2711.    L_GraphText(FONT8X16, 0,"50",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2712.    i=i-16;
  2713.  
  2714. #endif
  2715.    L_GraphText(FONT8X16, 0,"51",WHITE, KEEPBACKGROUND,0,i);
  2716.    sprintf(TEXTP,"   - Change BitMap brightness.             - CLEAR The Screen.");
  2717.    L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
  2718.    L_GraphText(FONT8X16, 0,"52",WHITE, KEEPBACKGROUND,41*XCHR,i);
  2719.  
  2720.    sprintf(TEXTP,"Enter your selection, or 100 to exit:                                           ");
  2721.    L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
  2722.    L_GraphText(FONT8X16, 0,"────────────────────────────────────────────────────────────────────────────────",LIGHTYELLOW,-1,0,17);
  2723.    L_GraphText(FONT8X16, 0,"────────────────────────────────────────────────────────────────────────────────",LIGHTYELLOW,-1,0,0);
  2724.  
  2725.    
  2726.  
  2727. }
  2728.  
  2729. void getint(int *answer, int xpos, int ypos)         
  2730. {
  2731.    int ch, i,j;
  2732.    char string[7];
  2733.  
  2734.    i=xpos*XCHR;
  2735.    j=0;
  2736.    string[0]='\0';
  2737.  
  2738.    while(j < 5)
  2739.    {
  2740.     ch = getch();  /* Character type in is stored in ch */
  2741.     if ( (ch == EOF) || (ch == '\r') || (ch == '\n') )
  2742.       {
  2743.        break;
  2744.       }
  2745.     /* Makes sure ch is a printable charcter */
  2746.     /* Also checks to see if ch is a Backspace key */
  2747.     if ( (ch != 0x08) )
  2748.       {
  2749.        sprintf(TEXTP,"%c",ch);
  2750.        L_GraphText(FONT8X16, 0,TEXTP,WHITE,-1,i,ypos);
  2751.        string[j]=(char)ch;
  2752.        i=i+XCHR;
  2753.        j++;
  2754.       }
  2755.     else
  2756.        if (ch == 0x08)
  2757.          {
  2758.          if (j > 0)
  2759.             {
  2760.              /* If ch is a Backspace then clear the curent character
  2761.                 on the screen */
  2762.              i=i-XCHR;
  2763.              j--;
  2764.              sprintf(TEXTP," ");
  2765.              L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,i,ypos);
  2766.             }
  2767.            else
  2768.             putch(7);
  2769.  
  2770.          }
  2771.    }
  2772.    string[j]='\0';
  2773.    *answer=atoi(string);
  2774.    L_GraphText(FONT8X16, 0,"                                                                                ",LIGHTYELLOW,RED,0,ypos);
  2775.    L_GraphText(FONT8X16, 0,"────────────────────────────────────────────────────────────────────────────────",LIGHTYELLOW,-1,0,ypos+8);
  2776.    L_GraphText(FONT8X16, 0,"────────────────────────────────────────────────────────────────────────────────",LIGHTYELLOW,-1,0,ypos-10);
  2777.  
  2778.  
  2779. }
  2780.  
  2781. /************** Get a string from the keyboard ****************/
  2782. void getstring(char *answer,int xpos, int ypos)
  2783. {
  2784.    int ch, i, j=0;           /* Counters */
  2785.    char string[128];     /* Charcter buffer */
  2786.  
  2787.    i=xpos*XCHR;
  2788.  
  2789.    while(j < 128)
  2790.    {
  2791.     ch = getch();          /* Gets a character and stores it in ch */
  2792.     if ( (ch == EOF) || (ch == '\r') || (ch == '\n') )
  2793.      {
  2794.       break;
  2795.      }
  2796.     /* Make sure the key pressed is a printable character and
  2797.        not a Backspace */
  2798.     if ( (ch != 0x08) && (ch > 32 ) )
  2799.      {
  2800.       sprintf(TEXTP,"%c",ch);
  2801.       L_GraphText(FONT8X16, 0,TEXTP,WHITE,-1,i,ypos);
  2802.       string[j]=(char)ch;
  2803.       i=i+XCHR;
  2804.       j++;
  2805.      }
  2806.     else
  2807.        if (ch == 0x08)
  2808.         {
  2809.          if (j > 0)
  2810.            {
  2811.             /* If ch is a Backspace then clear the curent character
  2812.                on the screen */
  2813.             i=i-XCHR;
  2814.             j--;
  2815.             sprintf(TEXTP," ");
  2816.             L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,i,ypos);
  2817.            }
  2818.           else
  2819.             putch(7);
  2820.         }
  2821.    }
  2822.    string[j] = '\0';
  2823.    strcpy(answer,string);
  2824.    L_GraphText(FONT8X16, 0,"                                                                                ",LIGHTYELLOW,RED,0,ypos);
  2825.    L_GraphText(FONT8X16, 0,"────────────────────────────────────────────────────────────────────────────────",LIGHTYELLOW,-1,0,ypos+8);
  2826.    L_GraphText(FONT8X16, 0,"────────────────────────────────────────────────────────────────────────────────",LIGHTYELLOW,-1,0,ypos-10);
  2827.  
  2828. }
  2829.  
  2830. /************* BLANK the screen ************/
  2831. void ClearTheScreen(void)
  2832. {
  2833.   int i;
  2834.   for(i=0; i<59; i++)
  2835.                  /*Font,   vertical,      text,     for color,  back color, X, Y*/
  2836.      L_GraphText(FONT8X16, 0,"                                                                                ",
  2837.       BLACK,       BLACK,              0,    i*8);
  2838.  
  2839. }
  2840.