This example module handles colors conversions that normally require an ICC CMM. More...
Modules | |
PS device for setting parameters used by the Pure Color CMM example | |
The %cmmparams% example PostScript device for setting configuration parameters used by the PureColor CMM example. | |
Files | |
file | cmm_purecolor.h |
CMM Interface to pure color preservation module. | |
file | cmm_purecolor.c |
CMM Implementation of an example module that preserves pure colors and uses the RIP's built-in ICC CMM for non-pure colors. | |
Functions | |
sw_cmm_api * | purecolor_getInstance (void) |
Return the singleton instance of a sw_cmm_api object containing details specific to Pure Color CMM example module. More... | |
static sw_cmm_result | purecolor_construct (sw_cmm_instance *instance) |
Construct an instance of the sw_cmm_api interface. More... | |
static sw_cmm_result | purecolor_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 | purecolor_close_profile (sw_cmm_instance *instance, sw_cmm_profile profile) |
Close a profile with a handle previously created by purecolor_open_profile(). More... | |
static sw_cmm_result | purecolor_open_transform2 (sw_cmm_instance *instance, sw_cmm_profile profiles[], uint32 num_profiles, int32 intents[], HqBool black_point_compensations[], HqBool compositing, sw_cmm_object_type object_type, sw_cmm_color_model color_model, uint32 *num_input_channels, uint32 *num_output_channels, sw_cmm_transform *handle) |
Create a transform structure for the example CMM. More... | |
void | purecolor_close_transform (sw_cmm_instance *instance, sw_cmm_transform transform) |
Close a transform previously opened with purecolor_open_transform2(). More... | |
static sw_cmm_result | purecolor_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... | |
This example module handles colors conversions that normally require an ICC CMM.
First, color values are deemed to be either pure or non-pure. Non-pure colors are not converted by this module; instead they are passed back to the RIP for it to convert using its built-in ICC CMM. The pure colors are converted by this module using a simple method to preserve their pureness.
The pureness of the preserved colors is controled by parameters set in the associated %cmmparams%
PostScript device. These parameters are:
The code behind these parameters are in the cmm_params.c file.
These parameters are set using setdevparams
, e.g.:
The parameters may also be read using currentdevparams
, e.g.:
To configure the RIP to use this color management module, use this fragment in the configuration PostScript:
This example module is registered by calling SwRegisterCMM() with the singleton API instance returned by purecolor_getInstance(). The pure color parameters device must also be registered by calling purecolor_register_params(). The module implements the CMM API methods purecolor_construct(), purecolor_open_profile(), purecolor_close_profile(), purecolor_open_transform2(), purecolor_close_transform() and purecolor_invoke_transform().
|
static |
Close a profile with a handle previously created by purecolor_open_profile().
This function only needs to free the memory that was previously allocated.
[in] | instance | The alternate CMM instance owning the profile. |
[in] | profile | A 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. |
void purecolor_close_transform | ( | sw_cmm_instance * | instance, |
sw_cmm_transform | transform | ||
) |
Close a transform previously opened with purecolor_open_transform2().
This function only needs to free the memory that was previously allocated.
[in] | instance | The alternate CMM instance owning the color transform. |
[in] | transform | A 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. |
|
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 definiing 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.
[in,out] | instance | An 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. |
sw_cmm_api* purecolor_getInstance | ( | void | ) |
Return the singleton instance of a sw_cmm_api object containing details specific to Pure Color CMM example module.
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.
|
static |
Use the specified transform to adjust color data.
This function decides whether an input color is pure or non-pure. Pure colors are preserved in the output by copying the original color. The non-pure colors are passed back to the RIP for it to handle using the built-in ICC CMM.
Various parameters control the decision of whether this color is pure. These are documented in the cmm_param.c file.
[in] | instance | The alternate CMM instance owning the color transform. |
[in] | transform | A valid transform handle created by an open_transform() call on the same alternate CMM instance. |
[in] | input_data | An 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_data | An 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_pixels | The number of sets of input pixel colorvalues to convert from the input space to the output space of the transform. |
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:
num_pixels * num_input_channels * sizeof(float)
num_pixels * num_output_channels * sizeof(float)
|
static |
Create an internal profile structure for ICC profile data stored in memory.
This function extracts data sufficient to the needs of the module using methods from the LittleCMS API. To simplify this example, it trampolines on the open_profile() function of the LittleCMS example to create a LittleCMS profile. That is the only purpose of using LittleCMS, so this function closes the LittleCMS profile since it is of no further use.
[in] | instance | The alternate CMM implementation instance owning the ICC profile. |
[in] | ICC_profile | A 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] | handle | A 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(). |
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.
|
static |
Create a transform structure for the example CMM.
This function is simple, it only records whether the input and output ICC profiles were CMYK or RGB. Other ICC profiles are ignored and will be handled by the RIPs built-in CMM.
This is essentially a duplicate of open_transform() but with additional parameters for object type, color model, and transparency compositing flag.
[in] | instance | The alternate CMM instance owning the profiles. |
[in] | profiles | An array of num_profiles profile handles, returned by calls to open_profile() or open_custom_colorspace(). |
num_profiles | The number of profiles in the transform chain. | |
[in] | intents | An array of length num_profiles-1 specifying the rendering intents use for color conversions between adjacent profiles in the profiles parameter. |
[in] | black_point_compensations | An 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. |
[in] | compositing | A boolean flag indicating if this transform is part of transparency compositing. This may also be true for some transforms when OverprintPreview is active. |
[in] | object_type | One of the values of sw_cmm_object_type. |
[in] | color_model | One of the values of sw_cmm_color_model. |
[out] | num_input_channels | A 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_channels | A 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] | handle | A 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. |
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.
If both open_transform() and open_transform2() are both present in an implementation, only open_transform2() will be called.