|
Starting with Mac OS X version 10.4 (Tiger), developers writing raster printer drivers for the CUPS printing system can receive bitmap raster data with 16 bits-per-color component. Working with deeper pixel data offers the opportunity for greater color fidelity and precision. The support for 16 bits-per-color is limited to the CUPS color spaces Byte Ordering (Endian-ness)For raster data that is 1 bit and 8 bits-per-color component, the byte ordering of the data for a given color component is unambiguous because the color component data for each pixel is one byte or less in size. For 16 bits-per-color data, the color value for a given color component is 2 bytes and the byte ordering is defined to be the native byte ordering. That is, for 16 bits-per-color data when executing on big-endian machines, the byte order of each color component value is big-endian. For 16 bits-per-color data when executing on little-endian machines, the byte order of each color component value is little-endian. This approach offers the best performance and most straightforward treatment of the data passed to a CUPS filter expecting to receive 16 bits-per-color CUPS raster data. However, this means that your CUPS filter that processes 16 bits-per-color data must determine whether the architecture of the producer of the raster data matches your filter's architecture. CUPS provides a straightforward way to determine whether the architecture of the producer of the raster data is the same as your filter which will process the raster. The Listing 1: Determining if endian data swapping is needed bool isRasterEndianSwapNeeded(int in_fd) { bool swap16BitData = false; cups_raster_t *raster; // in_fd is the input file descriptor for the file // you are reading the raster from, e.g. stdin. raster = cupsRasterOpen(in_fd, CUPS_RASTER_READ); if(raster->sync == CUPS_RASTER_REVSYNC) swap16BitData = true; return swap16BitData; } When the Requesting 16 Bits-Per-Color DataThere are two methods that developers can use to specify that they want 16 bits-per-color data. Which method is best depends on whether the driver receiving the data is intended to run on versions prior to Tiger. Mac OS X 10.4 and Later Systems OnlyIf you want to receive 16 bits-per-color raster data and only care about having your driver run on systems that support that format, you can simply specify a Listing 2: Specifying in a PPD file a cupsBitsPerColor value of 8 *ColorModel RGB/RGB Color: "<</cupsColorSpace 1/cupsColorOrder 0/cupsBitsPerColor 8>>setpagedevice" This specifies the
with each color value in a single byte. To specify the same parameters but with 16 bits-per-color, you would change the equivalent line in the PPD file to instead read as shown in Listing 3. Listing 3: Specifying in a PPD file a cupsBitsPerColor value of 16 *ColorModel RGB/RGB Color: "<</cupsColorSpace 1/cupsColorOrder 0/cupsBitsPerColor 16>>setpagedevice" This specifies the
with each color value specified as a 2-byte integer value in host-endian format. This approach is straightforward but will fail when executing on any version of Mac OS X prior to Tiger or any other CUPS print server that does not support a Compatibility with Other SystemsCUPS raster printer drivers that use The Listing 4: Specifying that 16 bits per color is preferred, while maintaining 8 bits per color compatibility for systems prior to Mac OS X 10.4 *ColorModel RGB/RGB Color: " <</cupsColorSpace 1/cupsColorOrder 0/cupsBitsPerColor 8 /cupsPreferredBitsPerColor 16>>setpagedevice" *End On systems that recognize the
with each color value specified as a 2-byte integer value in host-endian format. On systems that do not support the Versions of CUPS that don't know anything about the CUPS printer drivers that specify their data request this way MUST use the CUPS raster header structure that precedes each page raster to determine the format of the raster data that is provided to them. If the header has the SummaryMac OS X version 10.4 and later have support for providing 16 bits-per-color component data to CUPS raster printer drivers. Taking advantage of deep color data offers the potential for superior results from a given output device. You can request deep color data in a manner that is compatible with CUPS installations that don't support it, allowing deployment of a single driver across a wide range of platforms and OS versions. Document Revision History
Posted: 2005-08-24 |
|