ImageGear Professional DLL v17.1 for Windows Accusoft
IG_load_mem_CB_ex
Send Feedback  
ImageGear Professional DLL v17.1 for Windows > API Reference Guide > Core Component API Reference > Core Component Functions Reference > Load Functions > IG_load_mem_CB_ex

Glossary Item Box

This function loads an image from a file using user-defined callback functions.

Declaration:

  Copy Code
AT_ERRCOUNT ACCUAPI IG_load_mem_CB_ex(
   LPVOID lpImage,
   AT_UINT nSize,
   UINT nPage,
   UINT nReserved,
   LPFNIG_RASTER_SET lpfnRasterSet,
   LPFNIG_DIB_CREATE_EX lpfnDIBCreateEx,
   LPVOID lpPrivateData
);

Arguments:

lpImage Pointer to a memory buffer containing the image.
nSize Size of image in memory.
nPage Page number to load if this is a multi-page file. Note that page numbers begin at 1, not 0. Set nPage to 1 if this is not a multi-page file.
nReserved Reserved, should be set to 0 for now.
lpfnRasterSet Pointer to callback function to be called after each raster line is read. See LPFNIG_RASTER_SET.
lpfnDIBCreateEx Pointer to callback function to be called after the file header has been read. See LPFNIG_DIB_CREATE_EX.
lpPrivateData Pointer to a private data area. This pointer will be passed to the callback functions.

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 Professional.

Actual set of pixel formats supported by this function can be narrower, depending on the implementation of the user-defined callback function.

Sample:

None

Example:

  Copy Code
HIGEAR hIGear = 0;      /* handle ret'd by ImageGear  */
char* lpWhereFile; /* ptr to image file in mem   */
AT_UINT nWholeSize;    /* Size of image in memory */
AT_ERRCOUNT nErrcount;  /* to test for errors         */

// Open a file and get its size
FILE* fd = NULL;
fopen_s(&fd, "picture.bmp", "rb");
if(fd != NULL)
{
    fseek(fd, 0, SEEK_END);
    nWholeSize = (AT_UINT)ftell(fd);
    fseek(fd, 0, SEEK_SET);
    // Allocate memory and read the image into the memory buffer
    lpWhereFile = (char*)malloc(nWholeSize);
    fread(lpWhereFile, 1, nWholeSize, fd);
    // File is no longer needed - close it
    fclose(fd);
    // Load image from the memory
    nErrcount = IG_load_mem_CB_ex(lpWhereFile, nWholeSize, 1, 0, MyRasterSet, MyDIBCreateEx,  &hIGear);
    // delete memory 
    free(lpWhereFile);
}

//...

// Destroy the image
if(IG_image_is_valid(hIGear))
{
    IG_image_delete(hIGear);
}

If you set nPage to < 1, ImageGear will default the value to 1; if you set nPage to greater than the number of pages in the document, ImageGear will default the value to the last page number. This same default procedure applies to the nTileNum parameter as well.

See Also

IG_load_FD_CB

IG_load_mem

©2012. Accusoft Corporation. All Rights Reserved.