ImageGear for C and C++ on Windows v20.0 - Updated
IG_info_get_mem
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Info Functions > IG_info_get_mem

This function obtains information about the image located in a memory buffer. This is an obsolete function, see remarks.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_info_get_mem(
   LPVOID lpImage,
   AT_UINT nImageSize,
   UINT nPage,
   LPAT_MODE lpFileType,
   LPAT_MODE lpCompression,
   LPAT_DIB lpDIB
);

Arguments:

Name Type Description
lpImage LPVOID Pointer to memory location of an image file that is currently in memory.
nImageSize AT_UINT Size of image in memory.
nPage UINT Page number for which the info is obtained. Note that page numbers begin at 1, not 0. Set nPage to 1 if this is not a multi-page memory file.
lpFileType LPAT_MODE Pointer to an AT_MODE variable in which the file type will be returned. See enumIGFormats for possible values.
lpCompression LPAT_MODE Pointer to an AT_MODE variable in which compression type will be returned. See enumIGCompressions for possible values.
lpDIB LPAT_DIB Pointer to an AT_DIB structure to which other file information such as width, height, and Bits Per Pixel will be returned.

Return Value:

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

Supported Raster Image Formats:

If lpDIB is not NULL, then

otherwise, all pixel formats supported by ImageGear for C and C++.

Sample:

None

Example:

 
Copy Code
char* lpBuffer;            // Memory buffer with the image
AT_UINT nBufferSize;    // Size of the memory buffer
AT_MODE nFileType;        // Will receive an IG_FORMAT_ constant
AT_MODE nCompression;    // Will receive an IG_COMPRESSION_ constant
AT_DIB atDIB;
AT_ERRCOUNT nErrcount;        // Returned count of errors

// Open a file and get its size
FILE* fp = NULL;
fopen_s(&fp, "picture.bmp", "rb");
if(fp != NULL)
{
    fseek(fp, 0, SEEK_END);
    nBufferSize = (AT_UINT)ftell(fp);
    fseek(fp, 0, SEEK_SET);
    // Allocate memory and read the image into the memory buffer
    lpBuffer = (char*)malloc(nBufferSize);
    fread(lpBuffer, 1, nBufferSize, fp);
    // File is no longer needed - close it
    fclose(fp);
    // Get image info
    nErrcount = IG_info_get_mem(lpBuffer, nBufferSize, 1, &nFileType, &nCompression, &atDIB);
    fclose(fp);

    // ...
    // Delete memory buffer
    free(lpBuffer);
}

Remarks:

This function is only kept for backward compatibility reasons. Please use IG_info_get_mem_ex instead.

Any of the output parameters such as lpFileType, lpCompression or lpDIB can be NULL, if the corresponding info is not required.

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