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

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 nTile,
   LPFNIG_RASTER_SET lpfnRasterSet,
   LPFNIG_DIB_CREATE_EX lpfnDIBCreateEx,
   LPVOID lpPrivateData
);

Arguments:

Name Type Description
lpImage LPVOID Pointer to a memory buffer containing the image.
nSize AT_UINT Size of image in memory.
nPage UINT 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.
nTile UINT If loading an image that is tiled, you can set the number of a specific tile to load. Tile numbers begin at 1, not 0. Set to 1 for a non-tiled image.
lpfnRasterSet LPFNIG_RASTER_SET Pointer to callback function to be called after each raster line is read.
lpfnDIBCreateEx LPFNIG_DIB_CREATE_EX Pointer to callback function to be called after the file header has been read.
lpPrivateData LPVOID 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 for C and C++.

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
AT_ERRCOUNT ACCUAPI MyDIBCreateEx( 
    LPVOID             lpPrivate, /* Private data passed in  */
    const HIGDIBINFO   hDIB       /* DIB info object for DIB */
    )
{
    /* Get info about image and allocate storage here */
    return 0;
}
AT_ERRCOUNT ACCUAPI MyRasterSet( 
    LPVOID           lpPrivate,   /* Private data passed in  */
    const LPAT_PIXEL lpRaster,    /* Raster line to set      */
    AT_PIXPOS        row,         /* Y position in the image */
    DWORD            rasterSize   /* Size of the raster line */
    )
{
    /* Do something with incoming raster data here */
    return 0;
}

void Example_IG_load_FD_CB_ex()
{
    AT_ERRCOUNT nErrcount;  /* Number of errors on stack */
    HANDLE fd;               /* File descriptor */
    DWORD dwPrivate[10];    /* Some private data */ 
    fd = CreateFile(_T("picture.bmp"), GENERIC_READ,
            0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

    if (fd != INVALID_HANDLE_VALUE)
    {
        nErrcount = IG_load_FD_CB_ex(
            (AT_INT)fd,       /* File descriptor             */
            0L,               /* Offset to image             */
            1,                /* Page number to load         */
            1,                /* Tile number to load         */
            MyRasterSet,      /* Called for each raster line */
            MyDIBCreateEx,    /* Called after header is read */
            dwPrivate);       /* Callback data               */
        CloseHandle(fd);
    }
}

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

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