Harlequin RIP SDK
Custom color space CMM example

This example provides a core color management module that implements a collection of custom color spaces that may be used by the setinterceptcolorspace and setreproduction color operators. More...

Files

file  cmm_example.h
 An example core color management module which implements its own custom color spaces.
 
file  cmm_example.c
 Simple example showing how to create and use custom color spaces using the core color management module interface.
 

Functions

sw_ccs_apiexampleccs_getInstance (void)
 Return the singleton instance of a sw_cmm_api object containing details specific to the Custom Color Space example module. More...
 
static sw_ccs_result ccs_construct (sw_ccs_instance *instance)
 Construct an instance of the sw_cmm_api interface. More...
 
static sw_ccs_custom_colorspaceccs_declare_custom_colorspace (sw_ccs_instance *instance, uint32 index)
 Declare a custom color space to the RIP. More...
 
static sw_ccs_result ccs_open_transform (sw_ccs_instance *instance, uint32 index, sw_cmm_object_type object_type, sw_cmm_color_model color_model, uint32 *num_input_channels, uint32 *num_output_channels, sw_ccs_transform *handle)
 Create a transform structure. More...
 
static void ccs_close_transform (sw_ccs_instance *instance, sw_ccs_transform transform)
 Close a transform previously opened with ccs_open_transform(). More...
 
static sw_ccs_result ccs_invoke_transform (sw_ccs_instance *instance, sw_ccs_transform transform, float *input_data, float *output_data, uint32 num_pixels)
 Use the specified transform to adjust color data. More...
 

Detailed Description

This example provides a core color management module that implements a collection of custom color spaces that may be used by the setinterceptcolorspace and setreproduction color operators.

There are 5 custom color spaces that are implemented in this module:

To configure the RIP to use this color management module, use this fragment in the configuration PostScript:

(CMM_CCSExample) setcustomcolorspacecmm

or, if simple control over the ink limiting in the MaxInk color space is desired, the TAC can be set using the optional InkLimit param, e.g.:

(CMM_CCSExample) << /InkLimit 175 >> setcustomcolorspacecmm

where the TAC will be limited to 175% in this case.

An example configuration using this alternate CMM is provided for use with the "clrip" application, in SW/TestConfig/CMYKCMMComposite300dpi. It is configured to use InvertColors as distributed, but can be changed to use BrightenColors or IdentityMap by editing a line in the configuration file. Comment out the /InputColorSpace options you do not require by prefixing the line with %, leaving one line enabled:

% Enable one of the following /InputColorSpace lines
/InputColorSpace [ /CMM (InvertColors) /DeviceRGB /DeviceRGB ]
% /InputColorSpace [ /CMM (BrightenColors) /DeviceRGB /DeviceRGB ]
% /InputColorSpace [ /CMM (IdentityMap) /DeviceRGB /DeviceRGB ]

When using the IdentityMap option, the output may differ from when the custom CMM example configuration is not used. This is because this configuration also specifies some ICC profiles.

This example module is registered by calling SwRegisterCCS() with the singleton API instance returned by exampleccs_getInstance(). The module implements the CMM API methods ccs_construct(), ccs_declare_custom_colorspace(), ccs_close_transform() and ccs_invoke_transform().

Note
This code should be used for reference purposes only.

Function Documentation

◆ ccs_close_transform()

static void ccs_close_transform ( sw_ccs_instance instance,
sw_ccs_transform  transform 
)
static

Close a transform previously opened with ccs_open_transform().

Parameters
[in]instanceThe alternate CMM instance owning the color transform.
[in]transformA valid transform handle created by an open_transform() or open_transform2() call on the same alternate CMM instance. The alternate CMM implementation should discard any resources associated with the transform.
See also
ccs_open_transform()

◆ ccs_construct()

static sw_ccs_result ccs_construct ( sw_ccs_instance instance)
static

Construct an instance of the sw_cmm_api interface.

The RIP constructs an instance for each CMM module after booting the interpreter. RIP fills in the implementation pointer, and pointers to the memory API and blob API instances. The module is expected to fill in the remaining fields, which contains flags defining of the implementation capabilities of the module. Some of the information returned will be used by the RIP to determine whether a particular profile or transform can be handled by this module, and in other cases the RIP will use this information to divert color conversions through its built-in CMM if appropriate.

Parameters
[in,out]instanceAn incomplete instance of the sw_cmm_instance structure to complete. The RIP will allocate a structure of the size presented in the implementation's sw_cmm_api::info.instance_size field, fill in the implementation and callback API instance pointers (*), and then pass it to this routine. The construct() method is expected to fill in the remaining fields. The implementation may sub-class the instance to allocate private workspace by initialising the implementation's sw_cmm_api::info.instance_size larger than the size of the sw_cmm_instance structure, then downcasting the instance pointer in method calls. (*) The RIP will also fill in the params field with the optional params dictionary that is an optional parameter for setalternatecmm, provided the API version is at least SW_CMM_API_VERSION_20250922.
Returns
SW_CMM_SUCCESS if the instance is fully constructed, otherwise one of the SW_CMM_RESULT error codes.

