Document Layout Tutorials
Text Flow Tutorials
PageElement Abstract Class
Frame : PageElement Class
TextBlock : PageElement Class
ImageBlock : PageElement Class
Box : PageElement Class
Rule : PageElement Class
The CMYK color model
On top of the standard ARGB color model (Alpha Red Green Blue – for monitor display), SharpPlot supports and the CMYK color model (Cyan Magenta Yellow Black – for ink mixing). CMYK colors are encoded are ARGB colors with an alpha channel (opacity) between 0 and 8. This is why, when using ARGB colors (which is standard .Net approach), you shouldn’t use opacity smaller than 9, otherwise the colors will appear “random”.
Colors on devices that emit light (like computer monitors) traditionally use three light-sources in the Red, Green and Blue band of the spectrum to fool the eye into seeing any of the combinations of color these can produce. Hence the tendency of programmers to think that specifying ‘color’ simply requires giving 3 values to set the RGB of each composite pixel.
However, color printers require a very different perspective, as inks work by selectively removing color from the reflected light. Of course all printers will accept a specification in RGB terms, and internally convert it to (Cyan,Magenta,Yellow,Black) using a simple subtractive procedure. Typically they determine the amount of each of the first three inks by simple subtraction from the RGB values, then factor out as much Black as they can by finding the minimum value across the CMY vector, adding this as Black, then removing this from each of the CMY.
As you can quickly see, any grey (R=G=B in the intensity model) always maps to (0,0,0,k) when converted to ink. That is why the black cartridge always goes down fastest on your photo-printer! Even grey-ish colors use mostly black when converted to inks.
Because the conversion can never be better than a guess, if the intended output medium of a chart is paper (maybe previewed on screen) then to get the colors exactly right, it is best to use either EPS or PDF output from SharpPlot and set the colors of the inks directly. The values you give will be passed directly into the EPS or PDF drawing commands, and both these formats have the ability to control PostScript printers directly.
Previewing CMYK colors on screen
The reverse conversion from CMYK to RGB is very poorly defined – there are two reasonable approaches here. Firstly, we can essentially reverse the RGB mapping by subtracting CMY from 1.0, then subtracting the K component from each of them, being careful not to go less than zero. This is what SharpPlot does if you use the raster output, or save your chart in SVG, XAML and so on – formats which only support RGB. It also matches what GhostScript does with your EPS output (if you convert it to PNG) and what MS Word does when importing EPS files as pictures.
The alternative algorithm is to subtract the CMY values as above, then multiply what you get by (1-K). This avoids the problem of getting values below zero, but generates rather ‘muddier’ colors as a result. This approach is used by the common PDF viewers such as Acrobat Reader and Foxit to generate the preview.
Use CMYK colors when you need full control over the inks on your printer, but don’t get too hung up on what the preview looks like on screen! There is no one ‘correct approach’ to mapping from inks to pixels.
See also ...