Harlequin RIP SDK
Combined LittleCMS and custom color space CMM example

This example provides a core color management example module that both interfaces to the open source LittleCMS ICC CMM and also implements the custom color spaces from the Custom color space example module. More...

Files

file  cmm_hybrid.h
 CMM Interface to combined LittleCMS and custom color space module.
 
file  cmm_examplepriv.h
 Header for linking the custom color space module with the Hybrid module.
 
file  cmm_hybrid.c
 CMM Implementation of a hybrid interface to both the Custom Color Space and LittleCMS example modules.
 
file  cmm_littlecmspriv.h
 Header for linking the custom color space module with the Hybrid module.
 

Functions

sw_cmm_apihybridcms_getInstance (void)
 Return the singleton instance of a sw_cmm_api object containing details specific to the Hybrid CMM example module. More...
 
static sw_cmm_result hybrid_construct (sw_cmm_instance *instance)
 Construct an instance of the sw_cmm_api interface. More...
 
static sw_cmm_result hybrid_open_profile (sw_cmm_instance *instance, sw_blob_instance *ICC_profile, sw_cmm_profile *handle)
 Create an internal profile structure for ICC profile data stored in memory. More...
 
static void hybrid_close_profile (sw_cmm_instance *instance, sw_cmm_profile profile)
 Close a profile with a handle previously created by either lcms_open_profile() or ccs_open_custom_colorspace(). More...
 
static sw_cmm_custom_colorspacehybrid_declare_custom_colorspace (sw_cmm_instance *instance, uint32 index)
 Declare a custom color space to the RIP. More...
 
sw_cmm_result hybrid_open_custom_colorspace (sw_cmm_instance *instance, uint32 index, sw_cmm_profile *handle)
 Create an internal profile structure for a custom colorspace. More...
 
static sw_cmm_result hybrid_open_transform (sw_cmm_instance *instance, sw_cmm_profile profiles[], uint32 num_profiles, int32 intents[], HqBool black_point_compensations[], uint32 *num_input_channels, uint32 *num_output_channels, sw_cmm_transform *handle)
 Create a transform structure for the example CMM. More...
 
void hybrid_close_transform (sw_cmm_instance *instance, sw_cmm_transform transform)
 Close a transform previously opened with hybrid_open_transform(). More...
 
