home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************
- * Last Modified: 12/1/92 *
- * Filenanme : DEMO.C *
- * This is an example program that demonstrates some *
- * of the most commonly called LEADTOOLS functions. *
- * and use LEADTOOLS compression/decompression, *
- * viewing, conversion, and all the BitMap load, flip, *
- * reverse functions for both TARGA and VGA/SuperVGA *
- * graphics card. *
- * *
- * This example uses both TARGA and VGA display in the same *
- * program. If your application uses only the TARGA display *
- * then do not use the L_Load???Screen() functions (where *
- * ??? is the file format). Also, if you are writing only *
- * for VGA display, then do not use the L_Load???Targa() *
- * functions. If both are used, then the EXE file will be *
- * larger than necessary since these routine are not *
- * applicable to the hardware. *
- * *
- ****************************************************************************/
-
- #include <ctype.h> /* Standard C header files */
- #include <conio.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- /********* INCLUDES *********/
- #include ".\include\l_toolap.h" /* Application tools for the toolkit */
- #include ".\include\l_error.h" /* Error return codes */
- #include ".\include\l_bitmap.h" /* Bitmap file information */
-
-
- #if __BORLANDC__
- extern unsigned _stklen = 14000U;
- #endif
-
- /* A define used in get_qfactor for transforming the characters typed for
- LEAD's Compression formats enhanced options to their equivalent
- integer defines. */
-
- #define NUMEXTENSIONS 9
- #define XCHR 8
- #define YCHR 18
-
- /*********************** Global Variables ***********************/
-
- char TEXTP[200]; /* TEXT for the print functions*/
-
- /********************** Decalare Functions ********************/
- int get_qfactor(char *string); /* Convert the characters typed for the
- ImageQfactor to the equivalent integer
- defines. */
- int video_size; /* Select a video mode */
- int device_bits;
-
- void printscreen(void); /* Prints the user input screen */
- void getint(int *, int, int); /* Gets an integer from the keyboard*/
- void getstring(char *,int ,int); /* Gets a string from the keyboard*/
- void ClearTheScreen(void); /* Blanks the screen */
- void main(int argc, char *argv[]);
-
-
- /****************************************************************************
- * main() *
- ****************************************************************************/
- void main(int argc, char *argv[])
- {
- int TARGA_FLAG; /* Flag used to verify if a TARGA board is present */
- int function_type; /* Switch to determine which function to call */
- int ret; /* Function return values */
- int videotype; /* To determine the VGA/SuperVGA graphics card type */
- int width; /* Image width */
- int height; /* Image height */
- int BitsPerPixel; /* As it says */
- int alloc_bitmap = 0; /* Flag to determine if there is a BitMap allocated
- in memory */
-
- int compress_format; /* Compression method to be used, either
- LEAD, JFIF, or JTIF */
- int qfactor; /* To determine the degree of compression for
- CMP, JFIF and JTIF */
-
- int new_width, /* For resizing an image */
- new_height;
- int xpos, ypos; /* For viewing image at different locations on
- the screen */
- int save_palette; /* Flag for saving the VGA palette in a compressed
- file or not */
- int output_format; /* For saving an image into the desired file format */
- int TIFCMP; /* to save tif as LZW or uncompressed */
- int video_memory; /* Amount of video memory in KBytes
- available in the VGA/SuperVGA card */
- int input_format; /* For selecting the input file format in the
- file to file conversion process */
- int intinput; /* value for input bits/pxel */
- char input_filename[160], /* Strings for input and output DOS file names */
- output_filename[160];
-
- char compress_qfactor[100]; /* String for entering compression Q factor */
-
- BITMAPHANDLE Bitmap; /* The main BITMAPHANLE used in the program */
- BITMAPHANDLE NewBitmap; /* A BitMap handle used for the resizing,
- optimizing, and viewing functions */
- FILEINFO FileInfo; /* Structure that L_FileInfo will fill to return
- important information about an image file */
-
- int format; /* used for BMP windows or PM */
- int i;
- char path[200];
-
- #ifdef FOR_TEST
- int port;
- FILE far *Stream;
- #endif
-
- strcpy(path, argv[0]);
-
- for (i = strlen(path)-1; i > 0; i--)
- {
- if (path[i] == '\\' || path[i] == ':')
- break;
- }
- path[i+1] = 0;
- i=0;
-
-
- /* Initialize the TARGA graphics environment. This function must be called
- before any other function to communicate with the TARGA. */
- if (L_TARGAInit() <= 0)
- {
- puts("TARGA board initialization error or TARGA not present!");
- puts("You Can Use you SVGA Display.");
- puts("But Do not attempt to use any of the TARGA functions!");
- putch(7);
- L_SleepKey(3);
- TARGA_FLAG=0;
- }
- else
- TARGA_FLAG=1;
-
- L_GetVideoInfo(&videotype, &width, &height);
- if (videotype != VIDEO_SVGA)
- {
- printf("You must have a SuperVGA with 512K or more memory to run this demo\n");
- exit(0);
- }
-
- L_SetVGASize(SIZE_640x480);
- L_GetVideoDeviceBits(&device_bits);
- L_SetVGAPalette(RGBFixedPalette);
-
- L_SetCompressFormatJFIFCMP();
- L_SetCompressFormatJTIF();
- L_SetDecompressFormatJTIF();
- L_SetDecompressFormatJFIFCMP();
-
- for(;;) /* Loops until user enters 100 to exit program */
- {
- printscreen();
-
- getint(&function_type,39,9); /* Get user input */
-
- switch (function_type) /* Main switch on user's input */
- {
- case 1:/* Case load TGA file to a BitMap */
- /* If a BitMap exists we need to free it */
-
- if (alloc_bitmap == 1)
- {
- L_FreeBitmap( &Bitmap );
- alloc_bitmap = 0;
- }
- /*Font, vertical, text, for color, back color, X, Y*/
- L_GraphText( FONT8X16, 0,"Input file name: ", WHITE, RED, 5, 9);
- getstring(input_filename,18,9);
- /* Load the TGA filename directly into the BitMap handle.*/
- if ( (ret=L_LoadTGATarga( input_filename,
- &Bitmap,OUTPUT_BITMAP,
- TYPE_NOCONV, 0, 0 )) == SUCCESS )
- { /* It alocated a BitMap sucessfully */
- alloc_bitmap = 1;
- sprintf(TEXTP,"%s loaded to the BitMap. Press any key to continue.",input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- { /* An error occured while loading the TGA file */
- sprintf(TEXTP,"Error: %d loading TGA to BitMap. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 2:/* Case save a BitMap to TGA file */
- /* Make sure BitMap is being used and filled with image data */
- if (alloc_bitmap == 1)
- {
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,19,9);
- sprintf(TEXTP,"BitsPerPixel (8, 16, 24 or 32): ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&BitsPerPixel,33,9);
- /* Save the image Data in BitMap to a TGA file */
- if ( (ret=L_SaveTGABitmap( output_filename,
- &Bitmap,BitsPerPixel )) == SUCCESS )
- {
- sprintf(TEXTP,"%s saved OK. Press any key to continue.",output_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- { /* Error saving the TGA BitMap to the file */
- sprintf(TEXTP,"Error: %d saving BitMap to TGA. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- { /* Trying to save an empty BitMap */
- sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 3:/* Case load a PCX file to the BitMap */
- /* Make sure BitMap used and is filled with image */
- if (alloc_bitmap == 1)
- {
- L_FreeBitmap( &Bitmap );
- alloc_bitmap = 0;
- }
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- /* Load the PCX filename directly into the BitMap handle.*/
- if ( (ret=L_LoadPCXScreen( input_filename,
- &Bitmap, OUTPUT_BITMAP,
- TYPE_NOCONV, 0, 0 )) == SUCCESS )
- {/* If the PCX file was successfuly loaded to the BitMap */
- alloc_bitmap = 1;
- sprintf(TEXTP,"%s loaded to BitMap. Press any key to continue.",input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d loading PCX to BitMap. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 4:/* Case save a BitMap to a PCX file */
- /* Make sure BitMap is already being used and is filled with image data */
- if (alloc_bitmap == 1)
- {
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,18,9);
- sprintf(TEXTP,"BitsPerPixel (1, 4, 8, or 24): ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&BitsPerPixel,31,9);
- /* Save the image Data in BitMap to a PCX file*/
- if ( (ret=L_SavePCXBitmap( output_filename,&Bitmap,
- BitsPerPixel )) == SUCCESS )
- {
- sprintf(TEXTP,"%s saved OK. Press any key to continue.",output_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d saving BitMap to PCX. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- { /* Trying to save an empty BitMap */
- sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 5:/* Case Load GIF to BitMap */
- /* If a BitMap is already being used we need to free it */
- if (alloc_bitmap == 1)
- {
- L_FreeBitmap( &Bitmap );
- alloc_bitmap = 0;
- }
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- /* Load a GIF file to a BitMap */
- if ( (ret=L_LoadGIFScreen( input_filename,
- &Bitmap, OUTPUT_BITMAP,
- TYPE_NOCONV, 0, 0 )) == SUCCESS )
- {
- alloc_bitmap = 1;
- sprintf(TEXTP,"%s loaded to BitMap. Press any key to continue.",input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d loading GIF to the BitMap. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 6:/* Case save a BitMap as GIF file */
- /* Make sure BitMap is already being used and filled with image data */
- if (alloc_bitmap == 1)
- {
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,18,9);
- /* Saving the BitMap to a GIF file */
- if ( (ret=L_SaveGIFBitmap( output_filename,
- &Bitmap, 8 )) == SUCCESS )
- {
- sprintf(TEXTP,"%s saved OK. Press any key to continue.",output_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d saving the BitMap to GIF. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 7:/* Case Load a TIF file to a BitMap */
- /* If a BitMap is already being used free it */
- if (alloc_bitmap == 1)
- {
- L_FreeBitmap( &Bitmap );
- alloc_bitmap = 0;
- }
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- /* Load the TIF file to a BitMap */
- if ( (ret=L_LoadTIFScreen( input_filename, &Bitmap,
- OUTPUT_BITMAP, TYPE_NOCONV, 0, 0 )) == SUCCESS )
- {
- alloc_bitmap = 1;
- sprintf(TEXTP,"%s loaded to BitMap. Press any key to continue.",input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d loading TIF to the BitMap. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 8:/* Case save a BitMap to a TIF file */
- /* Make sure BitMap is already being used and is filled with image data */
- if (alloc_bitmap == 1)
- {
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,18,9);
- sprintf(TEXTP,"BitsPerPixel (1, 8, 16, or 24): ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&BitsPerPixel,32,9);
- sprintf(TEXTP,"Compression type: (0 Uncompressed) (1 LZW compressed): ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&TIFCMP,57,9);
- /* Save the BitMap to a TIF file */
- if ( (ret=L_SaveTIFBitmap( output_filename, &Bitmap,
- BitsPerPixel, TIFCMP)) == SUCCESS )
- {
- sprintf(TEXTP,"%s saved OK. Press any key to continue.",output_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d saving the BitMap to TIF. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 9:/* Case Load a BMP file to a BitMap */
- /* If a BitMap is already being used free it */
- if (alloc_bitmap == 1)
- {
- L_FreeBitmap( &Bitmap );
- alloc_bitmap = 0;
- }
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- /* Load a BMP file to the BitMap */
- if ( (ret=L_LoadBMPScreen( input_filename, &Bitmap,
- OUTPUT_BITMAP, TYPE_NOCONV, 0, 0 )) == SUCCESS )
- {
- alloc_bitmap = 1;
- sprintf(TEXTP,"%s loaded to BitMap. Press any key to continue.",input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d loading BMP to the BitMap. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 10:/* Case save a BitMap to a BMP file */
- /* Make sure BitMap is already being used and is filled with image data */
- if (alloc_bitmap == 1)
- {
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,18,9);
- sprintf(TEXTP,"BitsPerPixel (4, 8, or 24): ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&BitsPerPixel,29,9);
- sprintf(TEXTP,"type 0 for (WINDOWS BMP), or 1 for (PM BMP): ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&format,46,9);
- if(format==0)
- format=TYPE_WIN;
- else if(format==1)
- format=TYPE_OS2;
- else
- {
- sprintf(TEXTP,"%d not a valid option",format);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getch();
- break;
- }
- /* Save the BitMap to a BMP file */
- if ( (ret=L_SaveBMPBitmap( output_filename,&Bitmap,
- BitsPerPixel, format )) == SUCCESS )
- {
- sprintf(TEXTP,"%s saved OK. Press any key to continue.",output_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d saving the BitMap to BMP. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 11:/* Decompress a compressed file to a BitMap*/
- /* If a BitMap is already being used free it */
- if (alloc_bitmap == 1)
- {
- L_FreeBitmap( &Bitmap );
- L_InitBitmap( &Bitmap, 0, 0, 0);
- alloc_bitmap = 0;
- }
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- /* See if the file is a valid one */
- if (L_FileInfo(input_filename, &FileInfo) == SUCCESS)
- {
- if((FileInfo.Format != FILE_TIF) && (FileInfo.BitsPerPixel >= 8))
- {
- /* Decompress a LEAD, JTIF, or JFIF compressed file format
- directly to a BitMap*/
- if ( (ret=L_DecompressBitmap ( input_filename,
- &Bitmap, BIT24 )) == SUCCESS )
- {
- alloc_bitmap = 1;
- sprintf(TEXTP,"Image decompressed to a BitMap. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d Decompressing to the BitMap. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- if( L_DecompressBitmap1Bit(input_filename,&Bitmap) == SUCCESS)
- {
- alloc_bitmap = 1;
- sprintf(TEXTP,"Image decompressed to a BitMap. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d Decompressing to the BitMap. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- }
- else
- {
- /* not a valid file format */
- sprintf(TEXTP,"Invalid file format or file not found. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- break;
-
- case 12:/* Case compress a BitMap to a compressed format */
- /* Make sure BitMap is already being used and is filled with image data */
- if (alloc_bitmap == 1)
- {
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,18,9);
- if( Bitmap.BitsPerPixel > 1 )
- {
- sprintf(TEXTP,"0 LEAD, 1 JFIF, 2 JTIF, 3 LEAD1JFIF, 4 LEAD1JTIF, 5 LEAD2JFIF, 6 LEAD2JTF ?.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&compress_format,77,9);
- sprintf(TEXTP,"Qfactor 1 to 255 or LEAD defined PQ1, PQ2, QFS, QMS, QS, SQS, SQT, MCQ, MC ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(compress_qfactor,75,9);
- strupr(compress_qfactor);
- /* Check for a correct Qfactor entered */
- if ( (qfactor = get_qfactor(compress_qfactor)) == ERROR_QFACTOR)
- {
- sprintf(TEXTP,"Bad qfactor. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- /* If the user selected the LEAD compressed file format
- then ask to see if he/she would also like to save the
- VGA palette */
- if (compress_format != 0)
- save_palette = 0;
- else
- {
- sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&save_palette,36,9);
- while( (save_palette != 0) && (save_palette != 1) )
- {
- sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&save_palette,36,9);
- }
- }
- /* Compress the BitMap to a compressed file */
- if ( (ret = L_CompressBitmap ( &Bitmap,
- output_filename, compress_format,
- qfactor, save_palette )) == SUCCESS )
- {
- sprintf(TEXTP,"BitMap compressed. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- }
- else /* If the bitmap is a 1Bit then you must use L_CompressBitmap1Bit */
- {
- sprintf(TEXTP,"1 - CCITT, 2 - LEAD0, 3 - LEAD1, 10 - CCITTG31D, 11 - CCITTG32D, 12 - CCITTG4");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&compress_format,78,9);
- ret = L_CompressBitmap1Bit( &Bitmap,
- output_filename,
- compress_format ) ;
- sprintf(TEXTP,"BitMap compressed. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
-
- }
-
- if( ret != SUCCESS )
- {
- sprintf(TEXTP,"Error: %d compressing the BitMap. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
-
- }
- else
- {
- sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 13: /* Case Flip a BitMap */
- /* Flip vertical */
- /* Make sure BitMap is already being used and is filled with image data */
- if ( alloc_bitmap == 0 )
- {
- sprintf(TEXTP,"Error: No storage has been allocated for a BitMap. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- /* Flip an image in the BitMap (top to bottom) */
- if ( (ret = L_FlipBitmap( &Bitmap )) == SUCCESS)
- {
- sprintf(TEXTP,"Image fliped. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d could not flip image. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 14: /* Case reverse an image in a BitMap */
- /* Flip horizontal */
- /* Make sure BitMap is already being used and is filled with image data */
- if ( alloc_bitmap == 0 )
- {
- sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- /* Reverse an image in a BitMap (left to right) */
- if ( (ret = L_ReverseBitmap( &Bitmap )) == SUCCESS)
- {
- sprintf(TEXTP,"Image reversed. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d Reversing the image. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 15: /* Case resize the image in the BitMap */
- /* Make sure BitMap is already being used and is filled with image data */
- if ( alloc_bitmap == 0 )
- {
- sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- sprintf(TEXTP,"New BitMap width: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&new_width,19,9);
- sprintf(TEXTP,"New BitMap height: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&new_height,20,9);
- /* Will alocate room and initialize a new Bitmap while keeping
- the original BitMap. Then the original BitMap location is released. */
- /* Initialize fields in a BitMap handle. */
- L_InitBitmap( &NewBitmap, new_width, new_height,
- Bitmap.BitsPerPixel ) ;
-
- /* Allocate storage to hold an image in a BitMap handle. */
- if ( (ret = L_AllocateBitmap( &NewBitmap,
- TYPE_NOCONV )) == SUCCESS )
- {
- /* Resizes image currently in BitMap handle, to the output BitMap
- handle. Since the new BitMap structure contains the new width
- and height just call L_ResizeBitmap() */
- if ( (ret = L_ResizeBitmap( &Bitmap, &NewBitmap ))
- == SUCCESS )
- {
- L_FreeBitmap( &Bitmap ); /* Free the old BitMap */
- L_CopyBitmapHandle( &Bitmap, &NewBitmap ); /* Copy the old BitMap handle
- to the new one */
- sprintf(TEXTP,"BitMap resized in NewBitMap.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d Resizing the BitMap. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: %d Alloctating a new bitmap for resizing. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 16: /* Rotate an image in a bitmap */
- if ( alloc_bitmap == 0 )
- {
- sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- sprintf(TEXTP,"Rotate by (degrees):");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint( &xpos,21,3 ) ;
- sprintf(TEXTP,"Resize? (0=No, 1=Yes):");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint( &output_format,23,3 ) ;
- L_RotateBitmap( &Bitmap, xpos, output_format ) ;
- sprintf(TEXTP,"Bitmap Rotated! Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- break;
-
- case 17: /* Case Dither an image for 256 colors LEAD's Fixed Palette */
- /* Make sure BitMap is already being used and is filled with image data */
- if ( alloc_bitmap == 0 )
- {
- sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- /* Make sure that the image needs to be optimized
- to 256 colors */
- if (Bitmap.BitsPerPixel >= 8)
- {
- /* Dither the bitmap to LEAD's 256 color Fixed palette */
- if ( L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- sprintf(TEXTP,"Error: Can't load table FIXED.DAT. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break ;
- }
-
- if ( (ret = L_DitherBitmap( &Bitmap, BURKES_DITHERING, 8 )) == SUCCESS)
- {
- sprintf(TEXTP,"Bitmap Ditherd OK. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- L_FreeRGBFixedPalette() ;
- }
- else
- {
- sprintf(TEXTP,"Error: %d Optimizing the BitMap. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- L_FreeRGBFixedPalette() ;
- putch(7);
- }
- }
- else
- { /* You cannot Dither 4 bits/pixel image */
- sprintf(TEXTP,"Cannot Dither a %d bits/pixel BitMap. Press any key to continue.",Bitmap.BitsPerPixel);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,RED,9);
- putch(7);
- }
- break;
-
- case 18: /* Case optimize an image for 256 colors */
- /* Make sure BitMap is already being used and is filled with image data */
- if ( alloc_bitmap == 0 )
- {
- sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- /* Make sure that the image needs to be optimized
- to 256 colors */
- if (Bitmap.BitsPerPixel >= 16)
- {
- /* Selecting the best 256 colors to represent the image.
- This function will allocate and put the 256 color image
- in NewBitmap */
- if ( (ret = L_OptimizeBitmap ( &Bitmap, &NewBitmap, NO_DITHERING, 256 )) == SUCCESS)
- {
- /* Free the storage for the old BitMap */
- L_FreeBitmap( &Bitmap );
- /* Copy the old BitMap handle to the new one */
- L_CopyBitmapHandle( &Bitmap, &NewBitmap );
- sprintf(TEXTP,"Bitmap optimized. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d Optimizing the BitMap. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- { /* You cannot optimize 4 or 8 bits/pixel image */
- sprintf(TEXTP,"Cannot optimize a %d bits/pixel BitMap. Press any key to continue.",Bitmap.BitsPerPixel);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,RED,9);
- putch(7);
- }
- break;
-
-
-
- case 19: /* Case clear a BitMap */
- /* Make sure BitMap is already being used and is filled with image data */
- if ( alloc_bitmap == 0 )
- {
- sprintf(TEXTP,"Error: No image in BitMap allocated. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- /* Clear the BitMap and fill it with zeros */
- if ( (ret = L_ClearBitmap( &Bitmap )) == SUCCESS )
- {
- sprintf(TEXTP,"BitMap cleared and filled with zeros OK. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d Clearing the BitMap. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 20: /* Case change BitMap bosition */
- /* Make sure BitMap is already being used and is filled with image data */
- if ( alloc_bitmap == 0 )
- {
- sprintf(TEXTP,"Error: No image in BitMap allocated. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- sprintf(TEXTP,"New BitMap X position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&xpos,24,9);
- sprintf(TEXTP,"New BitMap Y position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&ypos,24,9);
- /* Set new X, Y positions in a BitMap handle.
- The X and Y positions will be used as the starting
- offset when displaying this BitMap */
- L_SetBitmapPos( &Bitmap, xpos, ypos);
- sprintf(TEXTP,"Set BitMap position OK. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- break;
-
- case 21: /* Case view BitMap to TARGA */
- /* Is a TARGA installed OK? */
- if (TARGA_FLAG)
- {
- /* Make sure BitMap is already being used and is filled with image data */
- if ( alloc_bitmap == 0 )
- {
- sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- /* View the BitMap to the TARGA graphics adapter */
- if ( (ret = L_ViewBitmapTarga( &Bitmap, 0, 0 )) == SUCCESS )
- {
- sprintf(TEXTP,"BitMap viewed to TARGA successfully. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d viewing to the TARGA screen. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: TARGA board initialization. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 22: /* Case view a BitMap on the VGA/SuperVGA screen */
- /* Make sure BitMap is already being used and is filled with image data */
- if ( alloc_bitmap == 0 )
- {
- sprintf(TEXTP,"Error: No image in the BitMap allocated. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- /* Make sure that the image has no more than 256 colors */
- sprintf(TEXTP,"New viewing screen width 0 for no resize: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&new_width,43,9);
- sprintf(TEXTP,"New viewing screen height 0 for no resize: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&new_height,43,9);
- /* View the BitMap with the new width and height.
- This will display the image with the new width and height
- but will not change the original BitMap's width and height */
- if( L_ViewBitmapScreen(&Bitmap,new_width,new_height) == ERROR_NOT_256_COLOR )
- {
- ClearTheScreen();
- sprintf(TEXTP,"This is a %d bit/pixel image containing more that 256 colors.", Bitmap.BitsPerPixel);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,480-YCHR);
- sprintf(TEXTP,"An 8bit VGA/SuperVGA card can only handle up to 256 colors.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,480-(YCHR*2));
- sprintf(TEXTP,"To view this image you must first Dither the BitMap to LEAD's fixed palette.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,480-(YCHR*3));
- sprintf(TEXTP,"This will convert the bitmap to LEAD's Fixed 256 color palette.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,480-(YCHR*5));
- sprintf(TEXTP,"Or Optimize the the Bitmap to the best 256 colors to represent the image.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,480-(YCHR*6));
- sprintf(TEXTP,"Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,480-(YCHR*7));
- putch(7);
- }
- break;
-
- case 23: /* Case view TGA file to TARGA screen */
- /* Is a TARGA installed OK? */
- if (TARGA_FLAG)
- {
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&xpos,56,9);
- sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&ypos,56,9);
- sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&width,52,9);
- sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&height,52,9);
- if ( (ret = L_ShowTGATarga(input_filename,width,height,xpos, ypos)) ==SUCCESS)
- {
- sprintf(TEXTP,"%s successfully loaded to TARGA. Press any key to continue.",input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d Viewing to the TARGA. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: TARGA board initialization. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 24: /* Case view TGA file to VGA screen */
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- /* See if the file is a valid format and fill the FileInfo structure */
- if (L_FileInfo(input_filename, &FileInfo) == SUCCESS)
- {
- if (FileInfo.Format == FILE_TGA)
- {
- sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&xpos,56,9);
- sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&ypos,56,9);
- sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&width,52,9);
- sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&height,52,9);
-
- if ( device_bits == 8 && L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- sprintf(TEXTP,"Error: cannot load fixed palette data file FIXED.DAT.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- break ;
- }
- if ( (ret = L_ShowTGAScreen(input_filename,width,height,
- xpos, ypos)) == SUCCESS)
- {
- /* Displayed to VGA OK */
- /*Free the RGB table from memory*/
- if (device_bits == 8)
- L_FreeRGBFixedPalette();
- }
- else
- {
- /*Free the RGB table from memory*/
- if (device_bits == 8)
- L_FreeRGBFixedPalette();
- sprintf(TEXTP,"Error: %d viewing VGA. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: %s invalid TGA file format. Press any key to continue.", input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: %s not a supported file format. Press any key to continue.", input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 25: /* Case view PCX file to TARGA */
- /* Is a TARGA installed OK */
- if (TARGA_FLAG)
- {
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&xpos,56,9);
- sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&ypos,56,9);
- sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&width,52,9);
- sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&height,52,9);
- if ( (ret = L_ShowPCXTarga(input_filename,width,
- height,xpos, ypos)) ==SUCCESS)
- {
- sprintf(TEXTP,"%s successfully loaded to TARGA. Press any key to continue.",input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d viewing to the TARGA. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: TARGA board initialization. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 26: /* Case view PCX file to VGA */
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&xpos,56,9);
- sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&ypos,56,9);
- sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&width,52,9);
- sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&height,52,9);
- if ( device_bits == 8 && L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- sprintf(TEXTP,"Error: cannot load fixed palette data file FIXED.DAT.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- break ;
- }
- if ( (ret = L_ShowPCXScreen(input_filename,width,height,
- xpos, ypos)) ==SUCCESS)
- {
- /* displayed to VGA OK */
- /*Free the RGB Fixed Palette*/
- if (device_bits == 8)
- L_FreeRGBFixedPalette();
- }
- else
- {
- /*Free the RGB table from memory*/
- if (device_bits == 8)
- L_FreeRGBFixedPalette();
- sprintf(TEXTP,"Error: %d viewing to VGA. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 27: /* Case view GIF file to TARGA */
- /* Is a TARGA installed OK */
- if (TARGA_FLAG)
- {
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&xpos,56,9);
- sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&ypos,56,9);
- sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&width,52,9);
- sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&height,52,9);
- if ( (ret = L_ShowGIFTarga(input_filename,width,height,
- xpos, ypos)) ==SUCCESS)
- {
- sprintf(TEXTP,"%s successfully loaded to TARGA. Press any key to continue.",input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d viewing to TARGA. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: TARGA board initialization. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 28: /* Case view GIF to VGA */
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&xpos,56,9);
- sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&ypos,56,9);
- sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&width,52,9);
- sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&height,52,9);
- if ( (ret = L_ShowGIFScreen(input_filename,width,height,
- xpos, ypos)) ==SUCCESS)
- {
- /* displayed to VGA OK */
- }
- else
- {
- sprintf(TEXTP,"Error: %d viewing VGA. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 29: /* Case view TIF to TARGA */
- /* Is a TARGA installed OK */
- if (TARGA_FLAG)
- {
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&xpos,56,9);
- sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&ypos,56,9);
- sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&width,52,9);
- sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&height,52,9);
- if ( (ret = L_ShowTIFTarga(input_filename,width,height,
- xpos, ypos)) ==SUCCESS)
- {
- sprintf(TEXTP,"%s successfully loaded to TARGA. Press any key to continue.",input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d viewing to the TARGA. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: TARGA board initialization. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 30: /* Case view TIF to VGA */
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- /* See if the file is a valid format and fill the FileInfo structure */
- if (L_FileInfo(input_filename, &FileInfo) == SUCCESS)
- {
- if (FileInfo.Format == FILE_TIF)
- {
- sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&xpos,56,9);
- sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&ypos,56,9);
- sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&width,52,9);
- sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&height,52,9);
- if ( device_bits == 8 && L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- sprintf(TEXTP,"Error: cannot load fixed palette data file FIXED.DAT .");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- break ;
- }
- if ( (ret = L_ShowTIFScreen(input_filename,width,height,
- xpos, ypos)) ==SUCCESS)
- {
- /* Displayed to VGA OK */
- /*Free the RGB table from memory*/
- if (device_bits == 8)
- L_FreeRGBFixedPalette();
- }
- else
- {
- /*Free the RGB table from memory*/
- if (device_bits == 8)
- L_FreeRGBFixedPalette();
- sprintf(TEXTP,"Error: %d viewing VGA. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: %s Invalid TIF file format. Press any key to continue.",input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: %s not a supported file format. Press any key to continue.", input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 31: /* Case view BMP to TARGA */
- /* Is a TARGA installed OK */
- if (TARGA_FLAG)
- {
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&xpos,56,9);
- sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&ypos,56,9);
- sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&width,52,9);
- sprintf(TEXTP,"Display height, or 0 for current Heigth in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&height,52,9);
- if ( (ret = L_ShowBMPTarga(input_filename,width,height,
- xpos, ypos)) ==SUCCESS)
- {
- sprintf(TEXTP,"%s successfully loaded to TARGA. Press any key to continue.",input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d viewing to the TARGA. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: TARGA board initialization. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 32: /* Case view BMP to VGA */
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16,0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- /* See if the file is a valid format and fill the FileInfo structure */
- if (L_FileInfo(input_filename, &FileInfo) == SUCCESS)
- {
- if (FileInfo.Format == FILE_BMP)
- {
- sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&xpos,56,9);
- sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&ypos,56,9);
- sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&width,52,9);
- sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&height,52,9);
- if ( device_bits == 8 && L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- sprintf(TEXTP,"Error: cannot load fixed palette data file FIXED.DAT.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- break ;
- }
- if ( (ret = L_ShowBMPScreen(input_filename,width,height,
- xpos, ypos)) ==SUCCESS)
- {
- /* Displayed to VGA OK */
- /*Free the RGB table from memory*/
- if (device_bits == 8)
- L_FreeRGBFixedPalette();
- }
- else
- {
- /*Free the RGB table from memory*/
- if (device_bits == 8)
- L_FreeRGBFixedPalette();
- sprintf(TEXTP,"Error: %d viewing VGA. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: %s invalid BMP file format. Press any key to continue.", input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: %s Not a supported file format. Press any key to continue.", input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 33: /* Case decompress or display a compressed file to TARGA screen */
- /* Is a TARGA installed OK */
- if (TARGA_FLAG)
- {
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&xpos,56,9);
- sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&ypos,56,9);
- if ( (ret = L_DecompressTARGAScreen(input_filename,
- 0, 0, xpos, ypos)) == SUCCESS)
- {
- sprintf(TEXTP,"Decompress %s to TARGA screen. Press any key to continue.",input_filename );
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d Decompressing to TARGA. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: Cannot initialize TARGA board. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 34: /* Decompress a compressed file to the VGA screen */
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Starting X display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&xpos,56,9);
- sprintf(TEXTP,"Starting Y display position, or 0 for normal position: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&ypos,56,9);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- sprintf(TEXTP,"Display width, or 0 for current Width in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&width,52,9);
- sprintf(TEXTP,"Display height, or 0 for current Height in the file: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&height,52,9);
- if (device_bits == 8)
- {
- /**** load the fixed palette table to memory ****/
- if ( L_LoadFixedPalette(path) != SUCCESS)
- {
- sprintf(TEXTP,"Error: cannot load fixed palette data file FIXEDPAL.DAT.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- break ;
- }
- }
-
- if ( (ret = L_DecompressVGAScreenFP(input_filename, width, height,xpos, ypos)) == SUCCESS)
- {
- /*free the fixed palette table FIXEDPAL.DAT*/
- if (device_bits == 8)
- L_FreeFixedPalette();
- /* Decompression to VGA was OK */
- ;
- }
- else
- {
- /*free the fixed palette table FIXEDPAL.DAT*/
- if (device_bits == 8)
- L_FreeFixedPalette();
- sprintf(TEXTP,"Error: %d Decompressing to VGA. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 35: /* Case compress TGA file */
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,18,9);
- sprintf(TEXTP,"0 LEAD, 1 JFIF, 2 JTIF, 3 LEAD1JFIF, 4 LEAD1JTIF, 5 LEAD2JFIF, 6 LEAD2JTF ?.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&compress_format,77,9);
- sprintf(TEXTP,"Qfactor 1 to 255 or LEAD defined PQ1, PQ2, QFS, QMS, QS, SQS, SQT, MCQ, MC ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(compress_qfactor,75,9);
- if (compress_format != 0)
- save_palette = 0;
- else
- {
- sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&save_palette,36,9);
- while( (save_palette != 0) && (save_palette != 1) )
- {
- sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&save_palette,36,9);
- }
- }
- strupr(compress_qfactor);
- if ( (qfactor = get_qfactor(compress_qfactor)) == ERROR_QFACTOR)
- {
- sprintf(TEXTP,"Error: Bad qfactor. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- if ( (ret = L_CompressTGA(input_filename, output_filename, compress_format,
- qfactor, save_palette, 0)) == SUCCESS)
- {
- sprintf(TEXTP,"File: %s compressed to %s. Press any key to continue.",input_filename,output_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d compressing %s. Press any key to continue.", ret,input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 36: /* Case decompress to TGA file */
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,18,9);
- sprintf(TEXTP,"Output format 1 - TGA8, 2 - TGA16, 3 - TGA24, 4 - TGA32: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&intinput,58,9);
- if(intinput==1)
- {
- if ( L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- sprintf(TEXTP,"Error: Can't load FIXED.DAT fixed palette file. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break ;
- }
- output_format=TGA8;
- }
- else if(intinput==2)
- output_format=TGA16;
- else if(intinput==3)
- output_format=TGA24;
- else if(intinput==4)
- output_format=TGA32;
- else
- {
- sprintf(TEXTP,"%d not a valid option",intinput);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getch();
- break;
- }
- if ( (ret = L_DecompressTGA(input_filename, output_filename, output_format))
- == SUCCESS)
- {
- sprintf(TEXTP,"File: %s Decompressed to %s (TGA). Press any key to continue. ",input_filename,output_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- if(output_format==TGA8)
- L_FreeRGBFixedPalette();
- }
- else
- {
- sprintf(TEXTP,"Error: %d Decompressing to TGA. Press any key to continue. ", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- if(output_format==TGA8)
- L_FreeRGBFixedPalette();
- putch(7);
- }
- break;
-
- case 37: /* Case compress PCX file */
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,18,9);
- sprintf(TEXTP,"0 LEAD, 1 JFIF, 2 JTIF, 3 LEAD1JFIF, 4 LEAD1JTIF, 5 LEAD2JFIF, 6 LEAD2JTF ?.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&compress_format,77,9);
- sprintf(TEXTP,"Qfactor 1 to 255 or LEAD defined PQ1, PQ2, QFS, QMS, QS, SQS, SQT, MCQ, MC ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(compress_qfactor,75,9);
- if (compress_format != 0)
- save_palette = 0;
- else
- {
- sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&save_palette,36,9);
- while( (save_palette != 0) && (save_palette != 1) )
- {
- sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&save_palette,36,9);
- }
- }
- strupr(compress_qfactor);
- if ( (qfactor = get_qfactor(compress_qfactor)) == ERROR_QFACTOR)
- {
- sprintf(TEXTP,"Error: Bad qfactor.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- break;
- }
- if ( (ret = L_CompressPCX(input_filename, output_filename, compress_format,
- qfactor, save_palette)) == SUCCESS)
- {
- sprintf(TEXTP,"File: %s compressed to %s. Press any key to continue.",input_filename,output_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d compressing %s. Press any key to continue.", ret,input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 38: /* Case decompress to PCX file*/
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,18,9);
- sprintf(TEXTP,"Output format 1 - PCX8, 2 - PCX24: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&intinput,38,9);
- if(intinput==1)
- {
- if ( L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- sprintf(TEXTP,"Error: Can't load FIXED.DAT fixed palette file. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break ;
- }
- output_format=PCX8;
- }
- else if(intinput==2)
- output_format=PCX24;
- else
- {
- sprintf(TEXTP,"%d not a valid option",intinput);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getch();
- break;
- }
- if ( (ret = L_DecompressPCX(input_filename, output_filename, output_format))
- == SUCCESS)
- {
- sprintf(TEXTP,"%s Decompressed to %s (PCX). Press any key to continue. ",input_filename,output_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- if(output_format==PCX8)
- L_FreeRGBFixedPalette();
-
- }
- else
- {
- sprintf(TEXTP,"Error: %d Decompressing to PCX. Press any key to continue. ", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- if( (output_format==PCX8) && (FileInfo.BitsPerPixel==8))
- L_FreeFixedPalette();
- else if(output_format==PCX8)
- L_FreeRGBFixedPalette();
- putch(7);
- }
- break;
-
- case 39: /* Case compress GIF file */
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,18,9);
- sprintf(TEXTP,"0 LEAD, 1 JFIF, 2 JTIF, 3 LEAD1JFIF, 4 LEAD1JTIF, 5 LEAD2JFIF, 6 LEAD2JTF ?.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&compress_format,77,9);
- sprintf(TEXTP,"Qfactor 1 to 255 or LEAD defined PQ1, PQ2, QFS, QMS, QS, SQS, SQT, MCQ, MC ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(compress_qfactor,75,9);
- if (compress_format != 0)
- save_palette = 0;
- else
- {
- sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&save_palette,36,9);
- while( (save_palette != 0) && (save_palette != 1) )
- {
- sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&save_palette,36,9);
- }
- }
- strupr(compress_qfactor);
- if ( (qfactor = get_qfactor(compress_qfactor)) == ERROR_QFACTOR)
- {
- sprintf(TEXTP,"Error: Bad qfactor. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- if ( (ret = L_CompressGIF(input_filename, output_filename, compress_format,
- qfactor, save_palette)) == SUCCESS)
- {
- sprintf(TEXTP,"File: %s compressed to %s. Press any key to continue.",input_filename,output_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d compressing %s. Press any key to continue.", ret,input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 40: /* Case decompress to GIF file */
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,18,9);
- if (L_FileInfo(input_filename, &FileInfo) == SUCCESS)
- {
- if ( L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- sprintf(TEXTP,"Error: Can't load FIXED.DAT fixed palette file. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break ;
- }
- output_format=GIF8;
- }
- if ( (ret = L_DecompressGIF(input_filename, output_filename, output_format))
- == SUCCESS)
- {
- sprintf(TEXTP,"File: %s decompressed to %s (GIF). Press any key to continue. ",input_filename,output_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- L_FreeRGBFixedPalette();
- }
- else
- {
- sprintf(TEXTP,"Error: %d Decompressing to GIF. Press any key to continue. ", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- L_FreeRGBFixedPalette();
- putch(7);
- }
- break;
-
- case 41: /* Case compress TIF file */
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,18,9);
- sprintf(TEXTP,"0 LEAD, 1 JFIF, 2 JTIF, 3 LEAD1JFIF, 4 LEAD1JTIF, 5 LEAD2JFIF, 6 LEAD2JTF ?.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&compress_format,77,9);
- sprintf(TEXTP,"Qfactor 1 to 255 or LEAD defined PQ1, PQ2, QFS, QMS, QS, SQS, SQT, MCQ, MC ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(compress_qfactor,75,9);
- if (compress_format != 0)
- save_palette = 0;
- else
- {
- sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&save_palette,36,9);
- while( (save_palette != 0) && (save_palette != 1) )
- {
- sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&save_palette,36,9);
- }
- }
- strupr(compress_qfactor);
- if ( (qfactor = get_qfactor(compress_qfactor)) == ERROR_QFACTOR)
- {
- sprintf(TEXTP,"Error: Bad qfactor. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- break;
- }
- if ( (ret = L_CompressTIF(input_filename, output_filename, compress_format,
- qfactor, save_palette)) == SUCCESS)
- {
- sprintf(TEXTP,"File %s compressed to %s. Press any key to continue.",input_filename,output_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d compressing %s. Press any key to continue.", ret,input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
- case 42: /* Case decompress to a TIF file */
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,18,9);
- sprintf(TEXTP,"Output format 1 - TIF8, 2 - TIF16, 3 - TIF24: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&intinput,47,9);
- if(intinput==1)
- {
- if ( L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- sprintf(TEXTP,"Error: Can't load FIXED.DAT fixed palette file. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break ;
- }
- output_format=TIF8;
- }
- else if(intinput==2)
- output_format=TIF16;
- else if(intinput==3)
- output_format=TIF24;
- else
- {
- sprintf(TEXTP,"%d not a valid option",intinput);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getch();
- break;
- }
- if ( (ret = L_DecompressTIF(input_filename, output_filename, output_format))
- == SUCCESS)
- {
- sprintf(TEXTP,"File: %s Decompressed to %s (TIF). Press any key to continue. ",input_filename,output_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- if(output_format==TIF8)
- L_FreeRGBFixedPalette();
- }
- else
- {
- sprintf(TEXTP,"Error: %d Decompressiing to TIF. Press any key to continue. ", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- if(output_format==TIF8)
- L_FreeRGBFixedPalette();
- }
- break;
-
- case 43: /* Case compress a BMP file */
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,18,9);
- sprintf(TEXTP,"0 LEAD, 1 JFIF, 2 JTIF, 3 LEAD1JFIF, 4 LEAD1JTIF, 5 LEAD2JFIF, 6 LEAD2JTF ?.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&compress_format,77,9);
- sprintf(TEXTP,"Qfactor 1 to 255 or LEAD defined PQ1, PQ2, QFS, QMS, QS, SQS, SQT, MCQ, MC ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(compress_qfactor,18,9);
- if (compress_format != 0)
- save_palette = 0;
- else
- {
- sprintf(TEXTP,"Save VGA palette? 0 - No, 1 - YES: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&save_palette,36,9);
- while( (save_palette != 0) && (save_palette != 1) )
- {
- sprintf(TEXTP,"Save VGA palette? to? 0 - No, 1 - YES: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&save_palette,39,9);
- }
- }
- strupr(compress_qfactor);
- if ( (qfactor = get_qfactor(compress_qfactor)) == ERROR_QFACTOR)
- {
- sprintf(TEXTP,"Error: Bad qfactor. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- break;
- }
- if ( (ret = L_CompressBMP(input_filename, output_filename, compress_format,
- qfactor, save_palette)) == SUCCESS)
- {
- sprintf(TEXTP,"File: %s compressed to %s. Press any key to continue.",input_filename,output_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d compressing %s. Press any key to continue.", ret,input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
-
- case 44: /* Case decompress to BMP file */
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,18,9);
- sprintf(TEXTP,"Output format 1 -BMP8, 2 -BMP24, 3 -PM8, 4 -PM24: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&intinput,36,9);
- if(intinput==1)
- {
- if ( L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- sprintf(TEXTP,"Error: Can't load FIXED.DAT fixed palette file. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break ;
- }
- output_format=BMP8;
- }
- else if(intinput==2)
- output_format=BMP24;
- else if(intinput==3)
- {
- if ( L_LoadRGBFixedPalette(path) != SUCCESS)
- {
- sprintf(TEXTP,"Error: Can't load FIXED.DAT fixed palette file. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break ;
- }
- output_format=PM8;
- }
- else if(intinput==4)
- output_format=PM24;
- else
- {
- sprintf(TEXTP,"%d not a valid option",intinput);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getch();
- break;
- }
- if ( (ret = L_DecompressBMP(input_filename, output_filename, output_format))
- == SUCCESS)
- {
- sprintf(TEXTP,"File: %s decompressed to %s (BMP). Press any key to continue. ",input_filename,output_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- if( (output_format==PM8)||(output_format==PM8) )
- L_FreeRGBFixedPalette();
- }
- else
- {
- sprintf(TEXTP,"Error: %d Decompressing to BMP. Press any key to continue. ", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- L_FreeRGBFixedPalette();
- putch(7);
- }
- break;
-
- case 45: /* Case compress TARGA screen */
- /* Is a TARGA installed OK */
- if (TARGA_FLAG)
- {
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,18,9);
- sprintf(TEXTP,"0 LEAD, 1 JFIF, 2 JTIF, 3 LEAD1JFIF, 4 LEAD1JTIF, 5 LEAD2JFIF, 6 LEAD2JTF ?.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&compress_format,77,9);
- sprintf(TEXTP,"Qfactor 1 to 255 or LEAD defined PQ1, PQ2, QFS, QMS, QS, SQS, SQT, MCQ, MC ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(compress_qfactor,75,9);
- strupr(compress_qfactor);
- if ( (qfactor = get_qfactor(compress_qfactor)) == ERROR_QFACTOR)
- {
- sprintf(TEXTP,"Error: Bad qfactor. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- if ( (ret = L_CompressTarga(output_filename, compress_format,
- qfactor )) == SUCCESS )
- {
- sprintf(TEXTP,"File: %s TARGA screen compressed. Press any key to continue.",output_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d TARGA screen compression.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- }
- else
- {
- sprintf(TEXTP,"Error: Cannot initialize TARGA board. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
-
- case 46: /* Gase get file info */
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- if (L_FileInfo(input_filename, &FileInfo) != SUCCESS)
- {
- sprintf(TEXTP,"Error: %s Unrecognized file format. Press any key to continue.",input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- if (FileInfo.Format == FILE_PCX)
- {
- sprintf(TEXTP,"%s Format=PCX, Width=%d, Height=%d, Bits/Pixel=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- if (FileInfo.Format == FILE_GIF)
- {
- sprintf(TEXTP,"%s Format=GIF, Width=%d, Height=%d, Bits/Pixel=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- if (FileInfo.Format == FILE_TIF)
- {
- sprintf(TEXTP,"%s Format=TIF, Width=%d, Height=%d, Bits/Pixel=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- if (FileInfo.Format == FILE_TGA)
- {
- sprintf(TEXTP,"%s Format=TGA, Width=%d, Height=%d, Bits/Pixel=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- if (FileInfo.Format == FILE_CMP)
- {
- sprintf(TEXTP,"%s Format=LEAD CMP, Width=%d, Height=%d, Bits/Pixel=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- if (FileInfo.Format == FILE_BMP)
- {
- sprintf(TEXTP,"%s Format=Windows BMP, Width=%d, Height=%d, Bits/Pixel=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- if (FileInfo.Format == FILE_OS2)
- {
- sprintf(TEXTP,"%s Format=OS2 BMP, Width=%d, Height=%d, Bits/Pixel=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
-
- else
- if (FileInfo.Format == FILE_JFIF)
- {
- sprintf(TEXTP,"%s JPEG File Interchange Format, Width=%d, Height=%d, B/P=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- if (FileInfo.Format == FILE_JTIF)
- {
- sprintf(TEXTP,"%s JPEG TIF Width=%d, Height=%d, B/P=%d",input_filename, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel );
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- break;
-
-
-
- case 47: /* Case convert a file */
- sprintf(TEXTP,"Input file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,18,9);
- if (L_FileInfo(input_filename, &FileInfo) != SUCCESS)
- {
- sprintf(TEXTP,"Error: %s Unknown file format. Press any key to continue.",input_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- input_format = FileInfo.Format;
- sprintf(TEXTP,"Output file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(output_filename,18,9);
- sprintf(TEXTP,"Output format 1 -PCX, 2 -GIF, 3 -TIF, 4 -TGA, 5 -Windows BMP, 6 -OS2 BMP : ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&intinput,76,9);
- if(intinput==1)
- output_format=FILE_PCX;
- else if(intinput==2)
- output_format=FILE_GIF;
- else if(intinput==3)
- output_format=FILE_TIF;
- else if(intinput==4)
- output_format=FILE_TGA;
- else if(intinput==5)
- output_format=FILE_BMP;
- else if(intinput==6)
- output_format=FILE_OS2;
- else
- {
- sprintf(TEXTP,"%d not a valid option",intinput);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getch();
- break;
- }
- if ( (output_format != FILE_PCX) && (output_format != FILE_GIF)
- && (output_format != FILE_TIF) && (output_format != FILE_TGA)
- && (output_format != FILE_BMP)
- && (output_format != FILE_OS2) )
- {
- sprintf(TEXTP,"Error: Unknown file format. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- sprintf(TEXTP,"New width or 0 for same as original: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&new_width,37,9);
- sprintf(TEXTP,"New height or 0 for same as original: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&new_height,38,9);
- sprintf(TEXTP,"BitsPerPixel: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&BitsPerPixel,14,9);
- if (output_format == FILE_PCX)
- {
- if ( (BitsPerPixel != 1) && (BitsPerPixel != 4) && (BitsPerPixel != 8) && (BitsPerPixel != 24))
- {
- sprintf(TEXTP,"Error: PCX can only be 1, 4, or 8-Bits/pixel. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- }
- else
- if (output_format == FILE_GIF)
- {
- if ( (BitsPerPixel != 8) )
- {
- sprintf(TEXTP,"Error: GIF can only be 8-Bits/pixel. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- }
- else
- if (output_format == FILE_TIF)
- {
- if ( (BitsPerPixel != 1) && (BitsPerPixel != 8)
- && (BitsPerPixel != 16) && (BitsPerPixel != 24) )
- {
- sprintf(TEXTP,"Error: TIF can only be 1, 8, or 24-Bits/pixel. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- }
- else
- if (output_format == FILE_TGA)
- {
- if ( (BitsPerPixel != 8) && (BitsPerPixel != 16)
- && (BitsPerPixel != 24) && (BitsPerPixel != 32) )
- {
- sprintf(TEXTP,"Error: TGA can only be 8, 16, 24, or 32-Bits/pixel. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- }
- else
- if (output_format == FILE_BMP || output_format == FILE_OS2)
- {
- if ( (BitsPerPixel != 4) && (BitsPerPixel != 8)
- && (BitsPerPixel != 24) )
- {
- sprintf(TEXTP,"Error: BMP can only be 4, 8, or 24 Bits/pixel. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- }
- if ( (ret=L_FileConvert( input_filename,input_format,
- output_filename, output_format, new_width,
- new_height, BitsPerPixel )) == SUCCESS)
- {
- sprintf(TEXTP,"File: %s converted to %s successfully.", input_filename, output_filename);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d File convert. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- break;
-
-
- case 48: /* Case get video information */
- L_GetVideoInfo(&videotype, &width, &height);
- if (videotype == VIDEO_EGA)
- {
- sprintf(TEXTP,"VIDEO TYPE = EGA Width = %d, Height = %d",width, height);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- if (videotype == VIDEO_VGA)
- {
- sprintf(TEXTP,"VIDEO TYPE = Standared VGA with 256K of memory Width = %d, Height = %d",width, height);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- if (videotype == VIDEO_SVGA)
- {
- sprintf(TEXTP,"VIDEO TYPE = SuperVGA with 512K or more memory Width = %d, Height = %d",width, height);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- break;
-
- case 49: /* Case set video resolution */
- #ifdef TARGA /* If TARGA 16,24,32 is used not a TARGA+.
- The TARGA+ can be chages to multiple resolutions
- I cant not chage the old TARGA 16,24,32 only TARGA+*/
- sprintf(TEXTP,"MAX VGA resolution 0-320x200, 1-640x350, 2-640x480, 3-800x600, 4-1024x768. ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&video_size,74,9);
- /* Checks for legal VGA/SuperVGA resolution */
- if ( (video_size != SIZE_640x350)
- && (video_size != SIZE_640x480) && (video_size != SIZE_800x600)
- && (video_size != SIZE_1024x768) )
- {
- if(video_size == SIZE_320x200)
- {
- sprintf(TEXTP,"This demo must run at 640X480 or higher resolution.",width, height);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- else
- {
- sprintf(TEXTP,"Error: Unknown VGA resolution %d. Press any key to continue.",video_size);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- }
- L_SetVideoMode(3, 0);
- L_SetVGASize(video_size) ;
- L_GetVideoDeviceBits(&device_bits);
- sprintf(TEXTP,"VGA size set OK! Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- #else /** If TARGA+ is used NOT a TARGA 16, 24, 32**/
- sprintf(TEXTP," 0 - Set VGA resolution. 1 - Set TARGA+ resolution.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&input_format,52,9);
- if (input_format == 0)
- {
- sprintf(TEXTP,"MAX VGA resolution 0-320x200, 1-640x350, 2-640x480, 3-800x600, 4-1024x768: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&video_size,75,9);
- /* Checks for legal VGA/SuperVGA resolution */
- if ( (video_size != SIZE_640x350)
- && (video_size != SIZE_640x480) && (video_size != SIZE_800x600)
- && (video_size != SIZE_1024x768) )
- {
- if(video_size == SIZE_320x200)
- {
- sprintf(TEXTP,"This demo must run at 640X480 or higher resolution.",width, height);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- else
- {
- sprintf(TEXTP,"Error: Unknown VGA resolution %d. Press any key to continue.",video_size);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- }
- L_SetVideoMode(3, 0);
- L_SetVGASize(video_size) ; /* Set new VGA resolution */
- L_GetVideoDeviceBits(&device_bits);
- sprintf(TEXTP,"VGA size set OK! Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else if(input_format == 1)
- {
- ClearTheScreen();
-
- sprintf(TEXTP," 0 - Interlaced 512x400x16."); /* TARGA+ modes available */
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-YCHR);
- sprintf(TEXTP," 1 - Noninterlaced 512x400x16.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*2));
- sprintf(TEXTP," 2 - Interlaced 512x400x32.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*3));
- sprintf(TEXTP," 3 - Noninterlaced 512x400x32.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*4));
- sprintf(TEXTP," 4 - Interlaced 512x486x16.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*5));
- sprintf(TEXTP," 5 - Noninterlaced 512x486x16.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*6));
- sprintf(TEXTP," 6 - Interlaced 512x486x32.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*7));
- sprintf(TEXTP," 7 - Noninterlaced 512x486x32.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*8));
- sprintf(TEXTP," 8 - Interlaced 640x480x16.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*9));
- sprintf(TEXTP," 9 - Noninterlaced 640x480x16.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*10));
- sprintf(TEXTP," 10 - SquareInterlaced 640x486x16.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*11));
- sprintf(TEXTP," 11 - SquareNoninterlaced 640x486x16.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*12));
- sprintf(TEXTP," 12 - Interlaced 720x486x16.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*13));
- sprintf(TEXTP," 13 - Noninterlaced 720x486x16.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*14));
- sprintf(TEXTP," 14 - Interlaced 756x486x16.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*15));
- sprintf(TEXTP," 15 - Noninterlaced 756x486x16.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*16));
- sprintf(TEXTP," 16 - Interlaced 800x600x16.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*17));
- sprintf(TEXTP," 17 - Interlaced 1024x768x16.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*18));
- sprintf(TEXTP," 18 - Back to VGA mode.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*19));
- sprintf(TEXTP,"Set Targa+ Mode To: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,XCHR,480-(YCHR*20));
- getint(&videotype,38,9);
- L_SetTARGAMode(videotype) ; /* Set new TARGA+ mode */
- ClearTheScreen();
- sprintf(TEXTP,"Targa+ mode set! Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- else
- {
- sprintf(TEXTP,"Error: %d Unknown command number!");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- #endif
- break;
-
- case 50: /* Case set VGA memory */
- sprintf(TEXTP,"VGA memory in Kbytes: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&video_memory,23,9);
- if (video_memory < 256)
- {
- sprintf(TEXTP,"Error: %d Unknown VGA memory size", video_memory);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- break;
- }
- L_SetVideoMemory(video_memory) ; /* Set new video memory */
- sprintf(TEXTP,"VGA memory set! Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- break;
-
- case 51: /* Case change brightness */
- if ( alloc_bitmap == 0 )
- {
- sprintf(TEXTP,"Error: No image in BitMap allocated. Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- break;
- }
- sprintf(TEXTP,"+# Increase / -# Decrease Intensity by: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint( &ret,41,9 );
- L_ChangeBitmapIntensity(&Bitmap, ret) ; /* Set new intensity */
- sprintf(TEXTP,"Change Intensity Successful! ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- break;
-
- case 52: /* clear the screen */
- ClearTheScreen();
- L_GraphText(FONT8X16, 0,"Press any Key to Continue.",WHITE,RED,0,9);
- break;
- #ifdef FOR_TEST
- case 53: /* Case capture VGA */
- if (alloc_bitmap == 1) /* Free BitMap information as before */
- {
- L_FreeBitmap( &Bitmap );
- alloc_bitmap = 0;
- }
- /* The input file name can be any file format as long as it matches the */
- /* function call below. For this program capturing the VGA screen */
- /* requires that the user enter a PCX file. It then loads the file to */
- /* a bitmap handle. Then it will save the bitmap using L_GetScreeBitMap.*/
- /* When it is finished, it will release the bitmap. */
- sprintf(TEXTP,"Input PCX file name: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getstring(input_filename,23,9);
- sprintf(TEXTP,"Starting X display position to capture: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&xpos,42,9);
- sprintf(TEXTP,"Starting Y display position to capture: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&ypos,42,9);
- sprintf(TEXTP,"Capture width: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&width,17,9);
- sprintf(TEXTP,"Capture height: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- getint(&height,18,9);
-
- /* Puts it on the VGA screen and Bitmap handle */
- if ( (ret = L_LoadPCXScreen(input_filename, &Bitmap, OUTPUT_BITMAP,
- TYPE_CONV, 0, 0 )) == SUCCESS)
- {
- if ((ret=L_ViewBitmapScreen(&Bitmap, 0, 0)) == SUCCESS)
- {
- if ((ret = L_GetScreenBitmap(&NewBitmap, xpos, ypos, width, height)) == SUCCESS )
- {
- if ((ret = L_SavePCXBitmap("screen.pcx", &NewBitmap, 24)) != SUCCESS)
- {
- sprintf(TEXTP,"Error: %d saving Screen.pcx. Press any key to continue.", ret);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- putch(7);
- }
- else
- {
- sprintf(TEXTP,"Screen saved successfully in SCREEN.PCX");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- }
- L_FreeBitmap(&NewBitmap); /* Release impage from the copy Bit map */
- alloc_bitmap = 1; /* Release image from the bitmap */
- }
- }
- }
- break;
-
- case 54:
- if (alloc_bitmap == 1) /* Free BitMap information as before */
- {
- L_FreeBitmap( &Bitmap );
- alloc_bitmap = 0;
- }
-
- ret=L_SaveTargaWindow(256,256,400,400,&Bitmap,BIT24);
- alloc_bitmap = 1;
-
- break;
-
- case 55: /* inter use */
- L_SetVideoSource(VideoInputRGB);
- L_SetTARGALiveMode();
- L_SleepKey(99);
- L_GrabTARGA();
- break;
- #endif
- case 100: /* Case exit the program */
- if (alloc_bitmap == 1) /* Release BitMap information before quit */
- {
- L_FreeBitmap(&Bitmap);
- alloc_bitmap = 0;
- }
- L_SetVideoMode(3, 0); /* Set TEXT mode*/
- L_TARGAEnd();
- puts("EXIT DEMO\n\n");
- puts(" COPYRIGHT (c) 1991 LEAD Technologies Inc. ALL RIGHTS RESERVED.");
- puts(" 8701 Mallard Creek Rd.");
- puts(" Charlotte NC 28262");
- puts(" Tel # 704-549-5532");
- puts("Running this program indicates your compliance with the following contract.");
- puts("This software is owned by LEAD Technologies Inc. and is protected by");
- puts("the United States copyright laws and international treaty provisions. You may");
- puts("not copy, reverse engineer, decompile, or disassemble this software. LEAD");
- puts("Technologies Inc. grants the right to use this copy of this software for");
- puts("evaluation purposes only. \n\n");
- exit(0);
-
- default: /* Anything else is a wrong selection */
- sprintf(TEXTP," Wrong selection! Press any key to continue.");
- L_GraphText(FONT8X16, 0,TEXTP,GRAY,RED,6,9);
- putch(7);
- break;
- } /* End BIG switch */
-
- L_SleepKey(99); /* Waits 99 seconds or until key is pressed */
-
- } /* BIG for loop */
-
- } /* end main(); */
- /****************************END OF MAIN()***************************/
-
-
- /*********** Function to get the qfactor **********/
- /* Also it checks for a valid qfactor entered by the user */
- int get_qfactor(char *string) /* String to hold the Qfactor */
- {
- char *exttab[NUMEXTENSIONS], *extptr1;
- int qfactor, source;
-
- /* The following is a reference table to find out which compression */
- /* method the user wants to compress the file with. */
- exttab[0] = "PQ1"; /* Perfect quality compression */
- exttab[1] = "PQ2"; /* Perfect quality compression */
- exttab[2] = "QFS"; /* Quality by far more important than size */
- exttab[3] = "QMS"; /* Quality more important than size */
- exttab[4] = "QS"; /* Quality and size equally important */
- exttab[5] = "SQS"; /* Size more important than quality - SHARP */
- exttab[6] = "SQT"; /* Size more important than quality - LESS TILING */
- exttab[7] = "MCQ"; /* Give maximum compression - HIGHT QUALITY */
- exttab[8] = "MC"; /* Give maximum compression */
-
- extptr1 = string;
-
- for (source = 0; source < NUMEXTENSIONS; ++source)
- {if (!strcmp(extptr1, exttab[source]))
- break;
- }
- /* Checks for bad qfactor */
- if (source >= NUMEXTENSIONS)
- {
- qfactor = atoi(string);
- if (qfactor <= 0 || qfactor > 255)
- return(ERROR_QFACTOR);
- else
- return (qfactor);
- }
- /* Else the extension is a predefined qfactor shown in the table above */
- else
- {
- if (source == 0) /* See the table above for types of compression */
- return(QFACTOR_PQ1);
- if (source == 1)
- return(QFACTOR_PQ2);
- if (source == 2)
- return(QFACTOR_QFS);
- if (source == 6)
- return(QFACTOR_QMS);
- if (source == 4)
- return(QFACTOR_QS);
- if (source == 5)
- return(QFACTOR_SQS);
- if (source == 6)
- return(QFACTOR_SQT);
- if (source == 7)
- return(QFACTOR_MCQ);
- if (source == 8)
- return(QFACTOR_MC);
- }
- return(SUCCESS);
- }
-
- /********* Prints out the Main Menu *********/
- void printscreen(void)
- {
- int i; /* For the loop to fill the BLANK screen and a */
- /* BLANK line storage array */
-
- L_SetVGAPalette(RGBFixedPalette);
-
- L_GraphFontSize(16,32);
- i=480-16;
- L_GraphText(FONT8X16, 0,"LEADTOOLS DOS Real Mode Demo",LIGHTYELLOW,KEEPBACKGROUND,80,i);
-
- L_GraphFontSize(0,0);
- i=i-30;
- L_GraphText(FONT8X16, 0,"1",WHITE,KEEPBACKGROUND,XCHR,i);
- sprintf(TEXTP," - Load TGA file to BitMap. - Save BitMap as TGA file.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"2",WHITE, KEEPBACKGROUND,42*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"3",WHITE, KEEPBACKGROUND,XCHR,i);
- sprintf(TEXTP," - Load PCX file to BitMap. - Save BitMap as PCX file.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"4",WHITE, KEEPBACKGROUND,42*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"5",WHITE, KEEPBACKGROUND,XCHR,i);
- sprintf(TEXTP," - Load GIF file to BitMap. - Save BitMap as GIF file.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"6",WHITE, KEEPBACKGROUND,42*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"7",WHITE, KEEPBACKGROUND,XCHR,i);
- sprintf(TEXTP," - Load TIF file to BitMap. - Save BitMap as TIF file.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"8",WHITE, KEEPBACKGROUND,42*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"9",WHITE, KEEPBACKGROUND,XCHR,i);
- sprintf(TEXTP," - Load BMP file to BitMap. - Save BitMap as BMP file.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"10",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"11",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - Load LEAD/JFIF/JTIF/CCITT to BitMap - Save BitMap as LEAD/JFIF/JTIF/CCITT");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"12",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"13",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - Flip BitMap. - Reverse BitMap.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"14",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"15",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - Resize BitMap. - Rotate Bitmap.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"16",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"17",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - Dither BitMap to Fixed Palette. - Optimize Bitmap.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"18",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"19",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - Clear BitMap. - Change BitMap position.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"20",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"21",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - View BitMap on TARGA. - View BitMap on VGA.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"22",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"23",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - View TGA file on TARGA. - View TGA file on VGA.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"24",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"25",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - View PCX file on TARGA. - View PCX file on VGA.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"26",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"27",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - View GIF file on TARGA. - View GIF file on VGA.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"28",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"29",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - View TIF file on TARGA. - View TIF file on VGA.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"30",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"31",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - View BMP file on TARGA. - View BMP file on VGA.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"32",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"33",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - View LEAD/JFIF/JTIF file on TARGA. - View LEAD/JFIF/JTIF file on VGA.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"34",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"35",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - Compress TGA file. - Decompress to TGA file.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"36",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"37",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - Compress PCX file. - Decompress to PCX file.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"38",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"39",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - Compress GIF file. - Decompress to GIF file.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"40",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"41",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - Compress TIF file. - Decompress to TIF file.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"42",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"43",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - Compress BMP file. - Decompress to BMP file.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"44",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"45",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - Compress TARGA screen. - Get information on a file.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"46",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- L_GraphText(FONT8X16, 0,"47",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - Convert a file. - Get VGA/SuperVGA information.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"48",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- #ifdef TARGA
- L_GraphText(FONT8X16, 0,"49",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - Set VGA/SuperVGA Resolution. - Set VGA/SuperVGA memory size.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"50",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
- #else
- L_GraphText(FONT8X16, 0,"49",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - Set VGA or TARGA+ Resolution. - Set VGA/SuperVGA memory size.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"50",WHITE, KEEPBACKGROUND,41*XCHR,i);
- i=i-16;
-
- #endif
- L_GraphText(FONT8X16, 0,"51",WHITE, KEEPBACKGROUND,0,i);
- sprintf(TEXTP," - Change BitMap brightness. - CLEAR The Screen.");
- L_GraphText(FONT8X16, 0,TEXTP,LIGHTCYAN, -1,0,i);
- L_GraphText(FONT8X16, 0,"52",WHITE, KEEPBACKGROUND,41*XCHR,i);
-
- sprintf(TEXTP,"Enter your selection, or 100 to exit: ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,0,9);
- L_GraphText(FONT8X16, 0,"────────────────────────────────────────────────────────────────────────────────",LIGHTYELLOW,-1,0,17);
- L_GraphText(FONT8X16, 0,"────────────────────────────────────────────────────────────────────────────────",LIGHTYELLOW,-1,0,0);
-
-
-
- }
-
- void getint(int *answer, int xpos, int ypos)
- {
- int ch, i,j;
- char string[7];
-
- i=xpos*XCHR;
- j=0;
- string[0]='\0';
-
- while(j < 5)
- {
- ch = getch(); /* Character type in is stored in ch */
- if ( (ch == EOF) || (ch == '\r') || (ch == '\n') )
- {
- break;
- }
- /* Makes sure ch is a printable charcter */
- /* Also checks to see if ch is a Backspace key */
- if ( (ch != 0x08) )
- {
- sprintf(TEXTP,"%c",ch);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,-1,i,ypos);
- string[j]=(char)ch;
- i=i+XCHR;
- j++;
- }
- else
- if (ch == 0x08)
- {
- if (j > 0)
- {
- /* If ch is a Backspace then clear the curent character
- on the screen */
- i=i-XCHR;
- j--;
- sprintf(TEXTP," ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,i,ypos);
- }
- else
- putch(7);
-
- }
- }
- string[j]='\0';
- *answer=atoi(string);
- L_GraphText(FONT8X16, 0," ",LIGHTYELLOW,RED,0,ypos);
- L_GraphText(FONT8X16, 0,"────────────────────────────────────────────────────────────────────────────────",LIGHTYELLOW,-1,0,ypos+8);
- L_GraphText(FONT8X16, 0,"────────────────────────────────────────────────────────────────────────────────",LIGHTYELLOW,-1,0,ypos-10);
-
-
- }
-
- /************** Get a string from the keyboard ****************/
- void getstring(char *answer,int xpos, int ypos)
- {
- int ch, i, j=0; /* Counters */
- char string[128]; /* Charcter buffer */
-
- i=xpos*XCHR;
-
- while(j < 128)
- {
- ch = getch(); /* Gets a character and stores it in ch */
- if ( (ch == EOF) || (ch == '\r') || (ch == '\n') )
- {
- break;
- }
- /* Make sure the key pressed is a printable character and
- not a Backspace */
- if ( (ch != 0x08) && (ch > 32 ) )
- {
- sprintf(TEXTP,"%c",ch);
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,-1,i,ypos);
- string[j]=(char)ch;
- i=i+XCHR;
- j++;
- }
- else
- if (ch == 0x08)
- {
- if (j > 0)
- {
- /* If ch is a Backspace then clear the curent character
- on the screen */
- i=i-XCHR;
- j--;
- sprintf(TEXTP," ");
- L_GraphText(FONT8X16, 0,TEXTP,WHITE,RED,i,ypos);
- }
- else
- putch(7);
- }
- }
- string[j] = '\0';
- strcpy(answer,string);
- L_GraphText(FONT8X16, 0," ",LIGHTYELLOW,RED,0,ypos);
- L_GraphText(FONT8X16, 0,"────────────────────────────────────────────────────────────────────────────────",LIGHTYELLOW,-1,0,ypos+8);
- L_GraphText(FONT8X16, 0,"────────────────────────────────────────────────────────────────────────────────",LIGHTYELLOW,-1,0,ypos-10);
-
- }
-
- /************* BLANK the screen ************/
- void ClearTheScreen(void)
- {
- int i;
- for(i=0; i<59; i++)
- /*Font, vertical, text, for color, back color, X, Y*/
- L_GraphText(FONT8X16, 0," ",
- BLACK, BLACK, 0, i*8);
-
- }