| Previous | Table of Contents | Next |
The PRINTPCX.C program prints specified packed pixel color PCX images on the following printers:
| IBM Proprinter II | (black and white dot matrix) |
| Hewlett-Packard LaserJet Series | (black and white xerographic) |
| Hewlett-Packard DeskJet 500 | (black and white ink jet) |
| Hewlett-Packard DeskJet 500C | (color CMY ink jet printer) |
| Hewlett-Packard DeskJet 550C | (color CMYK ink jet printer) |
The program may operate on other Hewlett-Packard printers but is untested and results may vary.
The PRINTPCX.C main() routine expects three input arguments. In numeric order they are: a PCX filename, a printer type, and a gamma correction value. The PCX file must be a valid version 3 palette image or a 24-bit image. ValidatePrinter() verifies the printer argument is one of the following:
| Argument | Device | Print Routine |
| IbmPpII | (IBM Proprinter II) | PrintOnIbmPpII() |
| HpLj/Dj500 | (Hewlett-Packard achromatic) | PrintOnHpLjAndDj500() |
| HpDj500C | (Hewlett-Packard CMY) | PrintOnHpDj500C() |
| HpDj550C | (Hewlett-Packard CMYK) | PrintOnHpDj550C() |
main() first creates a gamma translate value look-up table and a random number table for the digital halftone random error distribution operation. Selecting a random error distribution halftone algorithm provides thousands of variations of the printed image that are indistinguishable from a distance. main() calls ValidatePrinter() to verify the printer specification and calculate gamma corrected values. main() then attempts to print the selected PCX file by calling PrintPcxFile(). After PrintPcxFile() returns, main() waits for a user keystroke before calling ResetPrinter() which provides a PC BIOS printer reset. The PC BIOS reset ejects the printed page from Hewlett-Packard printers and helps prevent printers from flushing printer memory before printing the entire image. main() consumes the keystroke and concludes with an ending message.
PrintPcxFile() opens the designated PCX file and calls ValidatePcxFileHeader() to verify the file has a valid PCX header. The file must be a valid PCX version 3 format file with a palette image or a 24-bit image. The PrintDirectColorPcxImageFile() provides a start but each of the print routines must handle converting 15- and 16-bit pixels into an acceptable format.
If the file does not have a valid PCX file, PrintPcxFile() returns without attempting to print anything. Otherwise, PrintPcxFile() calculates the image size and the maximum allowed pixel replication factor to scale the image up to a maximum pixel replication factor of MAX_REPLICATION_FACTOR set to a value of 5.
PrintPcxFile() next displays image dimensions on the monitor before calculating replication factors used during the forward and reverse scan-line print operations. Finally, PrintPcxFile() calls PrintColorPaletteImage() or PrintDirectColorPcxImageFile() which invokes the proper print routine for the designated printer. Each of the routines sends the correct escape sequences to the printer and reduces the image to a monochromatic image if necessary. The Proprinter II support routines also correct for the printer aspect ratio, which is not 1:1 like HP printers provide, while the Hewlett-Packard routines magnify the images up to a factor of five to produce larger images.
All print routines use the Floyd Steinberg halftone algorithm with a serpentine raster and dynamic sharpening operation. The algorithm also randomly distributes error using the IBM developed randomization approach. Because of the array sizes and their number, PrintOnHpDj500C() and PrintOnHpDj550C() use far pointers to arrays allocated on the heap rather than automatic or static arrays. This forces PRINTPCX.C to be a large model program.
| Previous | Table of Contents | Next |