static sw_cmm_result hybrid_invoke_transform (sw_cmm_instance *instance, sw_cmm_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 example module that both interfaces to the open source LittleCMS ICC CMM and also implements the custom color spaces from the Custom color space example module.

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

(CMM_Hybrid) setalternatecmm

With this configuration, color transforms involving ICC profiles will be directed to the LittleCMS module, and custom color spaces defined by the CCS example module will be available for use in the setinterceptcolorspace and setreproduction operators. Further details in the Extensions Manual.

This example module is registered by calling SwRegisterCMM() with the singleton API instance returned by hybridcms_getInstance(). The module implements the CMM API methods hybrid_construct(), hybrid_open_profile(), hybrid_close_profile(), hybrid_declare_custom_colorspace(), hybrid_open_custom_colorspace(), hybrid_open_transform(), hybrid_close_transform() and hybrid_invoke_transform().

Note
This code should be used for reference purposes only.

Function Documentation

◆ hybrid_close_profile()

static void hybrid_close_profile ( sw_cmm_instance instance,
sw_cmm_profile  profile 
)
static

Close a profile with a handle previously created by either lcms_open_profile() or ccs_open_custom_colorspace().

This function trampolines onto the close_profile() function from the LittleCMS or Custom Color Space example module as appropriate.

Parameters
[in]instanceThe alternate CMM instance owning the profile.
[in]profileA profile handle previous opened by an open_profile() or open_custom_colorspace() calls on the same alternate CMM instance. The alternate CMM implementation should discard any resources associated with the profile.
See also
hybrid_open_profile()

◆ hybrid_close_transform()

void hybrid_close_transform ( sw_cmm_instance instance,
sw_cmm_transform  transform 
)

Close a transform previously opened with hybrid_open_transform().

This function trampolines onto the close_transform() function from the LittleCMS or Custom Color Space example module as appropriate.

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
hybrid_open_transform()

◆ hybrid_construct()

static sw_cmm_result hybrid_construct ( sw_cmm_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.
Returns
SW_CMM_SUCCESS if the instance is fully constructed, otherwise one of the SW_CMM_RESULT error codes.

◆ hybrid_declare_custom_colorspace()

static sw_cmm_custom_colorspace * hybrid_declare_custom_colorspace ( sw_cmm_instance instance,
uint32  index 
)
static

Declare a custom color space to the RIP.

This function trampolines onto the declare_custom_colorspace() function from the Custom Color Space example module.

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

Parameters
[in]instanceAn alternate CMM instance queried for custom colorspaces.
indexA zero-based index used to identify the custom colorspaces defined by the alternate CMM instance. When trying to set custom colorspaces, 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 colorspace definition, or NULL if the index is out of the range supported by the alternate CMM implementation.
See also
hybrid_open_custom_colorspace()

◆ hybrid_invoke_transform()

static sw_cmm_result hybrid_invoke_transform ( sw_cmm_instance instance,
sw_cmm_transform  transform,
float *  input_data,
float *  output_data,
uint32  num_pixels 
)
static

Use the specified transform to adjust color data.

This function trampolines onto the invoke_transform() function from the LittleCMS or Custom Color Space example module as appropriate.

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
hybrid_open_transform()

◆ hybrid_open_custom_colorspace()

sw_cmm_result hybrid_open_custom_colorspace ( sw_cmm_instance instance,
uint32  index,
sw_cmm_profile handle 
)

Create an internal profile structure for a custom colorspace.

This function trampolines onto the open_custom_colorspace() function from the Custom Color Space example module.

The RIP does not interpret the profile handle returned by this call. The profile handle will be passed back to the alternate CMM implementation as a means of identifying the custom colorspace when creating a transform, or closing the profile.

Parameters
[in]instanceAn alternate CMM instance which previously declared support for the custom colorspace through a call to declare_custom_colorspace().
indexA zero-based index used to identify the custom colorspace defined by the alternate CMM instance.
[out]handleA pointer in which a CMM profile handle is stored. This handle will be used to refer to the profile by close_profile(), open_transform(), and open_transform2().
Returns
SW_CMM_SUCCESS if the profile was successfully opened, in which case a non-NULL profile pointer should have been stored in handle. If the profile could not be opened, one of the SW_CMM_RESULT error codes is returned.

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

See also
ccs_declare_custom_colorspace(), ccs_close_profile()

◆ hybrid_open_profile()

static sw_cmm_result hybrid_open_profile ( sw_cmm_instance instance,
sw_blob_instance ICC_profile,
sw_cmm_profile handle 
)
static

Create an internal profile structure for ICC profile data stored in memory.

This function trampolines onto the open_profile() function from the LittleCMS example module.

Parameters
[in]instanceThe alternate CMM implementation instance owning the ICC profile.
[in]ICC_profileA blob data source, giving access to the raw ICC profile data through the blob's sw_blob_api implementation methods. This blob will have been opened for non-exclusive read access. If the alternate CMM wishes to use the data source after the open_profile() method returns, it must create a new blob reference using the sw_blob_api::open_blob() method, and use that reference for all access after open_profile() terminates. If a new blob reference is created, the alternate CMM implementation must close that reference when it has finished accessing to it.
[out]handleA pointer in which a CMM profile handle is stored. This handle will be used to refer to the profile by close_profile(), open_transform(), and open_transform2().
Returns
SW_CMM_SUCCESS if the profile was successfully opened, in which case a non-NULL profile pointer should have been stored in handle. If the profile could not be opened, one of the SW_CMM_RESULT error codes is returned.

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

See also
hybrid_close_profile(), lcms_open_profile()

◆ hybrid_open_transform()

sw_cmm_result hybrid_open_transform ( sw_cmm_instance instance,
sw_cmm_profile  profiles[],
uint32  num_profiles,
int32  intents[],
HqBool  black_point_compensations[],
uint32 num_input_channels,
uint32 num_output_channels,
sw_cmm_transform handle 
)
static

Create a transform structure for the example CMM.

This function trampolines onto the open_transform() function from the LittleCMS or Custom Color Space example module as appropriate.

Parameters
[in]instanceThe alternate CMM instance owning the profiles.
[in]profilesAn array of num_profiles profile handles, returned by calls to open_profile() or open_custom_colorspace().
num_profilesThe number of profiles in the transform chain.
[in]intentsAn array of length num_profiles-1 specifying the rendering intents use for color conversions between adjacent profiles in the profiles parameter.
[in]black_point_compensationsAn array of length num_profiles-1 containing boolean flags, indicating if black point compensation is performed when converting colors between adjacent profiles in the profiles parameter.
[out]num_input_channelsA location for the alternate CMM 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 alternate CMM 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 CMM transform handle is stored by the alternate CMM implementation. This handle will be used to refer to the transform by close_transform() and invoke_transform() methods.
Returns
SW_CMM_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_CMM_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
hybrid_close_transform(), hybrid_invoke_transform()

◆ hybridcms_getInstance()

sw_cmm_api* hybridcms_getInstance ( void  )

Return the singleton instance of a sw_cmm_api object containing details specific to the Hybrid CMM example module.

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

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.