Herd Software Development
DaVinci Graphics Library
Printers and screens use fundamentally different methods of colour representation. While cathode ray tube (CRT) displays start from a black screen and display the image by adding red, blue and green light to the display surface, printers start from a white sheet of paper and produce colors by subtracting total light reflected from the page surface using a mixture of the colours yellow, cyan and magenta.
Printer colors yellow, cyan and magenta are defined in a fashion which allows every colour component to precisely affect a component of the RGB colorspace. For example specifying yellow as a pixel color allows red and green electron guns to illuminate the dots on the screen that make up that pixel.
|Cathode ray guns used:
|Printer colors used
|All but cyan
|All but magenta
|All but yellow
While the red, green and blue colors on CRTs come quite close to the ideal R,G,B colors, the cyan, magenta, and yellow inks or pigments used by printers are far from being ideal print colors. A 100% mixture of cyan, magenta and yellow will not produce black, but only a dark brown. Therefore, almost all color printers use black as a supplementary fourth color, thus the "four-color" standard for color printing.
Conversion between RGB and CMYK colourspace is tricky and not without some sacrifices. Not every colour displayable on an RGB screen can be printed on a CMYK printer. To make an exact conversion, the color values of the colors accessible with the concrete model of printer and paper must be considered. Thus conversion from onscreen image to printed page is printer-dependent.
High quality image processing applications such as Adobe Photoshop allow you to set up images in CMYK format on the screen so that the display renders the image in much the same way as it will be seen on the printed page. Images are accordingly stored in CMYK colour format as TIFF or JPEG files, or in a proprietary format designed for use specifically by that application.
Versions of Windows prior to NT 5 contain no support for printing CMYK images. All images are processed in RGB format, leaving it up to the printer driver to convert the RGB data to CMYK data. This is the most sensible approach, since the printer driver should know best how the recommended inks or pigments used by a particular printer are best applied to that printer.
Leaving conversion to the printer driver gives applications no precise control over the representation of an image, and this can result in printouts from one printer looking vastly different on another printer from a CMYK image.
DaVinci usually autoconverts TIFF or JPEG files from CMYK colourspace to RGB DIBs during the import process. Transformation has to be done without advance knowledge of the printer for which that image was designed, so conversion is done with a standard color set.
When importing CMYK TIFFs or JPEGs, DaVinci Professional allows you to specify the IPDIBF_ALLOW_IMPORT_CMYK flag in the dwDIBFlags field of the DAVPARAMS structure to force DaVinci to create a DIB in the CMYK format.
CMYK DIBs can be stored by DaVinci without loss of quality as TIFF or BMP files. Images saved in all other formats (PNG, PCX, etc.) are stored in the RGB format. Note that JPEG images are also saved unconditionaly as RGB images.
The function DIBCmyk2Rgb converts a CMYK format DIB to RGB format to make the DIB compatible with Windows's image processing API.
If StretchDIBBlt is applied to a CMYK DIB, a temporary RGB format copy of that DIB will be created and used to for display of the image onscreen.
The Imagine window class and the VCL and OCX elements based upon it will execute all necessary functions automatically.
Windows' own printer drivers provide no functionality for printing of CMYK bitmaps. Genuine CMYK printing is possible only on PostScript printers.
StretchDIBBlt recognizes CMYK format DIBs a PostScript printer driver automatically and sends PostScript code for the printing of the data in CMYK format to the printer. If the printer driver is not a PostScript driver, StretchDIBBlt converts the image to RGB format and transfers that data to the printer driver. This functionality allows for printing both from 16 and 32 bit Windows applications, and CMYK images are also printed in this fashion by PhotoShop.
CMYK graphics can't be converted to DDBs, or be processed with DIB.DRV or CreateDIBSection without loss of quality. The only comparable API available for DaVinci users is the RWxxxx API.
RWGetPixelRgb16 and RWSetPixelRgb16 support processing on the basis of RGB colour data that is to be converted automatically from/into the CMYK colourspace.
The functions RWGetPixelIndex and RWSetPixelIndex support processing via direct CMYK colour specifications in the pxCmykQuad structure of the PIXELINDEXUNION.
A section of a source DIB (CMYK or RGB) can be copied with StretchDIB2DIBBlt into a target DIB (CMYK or RGB).
The DIBIsCmyk function allows you to determine whether a DIB is available in the CMYK format.
Þ Setup of a CMYK DIB
Þ Function DIBCmyk2Rgb
Þ Function DIBIsCmyk