ImageGear Professional for Linux
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:

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).

Saving Images to Memory

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:

  1. Call IG_fltr_save_mem_size_calc(), specifying the HIGEAR for the first page, and passing NULL to lpImage parameter. This will return the size of the first page, saved to the buffer.
  2. Allocate a memory buffer using the calculated size.
  3. Save first page to the memory buffer, using IG_fltr_save_mem().
  4. Call IG_fltr_save_mem_size_calc(), specifying the HIGEAR for the second page, and passing the pointer to the memory buffer you've allocated, to lpImage parameter. This will return the size of the first and second pages saved to the buffer.
  5. Reallocate memory buffer using the new size.
  6. Save second page.
  7. Continue for the rest of pages.

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.

See Also

Saving Images to a Disk File

Saving to a Disk File Using a File Descriptor Handle

Saving an Image to Memory

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback