ImageGear for C and C++ on Windows v19.7 - Updated
IG_image_orientation_get
API Reference Guide > Core Component API Reference > Core Component Functions Reference > General Image Functions > IG_image_orientation_get

This function tells you the orientation of the image.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_image_orientation_get(
       HIGEAR hIGear,
       LPAT_MODE lpOrientation
);

Arguments:

Name Type Description
hIGear HIGEAR HIGEAR handle of image.
lpOrientation LPAT_MODE A constant of type AT_MODE that will return the current orientation of the HIGEAR image. See enumOrientation for possible values.

Return Value:

Returns 0 if successful. Otherwise, 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:

Filter

Example:

 
Copy Code
AT_ERRCOUNT nErrcount;  // Number of errors on stack
HIGEAR hIGear;          // Handle of image
AT_MODE nOrientation;    // Image orientation

// Load image file "picture.bmp" from working directory
nErrcount = IG_load_file("picture.bmp", &hIGear);
if(nErrcount == 0)
{
    nErrcount = IG_image_orientation_get(hIGear, &nOrientation);
    // ...
    // Destroy the image
    IG_image_delete(hIGear);
}

Remarks:

The two most frequently used orientations are "Portrait" and "Landscape." However, in order to provide complete support for the TIFF file format, which defines eight image orientations, ImageGear interprets eight orientations. For an image with a "Portrait" orientation, this value would normally be IG_ORIENT_TOP_LEFT. For an image with "Landscape" orientation, this value would be either IG_ORIENT_RIGHT_TOP or IG_ORIENT_LEFT_BOTTOM. See enumOrientation for descriptions of all orientation modes.

Notice that the IG_ORIENT constants contain indicators of two directions. For IG_ORIENT_TOP_LEFT, the first direction is "TOP." This specifies the placement of row 0 of the image. The second direction is "LEFT", and this specifies the placement of column 0. Thus, IG_ORIENT_TOP_LEFT specifies that row 0 of the image stored in the file should be displayed at the top and column 0 should be displayed at the left. This is the normal orientation of most images. On the other hand, IG_ORIENT_LEFT_BOTTOM specifies that row 0 should be displayed at the left and column 0 at the bottom. For this to be true the image would have to be rotated 90 degrees counterclockwise.

The orientation setting is stored in the header structure of those file formats that support the storage of orientation information. The orientation setting tells how the image was intended to be displayed. In the example above, the bitmap image is not necessarily stored "sideways." When you find that it is intended to be displayed sideways, you could call IG_dspl_orientation_get to display it in its intended orientation, or call IG_IP_rotate_multiple_90 to rearrange the actual bitmap data so that the image is actually stored sideways.