ImageGear Professional DLL for Windows
Converting Image Color Space

Color space conversion is available for a separate raster as well as for an entire image. The simplest version may be used to convert an entire image. For these purposes, IG_image_colorspace_convert() routine must be used. It takes image, new color space identifier, and conversion options (optionally) as incoming parameters. It is necessary to note that the channels structure of the converted image may differ from the initial one. The most common changes are the quantity of channels and the depth of channels. The quantity of channels may be changed because of differences in color space and because of changes in extra channels (controlled by conversion options). Changes in depth usually occur if the source channels have different depths (e.g., if the source image has 5-6-5 bits per pixel, the converted image will have 6-6-6 channel depths).

The AT_COLORSPACE_CONVERSION_OPTIONS structure provides advanced control for color space conversion. Below is the explanation of each attribute:

Advanced color space conversion routines allow you to operate not only on images, but also on particular rasters. It's also possible to supply a custom channels structure to produce conversion data with the necessary channel depths.

To start operating conversion, a HIGCSCONVERTER instance must be created. Any of IG_colorspace_conversion_create(), IG_colorspace_conversion_create_from_image(), or IG_colorspace_conversion_create_from_dib_info() may be used for this purpose. The first variation has eight incoming parameters and one output:

IG_colorspace_conversion_create_from_image() and IG_colorspace_conversion_create_from_dib_info() are designed for convenience and retrieve source attributes (space, palette, channels) from supplied image or DIB information.

Once a color space converter has been allocated, it may be used in any of IG_colorspace_conversion_apply_to_image() and IG_colorspace_conversion_apply_to_raster() routines.

To release conversion, IG_colorspace_conversion_destroy() routine must be used.

It's necessary to note that advanced conversion routines may be used not only for color space conversion, but for channel depth change, too (even if IsRaw attribute of conversion options is turned on). It's possible to provide the desired channels structure, and the converter will produce output according to the specified structure.

Auxiliary routines of advanced color space conversion are IG_colorspace_conversion_result_palette_get() and IG_colorspace_conversion_result_channels_build().

IG_colorspace_conversion_result_palette_get() is designed to produce a palette if the new color space is indexed. But note that conversion to IG_COLOR_SPACE_ID_I color space is possible only from IG_COLOR_SPACE_ID_I and IG_COLOR_SPACE_ID_Gy with a depth not greater than eight.

IG_colorspace_conversion_result_channels_build() may be used to get the default channels structure for converted data. The result of this routine is used by conversion routines if resultChannelDepths parameter has a NULL value.

 

 


©2014. Accusoft Corporation. All Rights Reserved.

Send Feedback