ImageGear for C and C++ on Windows v19.10 - Updated
IG_load_tiles_stitch_mem
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Load Functions > IG_load_tiles_stitch_mem

This function loads and stitches together a tiled image that has already been loaded into memory, returning you a HIGEAR handle to the image.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_load_tiles_stitch_mem(
   LPVOID lpImage,
   AT_UINT nSize,
   UINT nPage,
   LPAT_STITCH lpStitch,
   LPHIGEAR lphIGear
);

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.
lpStitch LPAT_STITCH Set to a structure of type AT_STITCH, which defines the reference tile number, and the number of rows and columns of tiles.
lphIGear LPHIGEAR Returns a HIGEAR handle to the newly stitched-together image.

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:

None

Example:

 
Copy Code
AT_ERRCOUNT  nErrcount;
HIGEAR hIGear;
char far * lpWhereFile;
AT_UINT         nWholeSize;
AT_STITCH stitchStruct = {1, 1, 1};
// Open a file and get its size
FILE* fd;
fopen_s(&fd, "picture.tif", "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);
}

if(lpWhereFile != NULL)
{
    nErrcount = IG_load_tiles_stitch_mem(lpWhereFile, nWholeSize, 1, &stitchStruct, &hIGear);
    // delete memory 
    free(lpWhereFile);
}

//...

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

Remarks:

The AT_STITCH structure allows you to tell ImageGear which tile to use as the upper-left corner in the new stitched image, and how many tile rows and columns should be stitched together. For a graphical representation of how this works, see Working with Tiled Images.

Simply loading and stitching the file does not cause it to be displayed. Refer to IG_dspl_image_draw and related routines, for how to display an image once it is in memory. See also IG_load_file_display function.

The nPage argument is set to 1 or greater if you are loading from a multi-page file, to indicate which page (image) you want to load. Set nPage to 1 for a non multi-page file.

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.

See also IG_load_tiles_stitch, IG_load_tiles_stitch_FD, IG_tile_count_get_memfunctions.

For a complete discussion of working with tiled images, see Working with Tiled Images.