Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

DynaPDF Manual - Page 217

Previous Page 216   Index   Next Page 218

Function Reference
Page 217 of 750
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:
L*
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
integers.
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().
Example:
if (component_value < 0)
result = 256 + component_value; // Note that we add a negative number!
else
result = component_value;
Notice:
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.
Remarks:
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: CreateColItemNumber