Freeimage.h

FreeImage_SaveToHandle

La estructura FreeImageIO descrita también para cargar un mapa de bits desde una entrada arbitraria también puede ser usada para guardar mapas de bits. Una vez más, FreeImage no implementa el modo de guardar el mapa de bits, pero te deja implementar la funcionalidad deseada mediante una estructura FreeImageIO asignando punteros a funciones. FreeImage podrá entonces invocar a tus funciones para escribir, buscar y localizar la posición en el stream.

// this code assumes there is a bitmap loaded and
// present in a variable called ‘bitmap’
FreeImageIO io;
io.read_proc = NULL; // usually not needed for saving
io.write_proc = WriteProc; // pointer to function that calls fwrite
io.seek_proc = SeekProc; // pointer to function that calls fseek
io.tell_proc = TellProc; // pointer to function that calls ftell
FILE *f = fopen(“mybitmap.bmp”, “wb”);
if (FreeImage_SaveToHandle(FIF_BMP, bitmap, &io, (fi_handle)f, 0)) {
    // bitmap successfully saved!
}
fclose(f);
DLL_API BOOL DLL_CALLCONV FreeImage_SaveToHandle(FREE_IMAGE_FORMAT fif, FIBITMAP *dib,
FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0));

Parámetros

fif: Define el tipo de mapa de bits a guardar.

dib: Puntero a mapa de bits.

io: Puntero a una estructura FreeImageIO.

handle: Manipulador de la fuente de origen.

flags: Flags opcionales. (Ver FreeImage_Load).

Valor de retorno

True si el proceso se completó con éxito.