| Previous | Table of Contents | Next |
This chapter provides brief descriptions of programs contained on the CD-ROM accompanying this book. Please read the licensing information each program contains.
The TIFFEXAM.C program displays TIFF file information for TIFF specification 5.0 format files that Hewlett-Packard ScanJet scanners and other popular computing products produce. The program handles Intel Corp. byte-ordering (referred to as little-endian) as well as Motorola Corp. processor byte-ordering (referred to as big-endian). The TIFF 6.0 specification significantly expands the TIFF 5.0 specification, and the programming extensions are left as an extended reader exercise.
The TIFF2BIN.C program reads a program argument-specified 8-bit negative image TIFF file and creates a 6-bit positive image file. The program assumes the input file is a carefully produced file with 92 rows x 98 columns and 256 monochromatic intensities. Hewlett-Packard ScanJet IIc scanners using Hewlett-Packards DeskScan software easily produce such files. The ARRAY96.C program performs a hard-coded seek 734 bytes into the file where Hewlett-Packard software places the start of image data. (Use the TIFFEXAM.C program to confirm this hard-coded assumption.)
The program reads the entire 92x98 byte image into a 92x98 character array using one read operation and then converts the image from an 8-bit negative image to a 6-bit positive image. A gray response curve correction is commented out. The program creates a binary file named 96x96.bin by writing two 96-column rows of binary zeros followed by 92 rows each with 96 columns created by reading 96 bytes from each row at a row offset of one byte. The output file operation ends after writing two final rows of binary data.
The ARRAY96.C program reads a program argument-specified binary file created by a program such as the TIFF2BIN.C program. It then creates a text file named image.h which the VIDEO.C program can use as an example include file.
The VESAEXAM.C program determines whether VESA VBE support is available to MS-DOS application programs. (Either the graphics card vendor or SciTech shareware module (available by calling 916-894-8400 in the U.S.) can provide the VBE support). If VBE support is available, the VESAEXAM.C program interrogates the support and reports its findings which are documented in the Video Display Boards and Controllers chapter. By redirecting output to a file, users can review or print the information later.
The GAMMA.C program allows users to determine visual midpoint gamma corrections for each monitor electron gun. Users run the program, specifying a VESA packed pixel mode their display controller supports. The program first verifies that VESA support is available and then confirms the display controller supports the argument-specified mode.
If the mode is supported, the program creates an initial rectangular monochromatic array of alternating horizontal areas. Some areas contain pixels with (R, G, B) intensity values of (127, 127, 127). The other areas contain alternating (R, G, B) values of (0, 0, 0) and (255, 255, 255). Pressing the cursor-up and cursor-down keys respectively increases or decreases the initial 1.0 gamma correction value. When the areas seem to provide the same intensity when viewed at a distance, the user should press the Enter key. The program then repeats the operation for red, green, and blue in isolation.
Before exiting, the program displays a gamma corrected rectangular monochromatic array of alternating horizontal areas using individually adjusted red, green, and blue gamma correction values and returns to MS-DOS after reporting the user selected gamma correction values in each of the operations. Redirecting the output to a file named gamma.val allows the VESAPCX.C program to provide gamma corrected image displays.
The CLRSPC.C program provides a test program that converts from RGB color space into another color space and back. This allows developers to test RGB color space conversions to and from the HLS, HSV, and HSI color spaces. A standard HLS to RGB routine (HlsToRgb()) is given as well as an alternate implementation (HlsToRgb2()) for Ken Fishkins accelerated HLS to RGB transformation found in Graphics Gems Volume 1.
To operate the program, users specify R, G, and B values as arguments where:
0 <= R, G, B <= 255
The program converts the specified RGB triad into other color space triads and converts these triads back into RGB space values. The HSV and HSI conversions are commented out, leaving only HLS conversions.
The VESATEST.C program displays the RGB cube, CMY cube, and an HSI triangular cross section at a user-specified VESA VBE packed pixel mode. To operate the program, users specify a desired VESA packed pixel mode value as a program argument. After determining that both VESA VBE support and the selected direct color mode are available, the program first draws the RGB cube at the selected direct color modes bit depth.
The program draws the first RGB cube cross section by setting all blue values equal to zero and drawing a 256x256 pixel rectangular array (square array if the selected mode has a 4:3 aspect ratio) that varies red values vertically from 255 to zero and green values horizontally from zero to 255. The next cross section is drawn by starting one pixel lower and one to the left. On this cross section, the blue component has a value of BLUE_INCREMENT. At each successive cross section, the blue component value increases by BLUE_INCREMENT, and so on until it exceeds a value of 255. Note the banding illusion that occurs at a 15-bit depth. This visual illusion decreases at a 16-bit depth and disappears at a 24-bit depth.
The process is similar for the CMY cube. Displaying the HSI triangular cross section requires some geometry and trigonometry calculations which are not discussed here other than to mention that the routine uses mirroring to simplify calculations. In addition, the routines request an intensity value between zero and 1.0, allowing a default of 0.5.
| Previous | Table of Contents | Next |