ImageGear for C and C++ on Windows v19.10 - Updated
IG_DIB_colorspace_get
API Reference Guide > Core Component API Reference > Core Component Functions Reference > DIB Functions > IG_DIB_colorspace_get

This function returns the image's color space.

Declaration:

 
Copy Code
enumIGColorSpaceIDs ACCUAPI IG_DIB_colorspace_get(
        HIGDIBINFO hDIB
);

Arguments:

Name Type Description
hDIB HIGDIBINFO DIB info handle.

Return Value:

Returns a combination of values from enumIGColorSpaceIDs.

Supported Raster Image Formats:

All pixel formats supported by ImageGear for C and C++.

Sample:

None

Example:

 
Copy Code
AT_ERRCOUNT nErrcount;  /* Number of errors on stack */
HIGDIBINFO hDIBInfo;    /* DIB info handle */
HIGEAR hImage;          /* HIGEAR handle of image */
enumIGColorSpaceIDs colorspace; /* Color space of image */
AT_BOOL bIndexed;       /* Is color space of image indexed? */
AT_BOOL bHasAlpha;      /* Does image have an alpha channel? */
/* Find out if an image is indexed, and if it has alpha */
nErrcount = IG_image_DIB_info_get(hImage, &hDIBInfo);
colorspace = IG_DIB_colorspace_get(hDIBInfo);
bIndexed = (colorspace & IG_COLOR_SPACE_ID_ColorMask) == IG_COLOR_SPACE_ID_I;
bHasAlpha = colorspace & IG_COLOR_SPACE_ID_A;

Remarks:

This is a bitmask that indicates the color space as well as the presence of alpha, pre-multiplied alpha, and extra channels.

See the IG_util_colorspace_...() functions for more functions that retrieve information about color spaces, alpha, and extra channels.

Use caution when extracting information from this bitmask. For example, if you want to look at only the color space, you must use the mask IG_COLOR_SPACE_ID_ColorMask as in the example.