/** FreeImage error handler @param fif Format / Plugin responsible for the error @param message Error message */ void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) { std::cerr << "\n*** "; if (fif != FIF_UNKNOWN) { std::cerr << FreeImage_GetFormatFromFIF(fif) << " Format\n"; } std::cerr << message << " ***\n"; }
/** 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"; } } }
void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) { if (! RTEST(ruby_debug)) return; rb_raise(rb_eRuntimeError, "FreeImage exception for type %s: %s", (fif == FIF_UNKNOWN) ? "???" : FreeImage_GetFormatFromFIF(fif), message); }
/** FreeImage error handler @param fif Format / Plugin responsible for the error @param message Error message */ void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) { printf("\n*** "); if(fif != FIF_UNKNOWN) { printf("%s Format\n", FreeImage_GetFormatFromFIF(fif)); } printf(message); printf(" ***\n"); }
static void outputMessage(FREE_IMAGE_FORMAT fif, const char *message) { qWarning() << "FreeImage Output"; if (fif != FIF_UNKNOWN) qWarning() << "In Format" << FreeImage_GetFormatFromFIF(fif); qWarning() << message; }
void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) { if(FreeImageLogger) { if(fif != FIF_UNKNOWN) FreeImageLogger->Log("FreeImage Error (%s): %s",FreeImage_GetFormatFromFIF(fif),message); else FreeImageLogger->Log("FreeImage Error (Generic): %s",message); } };
/* FreeImageErrorHandler * Allows to catch FreeImage errors and log them to the console. *******************************************************************/ void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char* message) { string error = "FreeImage: "; if (fif != FIF_UNKNOWN) { error += S_FMT("[%s] ", FreeImage_GetFormatFromFIF(fif)); } error += message; LOG_MESSAGE(2, error); }
// Display an error message if FreeImage fails for some reason void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) { char errmsg[1024]; if(fif != FIF_UNKNOWN) { sprintf_s(errmsg, 1024, "FreeImage: %s Format, %s", FreeImage_GetFormatFromFIF(fif), message); } else { sprintf_s(errmsg, 1024, "FreeImage: %s", message); } MessageBox(NULL, errmsg, "USARSim Image Server", MB_OK); }
TextureHandle const& TextureLibrary::loadTexture(const std::string& imageFile) { TextureHandle texHandle; if (mLoadedTextures.count(imageFile) > 0) { ++mLoadedTextures[imageFile].count; return mLoadedTextures[imageFile]; } // Load image data FREE_IMAGE_FORMAT format = FreeImage_GetFileType(imageFile.c_str()); FIBITMAP* bitmap = FreeImage_Load(format, imageFile.c_str()); if (bitmap) { bitmap = FreeImage_ConvertTo32Bits(bitmap); glGenTextures(1, &texHandle.handle); glBindTexture(GL_TEXTURE_2D, texHandle.handle); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, FreeImage_GetWidth(bitmap), FreeImage_GetHeight(bitmap), 0, GL_BGRA, GL_UNSIGNED_BYTE, bitmap->data); glGenerateMipmap(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, 0); FreeImage_Unload(bitmap); texHandle.name = imageFile; texHandle.count = 1; mLoadedTextures[imageFile] = texHandle; } else { const char* formatStr = FreeImage_GetFormatFromFIF(format); Log::LogStream& stream = Log::error << "Failed to read file '" << imageFile << "'"; if (formatStr) { stream << " of type " << formatStr << '\n'; } else { stream << '\n'; } } return mLoadedTextures[imageFile]; }
//--------------------------------------------------------------------- void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) { // Callback method as required by FreeImage to report problems StringUtil::StrStreamType str; str << "FreeImage error: '" << message << "'"; const char* typeName = FreeImage_GetFormatFromFIF(fif); if (typeName) { str << " when loading format " << typeName; } LogManager::getSingleton().logMessage(str.str()); }
//--------------------------------------------------------------------- void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) { // Callback method as required by FreeImage to report problems const char* typeName = FreeImage_GetFormatFromFIF(fif); if (typeName) { LogManager::getSingleton().stream() << "FreeImage error: '" << message << "' when loading format " << typeName; } else { LogManager::getSingleton().stream() << "FreeImage error: '" << message << "'"; } }
//--------------------------------------------------------------------- String FreeImageCodec::magicNumberToFileExt(const char *magicNumberPtr, size_t maxbytes) const { FIMEMORY* fiMem = FreeImage_OpenMemory((BYTE*)magicNumberPtr, static_cast<DWORD>(maxbytes)); FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(fiMem, (int)maxbytes); FreeImage_CloseMemory(fiMem); if (fif != FIF_UNKNOWN) { String ext(FreeImage_GetFormatFromFIF(fif)); StringUtil::toLowerCase(ext); return ext; } else { return StringUtil::BLANK; } }
/** 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"; } } } }