diff options
author | Francois Andriot <francois.andriot@free.fr> | 2013-08-25 20:05:22 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2013-08-25 20:05:22 +0200 |
commit | a433569b6366235c35c6d908190e1bf3de20acf5 (patch) | |
tree | 0bb95e23e730101d2e11d330ba5932ab286489f6 /kernel | |
parent | 577f5c814d1ffc2b9c130d65096ffbdc98364208 (diff) | |
download | libksquirrel-a433569b6366235c35c6d908190e1bf3de20acf5.tar.gz libksquirrel-a433569b6366235c35c6d908190e1bf3de20acf5.zip |
Add support for Giflib 5.0
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/kls_gif/fmt_codec_gif.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/kernel/kls_gif/fmt_codec_gif.cpp b/kernel/kls_gif/fmt_codec_gif.cpp index fbdd818..a4981bf 100644 --- a/kernel/kls_gif/fmt_codec_gif.cpp +++ b/kernel/kls_gif/fmt_codec_gif.cpp @@ -43,14 +43,26 @@ extern "C" { /* libgif 4.2.0 has retired PrintGifError() and added GifErrorString() */ #if defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && \ ((GIFLIB_MAJOR == 4 && GIFLIB_MINOR >= 2) || GIFLIB_MAJOR > 4) +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4 +static void PrintGifError(int ErrorCode) +#else static void PrintGifError(void) +#endif { +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4 + char *Err = GifErrorString(ErrorCode); +#else char *Err = GifErrorString(); +#endif if (Err != NULL) { fprintf(stderr, "\nGIF-LIB error: %s.\n", Err); } else { +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4 + fprintf(stderr, "\nGIF-LIB undefined error %d.\n", ErrorCode); +#else fprintf(stderr, "\nGIF-LIB undefined error %d.\n", GifError()); +#endif } } #endif @@ -107,7 +119,12 @@ s32 fmt_codec::read_init(const std::string &file) buf = 0; saved = 0; +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4 + int ErrorCode; + gif = DGifOpenFileName(file.c_str(), &ErrorCode); +#else gif = DGifOpenFileName(file.c_str()); +#endif // for safety... if(!gif) @@ -198,7 +215,11 @@ s32 fmt_codec::read_next() { if (DGifGetRecordType(gif, &record) == GIF_ERROR) { +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4 + PrintGifError(gif->Error); +#else PrintGifError(); +#endif return SQE_R_BADFILE; } @@ -207,7 +228,11 @@ s32 fmt_codec::read_next() case IMAGE_DESC_RECORD_TYPE: if(DGifGetImageDesc(gif) == GIF_ERROR) { +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4 + PrintGifError(gif->Error); +#else PrintGifError(); +#endif return SQE_R_BADFILE; } @@ -243,7 +268,11 @@ s32 fmt_codec::read_next() case EXTENSION_RECORD_TYPE: if(DGifGetExtension(gif, &ExtCode, &Extension) == GIF_ERROR) { +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4 + PrintGifError(gif->Error); +#else PrintGifError(); +#endif return SQE_R_BADFILE; } @@ -287,7 +316,11 @@ s32 fmt_codec::read_next() { if(DGifGetExtensionNext(gif, &Extension) == GIF_ERROR) { +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4 + PrintGifError(gif->Error); +#else PrintGifError(); +#endif return SQE_R_BADFILE; } } @@ -366,7 +399,11 @@ s32 fmt_codec::read_scanline(RGBA *scan) { if(DGifGetLine(gif, buf, Width) == GIF_ERROR) { +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4 + PrintGifError(gif->Error); +#else PrintGifError(); +#endif memset(scan, 255, im->w * sizeof(RGBA)); return SQE_R_BADFILE; } @@ -439,7 +476,11 @@ s32 fmt_codec::read_scanline(RGBA *scan) if(DGifGetLine(gif, buf, Width) == GIF_ERROR) { memset(scan, 255, im->w * sizeof(RGBA)); +#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4 + PrintGifError(gif->Error); +#else PrintGifError(); +#endif return SQE_R_BADFILE; } else |