/** Print plugins export capabilities */ void PrintExportFormats(iostream& ios) { int count = FreeImage_GetFIFCount(); if(count) ios << "FORMAT;DESCRIPTION;EXTENSIONS;BITDEPTH;ICC PROFILES\n"; for(int i = 0; i < count; i++) { FREE_IMAGE_FORMAT fif = (FREE_IMAGE_FORMAT)i; if(FreeImage_FIFSupportsWriting(fif)) { const char * format = FreeImage_GetFormatFromFIF(fif); const char * description = FreeImage_GetFIFDescription(fif); const char * ext = FreeImage_GetFIFExtensionList(fif); const char * icc = "*"; ios << format << ";" << description << ";" << ext << ";"; if(FreeImage_FIFSupportsExportBPP(fif, 1)) ios << "1 "; if(FreeImage_FIFSupportsExportBPP(fif, 4)) ios << "4 "; if(FreeImage_FIFSupportsExportBPP(fif, 8)) ios << "8 "; if(FreeImage_FIFSupportsExportBPP(fif, 16)) ios << "16 "; if(FreeImage_FIFSupportsExportBPP(fif, 24)) ios << "24 "; if(FreeImage_FIFSupportsExportBPP(fif, 32)) ios << "32 "; if(FreeImage_FIFSupportsICCProfiles(fif)) { ios << ";" << icc; } else { ios << "; "; } ios << "\n"; } } }
FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeFromHandle(FreeImageIO *io, fi_handle handle, int size) { if (handle != NULL) { int fif_count = FreeImage_GetFIFCount(); for (int i = 0; i < fif_count; ++i) if (FreeImage_Validate((FREE_IMAGE_FORMAT)i, io, handle)) return (FREE_IMAGE_FORMAT)i; } return FIF_UNKNOWN; }
//--------------------------------------------------------------------- void FreeImageCodec::startup(void) { FreeImage_Initialise(false); LogManager::getSingleton().logMessage( LML_NORMAL, "FreeImage version: " + String(FreeImage_GetVersion())); LogManager::getSingleton().logMessage( LML_NORMAL, FreeImage_GetCopyrightMessage()); // Register codecs StringUtil::StrStreamType strExt; strExt << "Supported formats: "; bool first = true; for (int i = 0; i < FreeImage_GetFIFCount(); ++i) { // Skip DDS codec since FreeImage does not have the option // to keep DXT data compressed, we'll use our own codec if ((FREE_IMAGE_FORMAT)i == FIF_DDS) continue; String exts(FreeImage_GetFIFExtensionList((FREE_IMAGE_FORMAT)i)); if (!first) { strExt << ","; } first = false; strExt << exts; // Pull off individual formats (separated by comma by FI) StringVector extsVector = StringUtil::split(exts, ","); for (StringVector::iterator v = extsVector.begin(); v != extsVector.end(); ++v) { ImageCodec* codec = OGRE_NEW FreeImageCodec(*v, i); msCodecList.push_back(codec); Codec::registerCodec(codec); } } LogManager::getSingleton().logMessage( LML_NORMAL, strExt.str()); // Set error handler FreeImage_SetOutputMessage(FreeImageErrorHandler); }
const QVector<QPair<QStringList, QString> > &ImageLoaderFreeImage::imageFormats() const { static QVector<QPair<QStringList, QString> > formats; if (formats.empty()) { const int pluginsCount = FreeImage_GetFIFCount(); for (int pluginIndex = 0; pluginIndex < pluginsCount; pluginIndex++) { const FREE_IMAGE_FORMAT fif = (FREE_IMAGE_FORMAT)pluginIndex; if (FreeImage_FIFSupportsReading(fif)) { const QString pluginExtensions(QLatin1String(FreeImage_GetFIFExtensionList(fif))); const QString pluginDescription(QLatin1String(FreeImage_GetFIFDescription(fif))); formats.append(QPair<QStringList, QString> (pluginExtensions.split(QLatin1Char(',')), pluginDescription)); } } } return formats; }
void FreeImageLoader::initialize() { for(int i=0;i<FreeImage_GetFIFCount();++i){ FREE_IMAGE_FORMAT fft=(FREE_IMAGE_FORMAT)i; if(fft==FIF_PGMRAW || fft==FIF_PPMRAW || fft==FIF_PBMRAW) continue; core::string ext=core::StringConverter::toString(FreeImage_GetFIFExtensionList(fft)); std::vector<core::string> stringVec; stringVec=core::StringUtil::Split(ext,mT(",")); for(int j=0;j<stringVec.size();j++){ FreeImageLoader* loader=new FreeImageLoader(stringVec[j],(FREE_IMAGE_FORMAT)i); gTextureResourceManager.addTextureLoader(loader); } } }
/** Print plugins import capabilities */ void PrintImportFormats(iostream& ios) { int count = FreeImage_GetFIFCount(); if(count) ios << "FORMAT;DESCRIPTION;EXTENSIONS;ICC PROFILES\n"; for(int i = 0; i < count; i++) { FREE_IMAGE_FORMAT fif = (FREE_IMAGE_FORMAT)i; if(FreeImage_FIFSupportsReading(fif)) { const char * format = FreeImage_GetFormatFromFIF(fif); const char * description = FreeImage_GetFIFDescription(fif); const char * ext = FreeImage_GetFIFExtensionList(fif); const char * icc = "*"; if(FreeImage_FIFSupportsICCProfiles(fif)) { ios << format << ";" << description << ";" << ext << ";" << icc << "\n"; } else { ios << format << ";" << description << ";" << ext << "; \n"; } } } }
FREE_IMAGE_FORMAT DLL_CALLCONV FreeImage_GetFileTypeFromHandle(FreeImageIO *io, fi_handle handle, int size) { if (handle != NULL) { int fif_count = FreeImage_GetFIFCount(); for (int i = 0; i < fif_count; ++i) { FREE_IMAGE_FORMAT fif = (FREE_IMAGE_FORMAT)i; if (FreeImage_Validate(fif, io, handle)) { if(fif == FIF_TIFF) { // many camera raw files use a TIFF signature ... // ... try to revalidate against FIF_RAW (even if it breaks the code genericity) if (FreeImage_Validate(FIF_RAW, io, handle)) { return FIF_RAW; } } return fif; } } } return FIF_UNKNOWN; }
FreeImageImageCodec::FreeImageImageCodec() : ImageCodec("FreeImageCodec - FreeImage based image codec") { FreeImage_Initialise(true); FreeImage_SetOutputMessage(&FreeImageErrorHandler); // Getting extensions for (int i = 0; i < FreeImage_GetFIFCount(); ++i) { String exts(FreeImage_GetFIFExtensionList((FREE_IMAGE_FORMAT)i)); // Replace commas with spaces for (size_t i = 0; i < exts.length(); ++i) if (exts[i] == ',') exts[i] = ' '; // Add space after existing extensions if (!d_supportedFormat.empty()) d_supportedFormat += ' '; d_supportedFormat += exts; } }
/* * Returns: number */ static int lfi_getFIFCount (lua_State *L) { lua_pushinteger(L, FreeImage_GetFIFCount()); return 1; }