ImageGear for C and C++ on Windows v19.6 - Updated
biCompression - Retrieving Compression Type / Color Space
User Guide > Concepts > Migrating from ImageGear v14 > biCompression - Retrieving Compression Type / Color Space

Prior to 14.5, biCompression was used as a means of extending the Windows DIB header to include information about other compression types and color spaces. Possible values are listed in the enumIGBiCompression enumeration in accucnst.h. Some examples are things like IG_BI_RGB, IG_BI_CMYK, IG_BI_GRAYSCALE, IG_BI_RLE, and so on.

In 14.5, the BITMAPINFOHEADER / AT_DIB struct is no longer used, so there's no biCompression. However, this value can still be retrieved by using the function IG_image_compression_type_get. It retrieves the same kind of value that biCompression held (from enumIGBiCompression). Note, however, that a new value was added to this enumeration: IG_BI_EXT. IG_image_compression_type_get will return this value if the image cannot be sufficiently described by any of the old enumeration values. Some examples of images for which IG_BI_EXT is returned are 1) an image with an alpha channel and 2) a 36-bit RGB image.

Instead of retrieving an image's "compression type", which has really been used more like "image type", you should consider retrieving the image's color space instead. In 14.5, you can get an image's color space by calling IG_image_colorspace_get. What you get back is a color space ID. This ID is made up of one or more values from the enumIGColorSpaceIDs enumeration defined in accucnst.h. A color space ID is a bitfield, so it can contain one or more of the following pieces of information:

To isolate the piece of information you're interested in, you must use a bitmask such as IG_COLOR_SPACE_ID_ColorMask.

Consider the following sample function which determines whether or not an image is bi-tonal:

 
Copy Code
// Is the given image bi-tonal? (1 bit per pixel for color channel)
BOOL isBitonal(HIGEAR hImage)
{
    // The color space must be indexed
    enumIGColorSpaceIDs cs;
    IG_image_colorspace_get(hImage, &cs);
    if ((cs & IG_COLOR_SPACE_ID_ColorMask) != IG_COLOR_SPACE_ID_I)
        return FALSE;
    // The color channel must have a depth of 1
    HIGDIBINFO hDIB;
    IG_image_DIB_info_get(hImage, &hDIB);
    AT_INT depth = IG_DIB_channel_depth_get(hDIB, 0);
    IG_DIB_info_delete(hDIB);
    if (depth != 1)
        return FALSE;
    return TRUE;
}