DynaPDF Manual - Page 79

Previous Page 78   Index   Next Page 80

Color spaces
Page 79 of 839
Once the color space was created it can be set with SetExtColorSpace(). Colors of a DeviceN color
space should be set with SetFillColorEx() or SetStrokeColorEx() because these functions accept up to
32 color channels.
A DeviceN color space can be applied to text, vector graphics and images with a color depth of 1, 2,
4, or 8 bits, and in addition to images with up to 32 color channels using 8 bits per component. See
Color Spaces and Images below and CreateDeviceNColorSpace().
Color Spaces and Images
All color spaces can be used with text, vector graphics, and images. While the usage with text and
vector graphics requires no further considerations the usage with images is more complicated.
Prior versions of DynaPDF supported device color spaces only and due to this limitation images
were always converted to the nearest device color space that was active when inserting an image.
This default conversion is not optimal if the original image is defined in a device independent color
space. However, in certain circumstances it's a nice to have feature, especially when creating PDF/X-
1a compatible PDF files (this standard prohibits the usage of device independent color spaces).
To preserve backward compatibility the following default rules apply depending on the active
device color space (the color conversion rules can be modified, see below):
Active color space
Description
DeviceGray
Images defined in another color space are converted to DeviceGray. 1 bit images
are always left unchanged.
DeviceRGB
Images defined in a color space with 3 or more color components are converted
to DeviceRGB. 1 channel images are converted to DeviceGray. 1 bit images are
left unchanged.
DeviceCMYK
Images defined in a 3 channel color space are converted to DeviceCMYK. This
conversion is applied to preserve backward compatibility. 1 channel images are
converted to DeviceGray. 1 bit images are left unchanged.
Handling of non-device color spaces
Non-device color spaces can be used to replace an image color space with the active color space. The
active color space and the image color space must be compatible. For example, a Lab color space
cannot be replaced with a CalRGB color space because this would require a physical conversion of
the pixel data. The source and destination color space must contain the same number of color
components. If the active color space is not compatible to the image color space DynaPDF reports an
error and the image is not inserted.
The following rules apply only if the flag gfUseImageColorSpace is not set (default). See
SetGStateFlags() for further information.
 

Previous topic: DeviceN Color Space

Next topic: Special treatment of 1 bit images, How to preserve the image color space?