◆ ccs_declare_custom_colorspace()

static sw_ccs_custom_colorspace * ccs_declare_custom_colorspace ( sw_ccs_instance instance,
uint32  index 
)
static

Declare a custom color space to the RIP.

This example code will ensure all custom color spaces are declared.

This method is optional. If this method is not supported, then the open_custom_colorspace() method will never be called.

Parameters
[in]instanceA custom color space instance.
indexA zero-based index used to identify the custom color spaces defined by the custom color space instance. When trying to set custom color spaces, the RIP will call this method with indices starting at 0, and increasing until either a match is found or this method returns NULL.
Returns
A pointer to a custom color space definition, or NULL if the index is out of the range supported by the custom color space implementation.
See also
ccs_open_custom_colorspace()

◆ ccs_invoke_transform()

static sw_ccs_result ccs_invoke_transform ( sw_ccs_instance instance,
sw_ccs_transform  transform,
float *  input_data,
float *  output_data,
uint32  num_pixels 
)
static

Use the specified transform to adjust color data.

Parameters
[in]instanceThe alternate CMM instance owning the color transform.
[in]transformA valid transform handle created by an open_transform() call on the same alternate CMM instance.
[in]input_dataAn array of num_pixels sets of pixel-interleaved color values to transform. Colors are interleaved in the order specified by the input space of the first profile in the transform.
[out]output_dataAn array in which to store num_pixels sets of pixel-interleaved color values. Colors are interleaved in the order specified by the output space of the last profile in the transform.
num_pixelsThe number of sets of input pixel colorvalues to convert from the input space to the output space of the transform.
Returns
SW_CMM_SUCCESS if the invocation succeeded, one of the SW_CMM_RESULT error codes otherwise.

In all cases, both the input and output data should be pixel interleaved with each color value contained in a 32-bit IEEE floating value. The interleaving of the input data is in the same order as that expected by the first profile in a transform and the interleaving of the output data should be in the same order as produced by the last profile in the transform. It is the responsibility of the alternate CMM to marshal the data into and out of the format required for its internal use. As an example, if five pixels of RGB data were to be converted to CMYK, the RIP will arrange the input data as follows:

RGBRGBRGBRGBRGB

and invoke_transform() will produce this arrangement of output data:

CMYKCMYKCMYKCMYKCMYK

The number of channels for each pixel is derived from the first and last profiles in the transform as returned by open_transform().

The memory referenced by input_data and output_data is managed by the RIP and can be assumed to contain valid memory for the appropriate amount of data. The size, in bytes, allocated by the RIP to each is:

  • input_data: num_pixels * num_input_channels * sizeof(float)
  • output_data: num_pixels * num_output_channels * sizeof(float)
See also
ccs_open_transform()

◆ ccs_open_transform()

static sw_ccs_result ccs_open_transform ( sw_ccs_instance instance,
uint32  index,
sw_cmm_object_type  object_type,
sw_cmm_color_model  color_model,
uint32 num_input_channels,
uint32 num_output_channels,
sw_ccs_transform handle 
)
static

Create a transform structure.

Parameters
[in]instanceThe custom color space instance.
indexThe zero-based index that identifies the desired custom color space, as established from declare_custom_colorspace().
[in]object_typeOne of the values of sw_cmm_object_type.
[in]color_modelOne of the values of sw_cmm_color_model.
[out]num_input_channelsA location for the custom color space to fill in the number of color channels in the input space of the first profile in the transform.
[out]num_output_channelsA location for the custom color space to fill in the number of color channels in the output space of the last profile in the transform.
[out]handleA pointer in which a CCS transform handle is stored by the custom color space implementation. This handle will be used to refer to the transform by close_transform() and invoke_transform() methods.
Returns
SW_CCS_SUCCESS if the transform was successfully opened, in which case a non-NULL transform pointer should have been stored in handle. If the profile could not be opened, one of the SW_CCS_RESULT error codes is returned.

If a valid transform handle is returned, the close_transform() method will be called to destroy the transform later.

See also
ccs_close_transform(), ccs_invoke_transform()

◆ exampleccs_getInstance()

sw_ccs_api* exampleccs_getInstance ( void  )

Return the singleton instance of a sw_cmm_api object containing details specific to the Custom Color Space example module.

Returns
A single instance of the CMM.
See also
SwRegisterCCS()

If compiled normally, the "clrip" application layer registers this module during RIP startup. CMM module examples may be excluded from "clrip" by building with NO_CMMEG defined.