freeimage.h
FreeImage_FIFSupportsWriting
DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsWriting(FREE_IMAGE_FORMAT fif);
Devuelve TRUE si el plugin perteneciente al FREE_IMAGE_FORMAT dado puede ser usado para guardar mapas de bits, y FALSE en caso contrario.
/** Generic image writer
@param dib Pointer to the dib to be saved
@param lpszPathName Pointer to the full file name
@param flag Optional save flag constant
@return Returns true if successful, returns false otherwise
*/
bool GenericWriter(FIBITMAP* dib, const char* lpszPathName, int flag) {
FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
BOOL bSuccess = FALSE;
// Try to guess the file format from the file extension
fif = FreeImage_GetFIFFromFilename(lpszPathName);
if(fif != FIF_UNKNOWN ) {
// Check that the dib can be saved in this format
BOOL bCanSave;
FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(dib);
if(image_type == FIT_BITMAP) {
// standard bitmap type
// check that the plugin has sufficient writing
// and export capabilities ...
WORD bpp = FreeImage_GetBPP(dib);
bCanSave = (FreeImage_FIFSupportsWriting(fif) &&
FreeImage_FIFSupportsExportBPP(fif, bpp));
} else {
// special bitmap type
// check that the plugin has sufficient export capabilities
bCanSave = FreeImage_FIFSupportsExportType(fif, image_type);
}
if(bCanSave) {
bSuccess = FreeImage_Save(fif, dib, lpszPathName, flag);
}
}
return (bSuccess == TRUE) ? true : false;
}