ImageGear for C and C++ on Windows v19.10 - Updated
Load and Save Pages in a Multi-Page Document
User Guide > How to Work with... > Common Operations > Manipulating Image Data > Work with Multi-Page Documents (HMIGEAR) > Load and Save Pages in a Multi-Page Document

After the multi-page image is associated with an external file, it is possible to perform operations such as page loads, saves, swaps, and deletes. If open mode is read-only, then only the page load is allowed. All others will trigger an error.

Use the function IG_mpf_page_load() to load pages from an external file into a multi-page image. The second argument of the function is a zero-based index of the first page for loading. The third argument specifies the number of pages to load starting from this index. The order and location of the loaded pages in the page array is the same as in the external file. Therefore, if the file pages start from nFirstIndex, then it loads into the page array starting with nFirstIndex. If necessary, the page arrays are expanded to fit all of the requested number of pages. If, while loading, some elements of the page array contains a valid HIGEAR image, then it is not deleted. It is then assigned a new value of the image loaded from the file.

Use the function IG_mpf_page_save() to save pages from a multi-page image into an external file. The second and third arguments are the same and have the same meaning as the second and third arguments for the load function. The fourth argument specifies the compression method (for example, IG_COMPRESSION_JPEG or IG_COMPRESSION_LZW for a TIFF image) and applies to all pages from the given range. The last parameter of this function specifies how to save the pages into a file. There are two modes are possible:

The first mode inserts pages into the file at the location specified by the second parameter, which is demonstrated in the following picture:

IG_MPF_SAVE_INSERT:

The second mode replaces pages starting from the index specified by the second parameter:

IG_MPF_SAVE_REPLACE: