ImageGear for C and C++ on Windows v20.1 - Updated
IG_mpi_file_open
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Multi Page Image Functions > IG_mpi_file_open

This function allows you to associate a multi-page image with an external image file.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_mpi_file_open( 
        [IN] const LPCHAR lpFileName,
        [IN] HMIGEAR hMIGear, 
        [IN] AT_MODE nFormat, 
        [IN] AT_MODE nOpenMode 
);

Arguments:

Name Type Description
lpFileName const LPCHAR The far pointer to the filename (you may include the path with the filename) of the image file to be associated with a given multi-page image.
hMIGear HMIGEAR The handle to the allocated multi-page image.
nFormat AT_MODE The format of the file, such as IG_FORMAT_UNKNOWN or IG_FORMAT_TIF. See the accucnst.h file for a list of all available IG_FORMAT_... constants.
nOpenMode AT_MODE An AT_MODE constant, such as IG_MP_OPENMODE_READONLY or IG_MP_OPENMODE_READWRITE.

Return Value:

Returns the number of ImageGear errors that occurred during this function call. If there are no errors, the return value is IGE_SUCCESS.

Supported Raster Image Formats:

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

Sample:

MFC Multipage

Example:

 
Copy Code
HMIGEAR  hMIGear;    /* handle to multi-page image */
AT_ERRCOUNT             nErrCount = IGE_SUCCESS; /* will hold returned error count */
nErrCount = IG_mpi_create( &hMIGear, 0 );
if (!nErrCount)
nErrCount = IG_mpi_file_open( "picture1.tif", hMIGear, 0, IG_MP_OPENMODE_READWRITE );
...
nErrCount = IG_mpi_delete( hMIGear );

Remarks:

After the association is made, you can then use different page manipulation functions, such as page load, save, delete, and swap. With this association operation, ImageGear allows you to store internal data, allowing you to make page operations faster than if using IG_fltr_... functions. This file can be opened with two modes - IG_MP_OPENMODE_READONLY and IG_MP_OPENMODE_READWRITE.

The first mode, read-only access, it is used only when page loading is necessary. It does not allow you to change the external file. When the image is opened with read only access, it sets the number of pages in the multi-page image equal to the number of pages in the external file using IG_mpi_page_count_set() function.

The second mode opens file for read-write access and allows all possible page operations with the external file. The multi-page image is not changed.

Not all filters support all page manipulation operations. Use the function IG_fltr_info_get(), which returns the information about all supported features of a particular filter.

IG_MP_OPENMODE_NONE is also accepted as a value for nOpenMode and, in this case, this call is equivalent to the IG_mpi_close() call.

The nFormat parameter is used only if a new image file is to be created and nOpenMode= IG_MP_OPENMODE_READWRITE. In this case, the file of the specified format is created. In all other cases this parameter is ignored.

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