ImageGear for C and C++ on Windows v19.10 - Updated
Color Profile Manager API
User Guide > How to Work with... > Color > Color Profile Manager > Color Profile Manager API

There are public functions implemented in ImageGear that allow you to set and get actual values for each group of color profiles.

To start working with the color profile manager, it is necessary to activate it. By default, the color profile manager is disabled in ImageGear, and all color-related operations are exactly the same as in previous versions. There is a Boolean global parameter named CPM.ENABLE_PROFILES used to control color profile management.

To activate color profile management, call the ImageGear global control function (see also Working with Global Control Parameters):

 
Copy Code
AT_BOOL     bEnable = TRUE;IG_gctrl_item_set( "CPM.ENABLE_PROFILES", AM_TID_AT_BOOL,  &bEnable,
sizeof(AT_BOOL), NULL );

When using color management, additional files are necessary: color profile files to be used as default profiles. By default those files should be located in the same folder as ImageGear and its components, and those files should be named as "ig_rgb_profile.icm" and "ig_cmyk_profile.icm" for RGB and CMYK color spaces, respectively. Correspondent global parameters CPM.RGB_PROFILE_PATH and CPM.CMYK_PROFILE_PATH exist to specify the full path to default profiles. Their values can be changed using the function IG_gctrl_item_set(), like in the following example:

 
Copy Code
CHAR     profile[256];
strcpy( profile, "d:\\profile\\rgb_profile.icm" );
IG_gctrl_item_set( "CPM.RGB_PROFILE_PATH", AM_TID_MAKELP(AM_TID_CHAR), profile,
strlen(profile)+1, NULL );

After color profile management is activated, it is possible to use the next functions to set color profiles in global parameters or to a specific image and to get information about currently used profiles.

The function:

 
Copy Code
IG_cpm_profile_set(       AT_MODE nColorSpace,        DWORD nProfileGroup,        LPBYTE lpRawData,        DWORD dwRawSize,        AT_BOOL  bConvert);

allows you to set a new color profile value (lpRawData) to a group specified by the second argument and associate it with the color space given by the first argument. lpRawData is a pointer to the memory buffer that contains the color profiles in valid ICC format, and if it is NULL then the default color profile will be set. The last argument specifies how to process the color data of the images associated with it. If it is TRUE then all images associated with the color profile will be converted to a new color format.

The function:

 
Copy Code
IG_cpm_image_profile_set(       HIGEAR hIGear,        LPBYTE lpRawData,        DWORD dwRawSize,        AT_BOOL  bConvert);

is a special case of a working profile set operation that associates a given color profile with a single image. In this case the image becomes associated not with a global working profile but with a locally given profile.

The function:

 
Copy Code
IG_cpm_profile_get(       AT_MODE nColorSpace,        DWORD nProfileGroup,        LPCHAR pStatusStr,       UINT nStatusSize,        LPUINT lpnStatusLen,        LPDWORD lpnProfileSize,        LPBYTE lpProfileData,        DWORD dwProfileDataSize);

can be used to get the current value of a color profile associated with the color space given by the first argument in the profile group specified by the second argument. Other arguments return information about the profile along with the profile itself.

To get the color profile information associated with a given image, the function:

 
Copy Code
IG_cpm_image_profile_get(       HIGEAR hIGear,        LPAT_BOOL lpbIsLocal,       LPAT_MODE lpnColorSpace,        LPCHAR lpStatusStr,       UINT nStatusSize,        LPUINT lpnStatusLen,        LPDWORD lpnProfileSize,        LPBYTE lpProfileData,        DWORD dwProfileDataSize);

can be used. It returns information about the local profile if it is associated with an image, or a global profile otherwise. The second argument returns TRUE if the local profile is associated or FALSE if it is not.

The function:

 
Copy Code
IG_cpm_profiles_reset(AT_BOOL bConvert)

is introduced to reset all global profiles to their default values. If bConvert is TRUE, then all images associated with the old previous profiles will be converted to the new ones.

For a detailed description of the color profile functions, please see the Core Component API Function Reference.