DynaPDF Manual - Page 224

Previous Page 223   Index   Next Page 225

Function Reference
Page 224 of 777
How to define CalGray colors?
Since CalGray colors consist of only one component which ranges from 0 to 255 the colors can be
defined as if you would use DeviceGray. No further conversion function is required.
How to define CalcRGB colors?
CalRGB can be used in the same way as DeviceRGB. Each component of a CalRGB color space
ranges from 0 to 255. Use the macro PDF_RGB() to convert color components to a 32 bit integer.
Other programming languages than C/C++ support mostly a function like rgb() which does
essentially the same as the C macro PDF_RGB().
How to define Lab colors?
The Lab color space is a three component space where each component supports different ranges:
0 to 100
a* -128 to 127
b* -128 to 127
The ranges above define the maximum ranges which can be used in a Lab color space. In comparison
to RGB each component is defined as signed char while in RGB each component is defined as
unsigned char. C/C++ programmers can still use the macro PDF_RGB() to convert Lab colors to 32 bit
If you use another programming language it is usually best to convert negative component values to
unsigned char before passing the value to a function like rgb().
if (component_value < 0)
result = 256 + component_value; // Note that we add a negative number!
result = component_value;
Non-device color spaces cannot be used for interactive objects such as annotations or form fields. The
active color space must always be changed to a device color space before creating interactive objects;
see SetColorSpace(). Note also that annotations support DeviceRGB only. Form fields support
DeviceGray, DeviceRGB, and DeviceCMYK.
Use the function SetExtColorSpace() to activate the color space in the graphics state. To set a color of
a CIE-based color space convert the color value to a 32 bit integer as described above and pass the
result to SetFillColor(), SetStrokeColor(), or SetColors().
Return values:
If the function succeeds the return value is the color space handle, a value greater or equal zero. If
the function fails the return value is a negative error code.

Previous topic: CreateCIEColorSpace

Next topic: CreateColItemDate, CreateColItemNumber