X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgraphics%2Fdevil%2Fdevilloader.cpp;h=cb6a1b6251764a29fd90cc7c0a36c3e509e9a991;hb=88814cd5cde0bddb56d299b2edbc48e8351a4311;hp=88beb04802d47025c2995d886d227d3d6dc3d78d;hpb=21b0c47700f1b570b6129384ce0b96a0c6b48ffd;p=libs%2Fgui.git diff --git a/source/graphics/devil/devilloader.cpp b/source/graphics/devil/devilloader.cpp index 88beb04..cb6a1b6 100644 --- a/source/graphics/devil/devilloader.cpp +++ b/source/graphics/devil/devilloader.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "devilloader.h" @@ -53,6 +54,20 @@ int tell(void *handle) return reinterpret_cast(handle)->tell(); } +std::string error_string(ILenum err) +{ + switch(err) + { + case IL_FORMAT_NOT_SUPPORTED: return "Format not supported"; + case IL_INTERNAL_ERROR: return "DevIL internal error"; + case IL_INVALID_FILE_HEADER: return "Invalid file header"; + case IL_FILE_READ_ERROR: return "File read error"; + case IL_LIB_PNG_ERROR: return "LibPNG error"; + case IL_LIB_JPEG_ERROR: return "LibJPEG error"; + default: return Msp::format("Unknown error (%04X)", err); + } +} + } // namespace @@ -92,7 +107,10 @@ void DevilLoader::load(Image::Data &data) { ilSetRead(0, 0, eof, get, read, seek, tell); ilBindImage(id); - ilLoadF(IL_TYPE_UNKNOWN, &io); + + ilGetError(); + if(!ilLoadF(IL_TYPE_UNKNOWN, &io)) + throw bad_image_data(error_string(ilGetError())); switch(ilGetInteger(IL_IMAGE_FORMAT)) {