freeimage.h
FreeImage_FIFSupportsExportBPP
1 4 8 16 24 32
DLL_API BOOL DLL_CALLCONV FreeImage_FIFSupportsExportBPP(FREE_IMAGE_FORMAT fif, int bpp);
Retorna TRUE si el plugin perteneciente al FREE_IMAGE_FORMAT dado puede guardar un mapa de bits con la profundidad de bits deseada, FALSE en caso contrario.
/**
Builds a series of string pairs that specify filters you can apply to save a file.
The filter string is to be used by a 'File Save As' dialog box (GetSaveFileName or
CFileDialog).
@param szFilter Input and output parameters. szFilter is an array of char whose length
should be 2048 or more.
@param bpp The bit depth of the image to be saved.
@param image_type The image type to be saved
@return Return the number of supported export formats
*/
int GetSaveAsFilterString(char *szFilter, WORD bpp, FREE_IMAGE_TYPE image_type) {
int i, iCount;
char Filter[2048];
char *token;
szFilter[0] = '\0';
iCount = 0;
// Build a string for each format
for(i = 0; i < FreeImage_GetFIFCount(); i++) {
// Check that the dib can be saved in this format
BOOL bCanSave;
FREE_IMAGE_FORMAT fif = (FREE_IMAGE_FORMAT)i;
if(image_type == FIT_BITMAP) {
// standard bitmap type
bCanSave = (FreeImage_FIFSupportsWriting(fif) &&
FreeImage_FIFSupportsExportBPP(fif, bpp));
} else {
// special bitmap type
bCanSave = FreeImage_FIFSupportsExportType(fif, image_type);
}
if(bCanSave) {
// Handle the special case of PNM files
strcpy(Filter, FreeImage_GetFormatFromFIF((FREE_IMAGE_FORMAT)i));
if((bpp == 1) & & (!strncmp(Filter, "PGM", 3) || !strncmp(Filter, "PPM", 3)))
continue;
if((bpp == 8) & & (!strncmp(Filter, "PBM", 3) || !strncmp(Filter, "PPM", 3)))
continue;
if((bpp == 24) & & (!strncmp(Filter, "PGM", 3) || !strncmp(Filter, "PBM", 3)))
continue;
// Description
sprintf(Filter, "%s (%s)|", FreeImage_GetFIFDescription((FREE_IMAGE_FORMAT)i),
FreeImage_GetFIFExtensionList((FREE_IMAGE_FORMAT)i));
strcat(szFilter, Filter);
// Extension(s)
strcpy(Filter, FreeImage_GetFIFExtensionList((FREE_IMAGE_FORMAT)i));
token = strtok(Filter, ",");
while(token != NULL) {
strcat(szFilter, "*.");
strcat(szFilter, token);
strcat(szFilter, ";");
// get next token
token = strtok(NULL, ",");
}
szFilter[strlen(szFilter)-1] = '|';
iCount++;
}
}
strcat(szFilter, "|");
return iCount;
}