ImageGear for C and C++ on Windows v20.3 - Updated
IG_fltr_detect_FD
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Filter Functions > IG_fltr_detect_FD

This function detects the format of the image file specified by a file descriptor.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_fltr_detect_FD(
   AT_INT fd,
   LONG lOffset,
   LPAT_MODE lpFileType
);

Arguments:

Name Type Description
fd AT_INT Handle of the open file containing the image. This handle can be obtained from Microsoft Windows functions such as CreateFile(), and cast to AT_INT for passing to the function parameter. FILE pointers returned by functions such as fopen(), and file handles returned by functions such as _sopen_s() are not supported.
lOffset LONG Offset into the file, in bytes, to where the image begins. This is the offset to the beginning of the header, not to the beginning of the bitmap. lOffset is usually 0.
lpFileType LPAT_MODE Pointer to an AT_MODE variable in which the file type will be returned. See enumIGFormats for possible values. If the file format can not be detected, this parameter will return IG_FORMAT_UNKNOWN.

Return Value:

Returns 0 if successful. Otherwise, returns the number of ImageGear errors that occurred during this function call.

Supported Raster Image Formats:

This function does not process image pixels.

Sample:

None

Example:

 
Copy Code
AT_ERRCOUNT nErrCount;    // will hold returned error count
AT_MODE nFormatID;
HANDLE      fd;                            //File Descriptor

fd = CreateFile(_T("picture.tif"), GENERIC_READ,
        0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(fd != INVALID_HANDLE_VALUE)
{
    nErrCount = IG_fltr_detect_FD((AT_INT)fd, 0, &nFormatID);
    if(nFormatID == IG_FORMAT_TIF)
    {
        // ...
    }
    CloseHandle(fd);
}

Remarks:

See also the section Detecting Image File Format.

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