ImageGear for C and C++ on Windows v20.5 - Updated
IG_image_resolution_get
API Reference Guide > Core Component API Reference > Core Component Functions Reference > General Image Functions > IG_image_resolution_get

This function retrieves the current resolution settings of the HIGEAR image.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_image_resolution_get(
        HIGEAR hIGear, 
        LPLONG lpXResNumerator, 
        LPLONG lpXResDenominator, 
        LPLONG lpYResNumerator, 
        LPLONG lpYResDenominator, 
        LPAT_MODE lpnUnits
);

Arguments:

Name Type Description
hIGear HIGEAR HIGEAR handle to the image.
lpXResNumerator LPLONG Pointer to a LONG variable that receives the x resolution numerator.
lpXResDenominator LPLONG Pointer to a LONG variable that receives the x resolution denominator.
lpYResNumerator LPLONG Pointer to a LONG variable that receives the y resolution numerator.
lpYResDenominator LPLONG Pointer to a LONG variable that receives the y resolution denominator.
lpnUnits LPAT_MODE Pointer to an AT_MODE variable that receives the resolution units. See enumIGResolutionUnits for possible values.

Return Value:

Returns the number of ImageGear errors that occurred during this function call.

Supported Raster Image Formats:

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

Sample:

Color, MFC Multipage, Print

Example:

 
Copy Code
HIGEAR hIGear;
AT_RESOLUTION res;
AT_ERRCOUNT  nErrCount;

// Load the image
nErrCount = IG_load_file("picture.tif", &hIGear);

if (nErrCount == 0)
{
        // Obtain the image's resolution
        nErrCount = IG_image_resolution_get(hIGear, &res.xResNumerator, &res.xResDenominator,
                &res.yResNumerator, &res.yResDenominator, &res.nUnits);

        // Change the current resolution setting to INCHES
        if (nErrCount == 0)
                nErrCount = IG_util_resolution_units_convert(&res, IG_RESOLUTION_INCHES);

        // Set the modified resolution
        if (nErrCount == 0)
                nErrCount = IG_image_resolution_set(hIGear, res.xResNumerator, res.xResDenominator,
                res.yResNumerator, res.yResDenominator, res.nUnits);

        // ...

        // Delete the image
        IG_image_delete(hIGear);
}

Remarks:

This function returns the resolution values and units of the HIGEAR image.

ImageGear stores resolution as a pair or rational numbers and a unit specification. This is the method used by several image file formats, which allows storing precise resolution values, rather than their double or float approximations. To set the X resolution of the image to 300 DPI, the numerator can be 300 and the denominator 1 (900 and 3 would also work).

Use IG_image_resolution_set to set image resolution.

Use IG_util_resolution_units_convert to convert resolution to different units.

An alternative way to obtain the image resolution is to get its DIB information using IG_image_DIB_info_get, and then get the resolution using IG_DIB_resolution_get.

Is this page helpful?
Yes No
Thanks for your feedback.