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

This function loads an image from the specified file into memory and creates a HIGEAR handle for the image.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_load_file(
   const LPSTR lpszFileName,
   LPHIGEAR lphIGear
);

Arguments:

Name Type Description
lpszFileName const LPSTR Name of image file (you may include path with filename) to load into memory.
lphIGear LPHIGEAR Pointer to HIGEAR object in which to return the ImageGear handle of the 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:

Clipboard, Color, Display, GUI Windows, Image Processing, JPEG, Magnify, Medical, MFC, Palette Edit, Pixel Access, Thumbnail, MFC Threads, Annotation, Vector, Filters, FlashPix, ImageClean, MULTIMED, Scan, TWAIN

Example:

 
Copy Code
HIGEAR hIGear = 0;            /* Will hold handle returned by IG_load_file*/
AT_ERRCOUNT nErrcount;    /* Count of errs on stack upon ret from func*/
/* Load image file "picture.bmp" from working directory, creating DIB */
/* and obtaining the image's ImageGear handle: */
nErrcount = IG_load_file ( "picture.bmp" , &hIGear );

//...

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

Remarks:

The handle which ImageGear assigns for this image is returned to you in argument lphIGear. The file named by filename may be in any format recognized by ImageGear. IG_load_file() will determine the format by inspecting the file's header section. See ImageGear Supported File Formats Reference for information on image file formats supported by ImageGear.

Note that simply loading 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.

Some file formats, such as TXT, JPEG, and others, may be loaded with additional control, using IG_fltr_ctrl_get and IG_fltr_ctrl_set. See the description of these functions also in Loading and Saving.

If the file pointed to by lpszFileName has multiple pages (images), the function will load the first page. To load pages of multi-page images, use IG_fltr_load_file, IG_load_FD or IG_load_mem.

This function can also be used to load Internet files. See the example code. The function IG_load_internet is a more versatile function for loading Internet files.