| FreeImage Documentation - Contents Previous Next Up | 
Advanced save functions
 
 
 Saving bitmaps using the SaveToHandle functions is almost identical to loading bitmap via the LoadFromHandle functions. 
 
 unsigned 
_ReadProc(void *buffer, unsigned s, unsigned c, fi_handle handle) { return fread(buffer, s, c, (FILE *)handle); } unsigned _WriteProc(void *buffer, unsigned s, unsigned c, fi_handle handle){ return fwrite(buffer, s, c, (FILE *)handle); } int _SeekProc(fi_handle handle, long offset, int origin) { return fseek((FILE *)handle, offset, origin); } long _TellProc(fi_handle handle) { return ftell((FILE *)handle); } FreeImageIO io; io.read_proc = _ReadProc; io.write_proc = _WriteProc; io.seek_proc = _SeekProc; io.tell_proc = _TellProc; FILE *file = fopen("test.bmp", "rb"); void *dib = FreeImage_LoadBMPFromHandle(&io, (fi_handle)file); fclose(file); if (dib != NULL) { file = fopen("saved.bmp", "wb"); FreeImage_SavePNGToHandle(dib, &io, (fi_handle)file); fclose(file); } FreeImage_Free(dib); SubsectionsFreeImage_SaveBMPToHandle
 
 
 bool FreeImage_SaveBMPToHandle(void *dib, FreeImageIO *io, fi_handle handle, BMPFlags flags = BMP_DEFAULT); 
 
 Saves the FreeImage DIB to a Windows Bitmap file. The BMP file is always saved in the Windows format. No compression is used. FreeImage_SavePNGToHandle
 
 
 bool FreeImage_SavePNGToHandle(void *dib, FreeImageIO *io, fi_handle handle, PNGFlags flags = PNG_DEFAULT); 
 
 Saves the FreeImage DIB to a PNG file. FreeImage_SavePNMToHandle
 
 
 bool FreeImage_SavePNMToHandle(void *dib, FreeImageIO *io, fi_handle handle, PNMFlags flags = PNM_DEFAULT); 
 
 Saves the FreeImage DIB to a PNM file. PNM is a descriptive name for a collection of ASCII based bitmap types: PBM, PGM and PPM. If the bitmap has a bitdepth of 1, the file is saved as a PBM file. If the bitmap has a bitdepth of 8, the file is saved as a PGM file. If the bitmap has a bitdepth of 24, the file is saved as a PPM file. Other bitdepths are not supported. FreeImage_SaveTIFFToHandle
 
 
 bool FreeImage_SaveTIFFToHandle(void *dib, FreeImageIO *io, fi_handle handle, TIFFFlags flags = TIFF_DEFAULT); 
 
 Saves the FreeImage DIB to a TIFF file. Copyright 2000 Floris van den Berg (freeimage@wxs.nl)  |