Add support for Giflib 5.0

r14.0.x
Francois Andriot 11 years ago committed by Slávek Banko
parent 577f5c814d
commit a433569b63

@ -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

Loading…
Cancel
Save