A high-performance general-purpose compute library

- Main Page
- Tutorials
- Release Notes
- Examples

Functions
saveImageMem
ArrayFire Functions | ArrayFire Functions by Category » Input and Output functions » Reading and writing images

## Functions
AFAPI void * | saveImageMem (const array &in, const imageFormat format=AF_FIF_PNG)
| C++ Interface for saving an image to memory.
AFAPI af_err | af_save_image_memory (void **ptr, const af_array in, const af_image_format format)
| C Interface for saving an image to memory using FreeImage.

## Detailed Description

Save an array to memory as an image using FreeImage stream (FIMEMORY).

Supported formats include JPG, PNG, PPM and other formats supported by freeimage

## Function Documentation

## ◆ af_save_image_memory()

AFAPI af_err af_save_image_memory | ( | void ** | ptr,
|  | const af_array | in,
|  | const af_image_format | format )

C Interface for saving an image to memory using FreeImage.

Parameters

  [out] | ptr | is the FIMEMORY pointer created by FreeImage.
  [in] | in | is the arrayfire array to be saved as an image
  [in] | format | is the type of image to create in memory. The enum borrows from the FREE_IMAGE_FORMAT enum of FreeImage. Other values not included in af_image_format but included in FREE_IMAGE_FORMAT can also be passed to this function.

Returns
  AF_SUCCESS if successful.

## ◆ saveImageMem()

AFAPI void * saveImageMem | ( | const array & | in,
|  | const imageFormat | format = AF_FIF_PNG )

C++ Interface for saving an image to memory.

Parameters

  [in] | in | is the arrayfire array to be saved as an image
  [in] | format | is the type of image to create in memory. The enum borrows from the FREE_IMAGE_FORMAT enum of FreeImage. Other values not included in imageFormat but included in FREE_IMAGE_FORMAT can also be passed to this function.

Returns
  a void* pointer which is a type cast of the FreeImage type FIMEMORY* pointer.

Note
  Ensure that deleteImageMem is called on this pointer. Otherwise there will be memory leaks