2 *************************************************************************
\r
4 * RD_DEMO.C - PCX_LIB PCX Image File Read Demonstration Program
\r
8 * History: 91/02/14 - Created
\r
9 * 91/04/01 - Release 1.00A
\r
10 * 91/04/06 - Release 1.00B
\r
12 * Compiler: Microsoft C V6.0
\r
14 * Author: Ian Ashdown, P.Eng.
\r
16 * 620 Ballantree Road
\r
17 * West Vancouver, B.C.
\r
19 * Tel. (604) 922-6148
\r
20 * Fax. (604) 987-7621
\r
22 * Copyright: Public Domain
\r
24 *************************************************************************
\r
33 #include "pcx_ext.h"
\r
35 /* FORWARD REFERENCES */
\r
39 static char *use_msg[] = /* Program usage message */
\r
41 " Synopsis: This public domain program displays a Paintbrush (R) PCX",
\r
42 "-format\n image file.\n\n Usage: RD_DEMO filename vi",
\r
43 "deo_mode\n\n where \"filename\" is the name of a PCX-form",
\r
44 "at image file and\n \"video_mode\" is an MS-DOS video mod",
\r
45 "e. Valid values are:\n\n 4 - 320 x 200 4-color CGA",
\r
46 "\n 5 - 320 x 200 4-color CGA (color burst off)\n ",
\r
47 " 6 - 640 x 200 2-color CGA\n 13 - 320 x ",
\r
48 "200 16-color EGA/VGA\n 14 - 640 x 200 16-color EGA/VG",
\r
49 "A\n 15 - 640 x 350 2-color EGA/VGA\n 16",
\r
50 " - 640 x 350 16-color EGA/VGA\n 17 - 640 x 480 2-co",
\r
51 "lor VGA\n 18 - 640 x 480 16-color VGA\n ",
\r
52 " 19 - 320 x 200 256-color VGA\n\n The file must be comp",
\r
53 "atible with the indicated video mode.\n",
\r
54 (unsigned char *) NULL
\r
57 /* PUBLIC FUNCTIONS */
\r
60 *************************************************************************
\r
62 * MAIN - Executive Function
\r
64 * Purpose: To read and display a PCX-format image file.
\r
72 * Where: argc is the number of command-line arguments.
\r
73 * argv is a pointer to an array of command-line argument
\r
76 * Return: 0 if successful; otherwise 2.
\r
80 * RD_DEMO filename video_mode
\r
84 * filename is the name of a PCX-format image file.
\r
85 * video_mode is the MS-DOS video mode. Valid values are:
\r
87 * 4 - 320 x 200 4-color CGA
\r
88 * 5 - 320 x 200 4-color CGA (color burst off)
\r
89 * 6 - 640 x 200 2-color CGA
\r
90 * 13 - 320 x 200 16-color EGA/VGA
\r
91 * 14 - 640 x 200 16-color EGA/VGA
\r
92 * 15 - 640 x 350 2-color EGA/VGA
\r
93 * 16 - 640 x 350 16-color EGA/VGA
\r
94 * 17 - 640 x 480 2-color VGA
\r
95 * 18 - 640 x 480 16-color VGA
\r
96 * 19 - 320 x 200 256-color VGA
\r
98 *************************************************************************
\r
107 int i; /* Scratch counter */
\r
108 int vmode; /* Video mode */
\r
109 BOOL status = FALSE; /* Return status */
\r
111 /* Display program title */
\r
113 puts("\nRD_DEMO - PCX Image File Display Demonstration Program\n");
\r
115 if (argc == 3) /* Check for filename and video mode parameters */
\r
117 vmode = atoi(argv[2]); /* Get the video mode */
\r
119 /* Validate the video mode (must be valid MS-DOS graphics mode) */
\r
121 if ((vmode >= 4 && vmode <= 6) || (vmode >= 13 && vmode <= 19))
\r
125 if (status == TRUE)
\r
127 if (_setvideomode(vmode) == 0) /* Set the video mode */
\r
132 "ERROR: could not set display adapter to mode %d.\n", vmode);
\r
137 /* Read and display the file (assume video page zero) */
\r
139 if ((status = pcx_read(argv[1], vmode, 0)) == TRUE)
\r
141 while (!kbhit()) /* Wait for a keystroke */
\r
144 (void) getch(); /* Clear the keyboard buffer */
\r
147 (void) _setvideomode(_DEFAULTMODE); /* Reset the video mode */
\r
149 if (status == FALSE)
\r
153 fprintf(stderr, "\nRD_DEMO - PCX Image File Display Demonstration");
\r
154 fprintf(stderr, " Program\n\nERROR: Could not read file %s.\n",
\r
158 else /* Display usage information */
\r
160 while (use_msg[i] != (unsigned char *) NULL)
\r
161 fputs(use_msg[i++], stderr);
\r
164 if (status == TRUE)
\r