ImageGear for C and C++ on Windows v21.0 - Updated
API Reference Guide / Core Component API Reference / Core Component Functions Reference / Info Functions / IG_info_get_mem_ex
In This Topic
    IG_info_get_mem_ex
    In This Topic

    This function obtains information about the image located in the memory buffer.

    Declaration:

     
    Copy Code
    AT_ERRCOUNT ACCUAPI IG_info_get_mem_ex(
       VOID FAR32* lpImage32,
       AT_UINT dwSize,
       UINT nPage,
       LPAT_MODE lpFileType,
       LPAT_MODE lpCompression,
       HIGDIBINFO* lphDIB
    );
    

    Arguments:

    Name Type Description
    lpImage32 VOID FAR32* Pointer to start of file image in memory.
    dwSize AT_UINT Size of image in memory.
    nPage UINT Page number about which to get information, if a multi page file set to 1 or greater; for a non multi page file set to 1.
    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 the compression type will be returned. See enumIGCompressions for possible values.
    lphDIB HIGDIBINFO* Pointer to an HIGDIBINFO 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:

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

    Sample:

    MemIO

    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
    HIGDIBINFO hDIB;
    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_ex(lpBuffer, nBufferSize, 1, &nFileType, &nCompression, &hDIB);
        fclose(fp);
    
        // ...
        // Delete memory buffer
        free(lpBuffer);
        // Delete DIB info
        IG_DIB_info_delete(hDIB);
    }
    

    Remarks:

    See also IG_info_get_FD_ex and IG_info_get_ex functions.