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() */ /* libgif 4.2.0 has retired PrintGifError() and added GifErrorString() */
#if defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && \ #if defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && \
((GIFLIB_MAJOR == 4 && GIFLIB_MINOR >= 2) || GIFLIB_MAJOR > 4) ((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) static void PrintGifError(void)
#endif
{ {
#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4
char *Err = GifErrorString(ErrorCode);
#else
char *Err = GifErrorString(); char *Err = GifErrorString();
#endif
if (Err != NULL) { if (Err != NULL) {
fprintf(stderr, "\nGIF-LIB error: %s.\n", Err); fprintf(stderr, "\nGIF-LIB error: %s.\n", Err);
} else { } 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()); fprintf(stderr, "\nGIF-LIB undefined error %d.\n", GifError());
#endif
} }
} }
#endif #endif
@ -107,7 +119,12 @@ s32 fmt_codec::read_init(const std::string &file)
buf = 0; buf = 0;
saved = 0; saved = 0;
#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4
int ErrorCode;
gif = DGifOpenFileName(file.c_str(), &ErrorCode);
#else
gif = DGifOpenFileName(file.c_str()); gif = DGifOpenFileName(file.c_str());
#endif
// for safety... // for safety...
if(!gif) if(!gif)
@ -198,7 +215,11 @@ s32 fmt_codec::read_next()
{ {
if (DGifGetRecordType(gif, &record) == GIF_ERROR) if (DGifGetRecordType(gif, &record) == GIF_ERROR)
{ {
#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4
PrintGifError(gif->Error);
#else
PrintGifError(); PrintGifError();
#endif
return SQE_R_BADFILE; return SQE_R_BADFILE;
} }
@ -207,7 +228,11 @@ s32 fmt_codec::read_next()
case IMAGE_DESC_RECORD_TYPE: case IMAGE_DESC_RECORD_TYPE:
if(DGifGetImageDesc(gif) == GIF_ERROR) if(DGifGetImageDesc(gif) == GIF_ERROR)
{ {
#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4
PrintGifError(gif->Error);
#else
PrintGifError(); PrintGifError();
#endif
return SQE_R_BADFILE; return SQE_R_BADFILE;
} }
@ -243,7 +268,11 @@ s32 fmt_codec::read_next()
case EXTENSION_RECORD_TYPE: case EXTENSION_RECORD_TYPE:
if(DGifGetExtension(gif, &ExtCode, &Extension) == GIF_ERROR) if(DGifGetExtension(gif, &ExtCode, &Extension) == GIF_ERROR)
{ {
#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4
PrintGifError(gif->Error);
#else
PrintGifError(); PrintGifError();
#endif
return SQE_R_BADFILE; return SQE_R_BADFILE;
} }
@ -287,7 +316,11 @@ s32 fmt_codec::read_next()
{ {
if(DGifGetExtensionNext(gif, &Extension) == GIF_ERROR) if(DGifGetExtensionNext(gif, &Extension) == GIF_ERROR)
{ {
#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4
PrintGifError(gif->Error);
#else
PrintGifError(); PrintGifError();
#endif
return SQE_R_BADFILE; return SQE_R_BADFILE;
} }
} }
@ -366,7 +399,11 @@ s32 fmt_codec::read_scanline(RGBA *scan)
{ {
if(DGifGetLine(gif, buf, Width) == GIF_ERROR) if(DGifGetLine(gif, buf, Width) == GIF_ERROR)
{ {
#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4
PrintGifError(gif->Error);
#else
PrintGifError(); PrintGifError();
#endif
memset(scan, 255, im->w * sizeof(RGBA)); memset(scan, 255, im->w * sizeof(RGBA));
return SQE_R_BADFILE; return SQE_R_BADFILE;
} }
@ -439,7 +476,11 @@ s32 fmt_codec::read_scanline(RGBA *scan)
if(DGifGetLine(gif, buf, Width) == GIF_ERROR) if(DGifGetLine(gif, buf, Width) == GIF_ERROR)
{ {
memset(scan, 255, im->w * sizeof(RGBA)); memset(scan, 255, im->w * sizeof(RGBA));
#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR > 4
PrintGifError(gif->Error);
#else
PrintGifError(); PrintGifError();
#endif
return SQE_R_BADFILE; return SQE_R_BADFILE;
} }
else else

Loading…
Cancel
Save