ImageGear Professional v18.1 > User Guide > Using ImageGear > Loading and Saving Images > Saving Images > Using Format Filters API for Image Saving |
The ImageGear filters API provides three saving functions that make your application much faster and more flexible when working with image saving:
This function works similarly to the IG_save_file() function, but has additional arguments that provide additional functionality when saving the image in a multi-page file. The nPageNumberargument allows you to specify the number of the page in an already existing multi-page file where you want the saved page to be placed. The last argument bOverwrite allows you to determine the mode of how to work with multi-page image files. The TRUE value completely overwrites the file and places a single page there, but a FALSE value means that the existing file will be expanded with one additional page specified by the nPageNumber parameter.
IG_fltr_compressionlist_get(LPAT_DIB lpDIB, AT_MODE nFormatID, LPAT_MODE lpComprList, UINT nCListSize, LPUINT lpnCListCount)
This function allows you to get information about all compressions (as IG_COMPRESSION_constants returned in lpComprListlist) that are available when saving the image to the file format specified by the nFormatID(as IG_FORMAT_constant) parameters. The first parameter allows you to specify information about the image to be saved. If this parameter is NULL, then the function returns all available compressions, otherwise it returns compressions that are applicable to a given image. For example, G3/4 compressions are only applicable for bi-tonal images, but JPEG compression is only applicable for color images with 8 bits or more per pixel.
You can process the IG_fltr_compressionlist_get() and/or IG_fltr_savelist_get() functions before using IG_fltr_save_file() to determine the file format and compression type you specified in the lFormatType argument (as IG_SAVE_ constant, see accucnst.h file).
The function IG_fltr_save_mem() allows you to save a HIGEAR image to memory. The result is a file image in memory that is identical to the file that would have resulted if you had used any other save function (such as IG_fltr_save_file()). However, instead of using a filename to call IG_save_mem(), you specify the address and size of the memory area to which to save. The allocation of memory is discussed further below.
If there already is a valid image file at the address you specify in an IG_fltr_save_mem() call, the effect is the same as when using IG_fltr_save_file() to save to an existing file. Specifically, it allows appending or inserting pages into an existing file stored in memory.
Before you call IG_fltr_save_mem(), you need to allocate a memory buffer, and you must supply the size of the allocated buffer to the function. You can determine the appropriate buffer size by making a call to IG_fltr_save_mem_size_calc(). The size returned by this function will include the size of the bitmap data, which can be a portion of the image (the image rectangle) or the whole image, plus any other structures, such as the header or palette. If you are going to add a page to an existing image in the memory buffer, pass the address of the buffer to IG_fltr_save_mem_size_calc(). The function will calculate and return the size necessary for storing the image after the addition of the page.
You can use these steps to save a multi-page file in a memory buffer:
This process can be optimized. For example, you can allocate (size of first saved page) * (number of pages) bytes in the first place to reduce the number of reallocations.
IG_fltr_save_mem() will return the actual size that the file required when it was saved to memory.
Saving to a Disk File Using a File Descriptor Handle