From 5bdb7691051b464a6ff801d145f542240f13b15d Mon Sep 17 00:00:00 2001 From: Cezary Statkiewicz Date: Tue, 30 Sep 2014 20:12:18 +0200 Subject: [PATCH] #21 conditionally use QuantizeBuffer, not available in giflib 4.2 --- gif.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gif.c b/gif.c index 2130ce2..28e8e55 100644 --- a/gif.c +++ b/gif.c @@ -17,12 +17,18 @@ #define INLINE static inline + +// QuantizeBuffer has been removed from giflib 4.2 +// in http://sourceforge.net/p/giflib/code/ci/ce02f85e6ed1e1455a4aea9ffa68a3e2b8f8a4b1/ +#if !defined(GIFLIB_MAJOR) || (GIFLIB_MAJOR == 4 && GIFLIB_MINOR < 2) + #define GifQuantizeBuffer QuantizeBuffer +#endif + #if !defined(GIFLIB_MAJOR) || GIFLIB_MAJOR < 5 #define EGifOpen(x, y, z) EGifOpen(x, y) #define EGifCloseFile(x, y) EGifCloseFile(x) #define GifMakeMapObject MakeMapObject #define GifFreeMapObject FreeMapObject - #define GifQuantizeBuffer QuantizeBuffer #define GIF_BEGIN_APP_EXTENSION(f) EGifPutExtensionFirst(f, APPLICATION_EXT_FUNC_CODE, strlen(GIF_APP), GIF_APP) #define GIF_END_APP_EXTENSION(f, m) EGifPutExtensionLast(f, APPLICATION_EXT_FUNC_CODE, sizeof(m), m) #else @@ -318,6 +324,8 @@ gif_encode(Image *image, int single, int *size) ColorMapObject *palette = GifMakeMapObject(NCOLORS, NULL); int palette_size = NCOLORS; + +#if !defined(GIFLIB_MAJOR) || (GIFLIB_MAJOR == 4 && GIFLIB_MINOR < 2) // Quantize again using giflib, since it yields a palette which produces // better compression, reducing the file size by 20%. Note that this second // quantization is very fast, because the image already has 256 colors, so @@ -327,7 +335,7 @@ gif_encode(Image *image, int single, int *size) gif_frames_free(frames, count); return NULL; } - +# endif frames[0].data = malloc(total); memcpy(frames[0].data, output, total); frames[0].width = width;