From 8cabfed4b3e9f3b3e7e2d7ccd156dee9743ac7d9 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Sat, 23 Aug 2014 09:20:20 -0700 Subject: [PATCH] Remove GIF format for screen capture export (render). This is to reduce maintenance burden. A GIF representation of a web page can be produced by converting its PNG capture. There are numerous third-party tools which can do the job better (optimized palette, minimized loss, etc). https://github.com/ariya/phantomjs/issues/12480 --- src/gif/config.h | 1 - src/gif/egif_lib.c | 1111 ---------------------------- src/gif/gif.pri | 22 - src/gif/gif_err.c | 120 --- src/gif/gif_hash.c | 160 ---- src/gif/gif_hash.h | 61 -- src/gif/gif_lib.h | 336 --------- src/gif/gif_lib_private.h | 59 -- src/gif/gifalloc.c | 443 ----------- src/gif/gifwriter.cpp | 126 ---- src/gif/gifwriter.h | 38 - src/gif/quantize.c | 330 --------- src/phantomjs.pro | 1 - src/webpage.cpp | 9 - test/webpage-spec-renders/test.gif | Bin 23635 -> 0 bytes test/webpage-spec.js | 8 - third-party.txt | 4 - 17 files changed, 2829 deletions(-) delete mode 100644 src/gif/config.h delete mode 100644 src/gif/egif_lib.c delete mode 100644 src/gif/gif.pri delete mode 100644 src/gif/gif_err.c delete mode 100644 src/gif/gif_hash.c delete mode 100644 src/gif/gif_hash.h delete mode 100644 src/gif/gif_lib.h delete mode 100644 src/gif/gif_lib_private.h delete mode 100644 src/gif/gifalloc.c delete mode 100644 src/gif/gifwriter.cpp delete mode 100644 src/gif/gifwriter.h delete mode 100644 src/gif/quantize.c delete mode 100644 test/webpage-spec-renders/test.gif diff --git a/src/gif/config.h b/src/gif/config.h deleted file mode 100644 index 1049dec0..00000000 --- a/src/gif/config.h +++ /dev/null @@ -1 +0,0 @@ -#define UINT32 uint32_t diff --git a/src/gif/egif_lib.c b/src/gif/egif_lib.c deleted file mode 100644 index ff9f7f6d..00000000 --- a/src/gif/egif_lib.c +++ /dev/null @@ -1,1111 +0,0 @@ -/****************************************************************************** - * "Gif-Lib" - Yet another gif library. - * - * Written by: Gershon Elber Ver 1.1, Aug. 1990 - ****************************************************************************** - * The kernel of the GIF Encoding process can be found here. - ****************************************************************************** - * History: - * 14 Jun 89 - Version 1.0 by Gershon Elber. - * 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names). - * 26 Jun 96 - Version 3.0 by Eric S. Raymond (Full GIF89 support) - *****************************************************************************/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -/* Find a thirty-two bit int type */ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_STDINT_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif -#ifdef HAVE_INTTYPES_H -#include -#endif - -#ifdef __MSDOS__ -#include -#include -#include -#else -#include -#include -#ifdef R6000 - -/* FIXME: What is sys/mode.h? Can we substitute a check for this file rather - * than a check based on machine type? - */ -#include -#endif -#endif /* __MSDOS__ */ - -#ifdef HAVE_IO_H -#include -#endif - -#ifdef HAVE_FCNTL_H -#include -#endif /* HAVE_FCNTL_H */ -#ifdef HAVE_UNISTD_H -#include -#endif /* HAVE_UNISTD_H */ -#include -#include -#include -#include "gif_lib.h" -#include "gif_lib_private.h" - -/* #define DEBUG_NO_PREFIX Dump only compressed data. */ - -/* Masks given codes to BitsPerPixel, to make sure all codes are in range: */ -static GifPixelType CodeMask[] = { - 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff -}; - -static char GifVersionPrefix[GIF_STAMP_LEN + 1] = GIF87_STAMP; - -#define WRITE(_gif,_buf,_len) \ - (((GifFilePrivateType*)_gif->Private)->Write ? \ - ((GifFilePrivateType*)_gif->Private)->Write(_gif,_buf,_len) : \ - fwrite(_buf, 1, _len, ((GifFilePrivateType*)_gif->Private)->File)) - -static int EGifPutWord(int Word, GifFileType * GifFile); -static int EGifSetupCompress(GifFileType * GifFile); -static int EGifCompressLine(GifFileType * GifFile, GifPixelType * Line, - int LineLen); -static int EGifCompressOutput(GifFileType * GifFile, int Code); -static int EGifBufferedOutput(GifFileType * GifFile, GifByteType * Buf, - int c); - -/****************************************************************************** - * Open a new gif file for write, given by its name. If TestExistance then - * if the file exists this routines fails (returns NULL). - * Returns GifFileType pointer dynamically allocated which serves as the gif - * info record. _GifError is cleared if succesfull. - *****************************************************************************/ -GifFileType * -EGifOpenFileName(const char *FileName, - int TestExistance) { - - int FileHandle; - GifFileType *GifFile; - - if (TestExistance) - FileHandle = open(FileName, O_WRONLY | O_CREAT | O_EXCL -#if defined(__MSDOS__) || defined(WINDOWS32) || defined(_OPEN_BINARY) - | O_BINARY -#endif /* __MSDOS__ */ - , S_IREAD | S_IWRITE); - else - FileHandle = open(FileName, O_WRONLY | O_CREAT | O_TRUNC -#if defined(__MSDOS__) || defined(WINDOWS32) || defined(_OPEN_BINARY) - | O_BINARY -#endif /* __MSDOS__ */ - , S_IREAD | S_IWRITE); - - if (FileHandle == -1) { - _GifError = E_GIF_ERR_OPEN_FAILED; - return NULL; - } - GifFile = EGifOpenFileHandle(FileHandle); - if (GifFile == (GifFileType *) NULL) - close(FileHandle); - return GifFile; -} - -/****************************************************************************** - * Update a new gif file, given its file handle, which must be opened for - * write in binary mode. - * Returns GifFileType pointer dynamically allocated which serves as the gif - * info record. _GifError is cleared if succesfull. - *****************************************************************************/ -GifFileType * -EGifOpenFileHandle(int FileHandle) { - - GifFileType *GifFile; - GifFilePrivateType *Private; - FILE *f; - - GifFile = (GifFileType *) malloc(sizeof(GifFileType)); - if (GifFile == NULL) { - _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; - return NULL; - } - - memset(GifFile, '\0', sizeof(GifFileType)); - - Private = (GifFilePrivateType *)malloc(sizeof(GifFilePrivateType)); - if (Private == NULL) { - free(GifFile); - _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; - return NULL; - } - if ((Private->HashTable = _InitHashTable()) == NULL) { - free(GifFile); - free(Private); - _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; - return NULL; - } - -#if defined(__MSDOS__) || defined(WINDOWS32) || defined(_OPEN_BINARY) - setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */ -#endif /* __MSDOS__ */ - - f = fdopen(FileHandle, "wb"); /* Make it into a stream: */ - -#if defined (__MSDOS__) || defined(WINDOWS32) - setvbuf(f, NULL, _IOFBF, GIF_FILE_BUFFER_SIZE); /* And inc. stream - * buffer. */ -#endif /* __MSDOS__ */ - - GifFile->Private = (VoidPtr)Private; - Private->FileHandle = FileHandle; - Private->File = f; - Private->FileState = FILE_STATE_WRITE; - - Private->Write = (OutputFunc) 0; /* No user write routine (MRB) */ - GifFile->UserData = (VoidPtr) 0; /* No user write handle (MRB) */ - - _GifError = 0; - - return GifFile; -} - -/****************************************************************************** - * Output constructor that takes user supplied output function. - * Basically just a copy of EGifOpenFileHandle. (MRB) - *****************************************************************************/ -GifFileType * -EGifOpen(void *userData, - OutputFunc writeFunc) { - - GifFileType *GifFile; - GifFilePrivateType *Private; - - GifFile = (GifFileType *)malloc(sizeof(GifFileType)); - if (GifFile == NULL) { - _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; - return NULL; - } - - memset(GifFile, '\0', sizeof(GifFileType)); - - Private = (GifFilePrivateType *)malloc(sizeof(GifFilePrivateType)); - if (Private == NULL) { - free(GifFile); - _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; - return NULL; - } - - Private->HashTable = _InitHashTable(); - if (Private->HashTable == NULL) { - free (GifFile); - free (Private); - _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; - return NULL; - } - - GifFile->Private = (VoidPtr) Private; - Private->FileHandle = 0; - Private->File = (FILE *) 0; - Private->FileState = FILE_STATE_WRITE; - - Private->Write = writeFunc; /* User write routine (MRB) */ - GifFile->UserData = userData; /* User write handle (MRB) */ - - _GifError = 0; - - return GifFile; -} - -/****************************************************************************** - * Routine to set current GIF version. All files open for write will be - * using this version until next call to this routine. Version consists of - * 3 characters as "87a" or "89a". No test is made to validate the version. - *****************************************************************************/ -void -EGifSetGifVersion(const char *Version) { - strncpy(GifVersionPrefix + GIF_VERSION_POS, Version, 3); -} - -/****************************************************************************** - * This routine should be called before any other EGif calls, immediately - * follows the GIF file openning. - *****************************************************************************/ -int -EGifPutScreenDesc(GifFileType * GifFile, - int Width, - int Height, - int ColorRes, - int BackGround, - const ColorMapObject * ColorMap) { - - int i; - GifByteType Buf[3]; - GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; - - if (Private->FileState & FILE_STATE_SCREEN) { - /* If already has screen descriptor - something is wrong! */ - _GifError = E_GIF_ERR_HAS_SCRN_DSCR; - return GIF_ERROR; - } - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - -/* First write the version prefix into the file. */ -#ifndef DEBUG_NO_PREFIX - if (WRITE(GifFile, (unsigned char *)GifVersionPrefix, - strlen(GifVersionPrefix)) != strlen(GifVersionPrefix)) { - _GifError = E_GIF_ERR_WRITE_FAILED; - return GIF_ERROR; - } -#endif /* DEBUG_NO_PREFIX */ - - GifFile->SWidth = Width; - GifFile->SHeight = Height; - GifFile->SColorResolution = ColorRes; - GifFile->SBackGroundColor = BackGround; - if (ColorMap) { - GifFile->SColorMap = MakeMapObject(ColorMap->ColorCount, - ColorMap->Colors); - if (GifFile->SColorMap == NULL) { - _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; - return GIF_ERROR; - } - } else - GifFile->SColorMap = NULL; - - /* - * Put the logical screen descriptor into the file: - */ - /* Logical Screen Descriptor: Dimensions */ - EGifPutWord(Width, GifFile); - EGifPutWord(Height, GifFile); - - /* Logical Screen Descriptor: Packed Fields */ - /* Note: We have actual size of the color table default to the largest - * possible size (7+1 == 8 bits) because the decoder can use it to decide - * how to display the files. - */ - Buf[0] = (ColorMap ? 0x80 : 0x00) | /* Yes/no global colormap */ - ((ColorRes - 1) << 4) | /* Bits allocated to each primary color */ - (ColorMap ? ColorMap->BitsPerPixel - 1 : 0x07 ); /* Actual size of the - color table. */ - Buf[1] = BackGround; /* Index into the ColorTable for background color */ - Buf[2] = 0; /* Pixel Aspect Ratio */ -#ifndef DEBUG_NO_PREFIX - WRITE(GifFile, Buf, 3); -#endif /* DEBUG_NO_PREFIX */ - - /* If we have Global color map - dump it also: */ -#ifndef DEBUG_NO_PREFIX - if (ColorMap != NULL) - for (i = 0; i < ColorMap->ColorCount; i++) { - /* Put the ColorMap out also: */ - Buf[0] = ColorMap->Colors[i].Red; - Buf[1] = ColorMap->Colors[i].Green; - Buf[2] = ColorMap->Colors[i].Blue; - if (WRITE(GifFile, Buf, 3) != 3) { - _GifError = E_GIF_ERR_WRITE_FAILED; - return GIF_ERROR; - } - } -#endif /* DEBUG_NO_PREFIX */ - - /* Mark this file as has screen descriptor, and no pixel written yet: */ - Private->FileState |= FILE_STATE_SCREEN; - - return GIF_OK; -} - -/****************************************************************************** - * This routine should be called before any attempt to dump an image - any - * call to any of the pixel dump routines. - *****************************************************************************/ -int -EGifPutImageDesc(GifFileType * GifFile, - int Left, - int Top, - int Width, - int Height, - int Interlace, - const ColorMapObject * ColorMap) { - - int i; - GifByteType Buf[3]; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (Private->FileState & FILE_STATE_IMAGE && -#if defined(__MSDOS__) || defined(WINDOWS32) || defined(__GNUC__) - Private->PixelCount > 0xffff0000UL) { -#else - Private->PixelCount > 0xffff0000) { -#endif /* __MSDOS__ */ - /* If already has active image descriptor - something is wrong! */ - _GifError = E_GIF_ERR_HAS_IMAG_DSCR; - return GIF_ERROR; - } - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - GifFile->Image.Left = Left; - GifFile->Image.Top = Top; - GifFile->Image.Width = Width; - GifFile->Image.Height = Height; - GifFile->Image.Interlace = Interlace; - if (ColorMap) { - GifFile->Image.ColorMap = MakeMapObject(ColorMap->ColorCount, - ColorMap->Colors); - if (GifFile->Image.ColorMap == NULL) { - _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; - return GIF_ERROR; - } - } else { - GifFile->Image.ColorMap = NULL; - } - - /* Put the image descriptor into the file: */ - Buf[0] = ','; /* Image seperator character. */ -#ifndef DEBUG_NO_PREFIX - WRITE(GifFile, Buf, 1); -#endif /* DEBUG_NO_PREFIX */ - EGifPutWord(Left, GifFile); - EGifPutWord(Top, GifFile); - EGifPutWord(Width, GifFile); - EGifPutWord(Height, GifFile); - Buf[0] = (ColorMap ? 0x80 : 0x00) | - (Interlace ? 0x40 : 0x00) | - (ColorMap ? ColorMap->BitsPerPixel - 1 : 0); -#ifndef DEBUG_NO_PREFIX - WRITE(GifFile, Buf, 1); -#endif /* DEBUG_NO_PREFIX */ - - /* If we have Global color map - dump it also: */ -#ifndef DEBUG_NO_PREFIX - if (ColorMap != NULL) - for (i = 0; i < ColorMap->ColorCount; i++) { - /* Put the ColorMap out also: */ - Buf[0] = ColorMap->Colors[i].Red; - Buf[1] = ColorMap->Colors[i].Green; - Buf[2] = ColorMap->Colors[i].Blue; - if (WRITE(GifFile, Buf, 3) != 3) { - _GifError = E_GIF_ERR_WRITE_FAILED; - return GIF_ERROR; - } - } -#endif /* DEBUG_NO_PREFIX */ - if (GifFile->SColorMap == NULL && GifFile->Image.ColorMap == NULL) { - _GifError = E_GIF_ERR_NO_COLOR_MAP; - return GIF_ERROR; - } - - /* Mark this file as has screen descriptor: */ - Private->FileState |= FILE_STATE_IMAGE; - Private->PixelCount = (long)Width *(long)Height; - - EGifSetupCompress(GifFile); /* Reset compress algorithm parameters. */ - - return GIF_OK; -} - -/****************************************************************************** - * Put one full scanned line (Line) of length LineLen into GIF file. - *****************************************************************************/ -int -EGifPutLine(GifFileType * GifFile, - GifPixelType * Line, - int LineLen) { - - int i; - GifPixelType Mask; - GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; - - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - - if (!LineLen) - LineLen = GifFile->Image.Width; - if (Private->PixelCount < (unsigned)LineLen) { - _GifError = E_GIF_ERR_DATA_TOO_BIG; - return GIF_ERROR; - } - Private->PixelCount -= LineLen; - - /* Make sure the codes are not out of bit range, as we might generate - * wrong code (because of overflow when we combine them) in this case: */ - Mask = CodeMask[Private->BitsPerPixel]; - for (i = 0; i < LineLen; i++) - Line[i] &= Mask; - - return EGifCompressLine(GifFile, Line, LineLen); -} - -/****************************************************************************** - * Put one pixel (Pixel) into GIF file. - *****************************************************************************/ -int -EGifPutPixel(GifFileType * GifFile, - GifPixelType Pixel) { - - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - - if (Private->PixelCount == 0) { - _GifError = E_GIF_ERR_DATA_TOO_BIG; - return GIF_ERROR; - } - --Private->PixelCount; - - /* Make sure the code is not out of bit range, as we might generate - * wrong code (because of overflow when we combine them) in this case: */ - Pixel &= CodeMask[Private->BitsPerPixel]; - - return EGifCompressLine(GifFile, &Pixel, 1); -} - -/****************************************************************************** - * Put a comment into GIF file using the GIF89 comment extension block. - *****************************************************************************/ -int -EGifPutComment(GifFileType * GifFile, - const char *Comment) { - - unsigned int length = strlen(Comment); - char *buf; - - length = strlen(Comment); - if (length <= 255) { - return EGifPutExtension(GifFile, COMMENT_EXT_FUNC_CODE, - length, Comment); - } else { - buf = (char *)Comment; - if (EGifPutExtensionFirst(GifFile, COMMENT_EXT_FUNC_CODE, 255, buf) - == GIF_ERROR) { - return GIF_ERROR; - } - length -= 255; - buf = buf + 255; - - /* Break the comment into 255 byte sub blocks */ - while (length > 255) { - if (EGifPutExtensionNext(GifFile, 0, 255, buf) == GIF_ERROR) { - return GIF_ERROR; - } - buf = buf + 255; - length -= 255; - } - /* Output any partial block and the clear code. */ - if (length > 0) { - if (EGifPutExtensionLast(GifFile, 0, length, buf) == GIF_ERROR) { - return GIF_ERROR; - } - } else { - if (EGifPutExtensionLast(GifFile, 0, 0, NULL) == GIF_ERROR) { - return GIF_ERROR; - } - } - } - return GIF_OK; -} - -/****************************************************************************** - * Put a first extension block (see GIF manual) into gif file. Here more - * extensions can be dumped using EGifPutExtensionNext until - * EGifPutExtensionLast is invoked. - *****************************************************************************/ -int -EGifPutExtensionFirst(GifFileType * GifFile, - int ExtCode, - int ExtLen, - const VoidPtr Extension) { - - GifByteType Buf[3]; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - - if (ExtCode == 0) { - WRITE(GifFile, (GifByteType *)&ExtLen, 1); - } else { - Buf[0] = '!'; - Buf[1] = ExtCode; - Buf[2] = ExtLen; - WRITE(GifFile, Buf, 3); - } - - WRITE(GifFile, Extension, ExtLen); - - return GIF_OK; -} - -/****************************************************************************** - * Put a middle extension block (see GIF manual) into gif file. - *****************************************************************************/ -int -EGifPutExtensionNext(GifFileType * GifFile, - int ExtCode, - int ExtLen, - const VoidPtr Extension) { - - GifByteType Buf; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - - Buf = ExtLen; - WRITE(GifFile, &Buf, 1); - WRITE(GifFile, Extension, ExtLen); - - return GIF_OK; -} - -/****************************************************************************** - * Put a last extension block (see GIF manual) into gif file. - *****************************************************************************/ -int -EGifPutExtensionLast(GifFileType * GifFile, - int ExtCode, - int ExtLen, - const VoidPtr Extension) { - - GifByteType Buf; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - - /* If we are given an extension sub-block output it now. */ - if (ExtLen > 0) { - Buf = ExtLen; - WRITE(GifFile, &Buf, 1); - WRITE(GifFile, Extension, ExtLen); - } - - /* Write the block terminator */ - Buf = 0; - WRITE(GifFile, &Buf, 1); - - return GIF_OK; -} - -/****************************************************************************** - * Put an extension block (see GIF manual) into gif file. - * Warning: This function is only useful for Extension blocks that have at - * most one subblock. Extensions with more than one subblock need to use the - * EGifPutExtension{First,Next,Last} functions instead. - *****************************************************************************/ -int -EGifPutExtension(GifFileType * GifFile, - int ExtCode, - int ExtLen, - const VoidPtr Extension) { - - GifByteType Buf[3]; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - - if (ExtCode == 0) - WRITE(GifFile, (GifByteType *)&ExtLen, 1); - else { - Buf[0] = '!'; /* Extension Introducer 0x21 */ - Buf[1] = ExtCode; /* Extension Label */ - Buf[2] = ExtLen; /* Extension length */ - WRITE(GifFile, Buf, 3); - } - WRITE(GifFile, Extension, ExtLen); - Buf[0] = 0; - WRITE(GifFile, Buf, 1); - - return GIF_OK; -} - -/****************************************************************************** - * Put the image code in compressed form. This routine can be called if the - * information needed to be piped out as is. Obviously this is much faster - * than decoding and encoding again. This routine should be followed by calls - * to EGifPutCodeNext, until NULL block is given. - * The block should NOT be freed by the user (not dynamically allocated). - *****************************************************************************/ -int -EGifPutCode(GifFileType * GifFile, - int CodeSize, - const GifByteType * CodeBlock) { - - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - - /* No need to dump code size as Compression set up does any for us: */ - /* - * Buf = CodeSize; - * if (WRITE(GifFile, &Buf, 1) != 1) { - * _GifError = E_GIF_ERR_WRITE_FAILED; - * return GIF_ERROR; - * } - */ - - return EGifPutCodeNext(GifFile, CodeBlock); -} - -/****************************************************************************** - * Continue to put the image code in compressed form. This routine should be - * called with blocks of code as read via DGifGetCode/DGifGetCodeNext. If - * given buffer pointer is NULL, empty block is written to mark end of code. - *****************************************************************************/ -int -EGifPutCodeNext(GifFileType * GifFile, - const GifByteType * CodeBlock) { - - GifByteType Buf; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (CodeBlock != NULL) { - if (WRITE(GifFile, CodeBlock, CodeBlock[0] + 1) - != (unsigned)(CodeBlock[0] + 1)) { - _GifError = E_GIF_ERR_WRITE_FAILED; - return GIF_ERROR; - } - } else { - Buf = 0; - if (WRITE(GifFile, &Buf, 1) != 1) { - _GifError = E_GIF_ERR_WRITE_FAILED; - return GIF_ERROR; - } - Private->PixelCount = 0; /* And local info. indicate image read. */ - } - - return GIF_OK; -} - -/****************************************************************************** - * This routine should be called last, to close GIF file. - *****************************************************************************/ -int -EGifCloseFile(GifFileType * GifFile) { - - GifByteType Buf; - GifFilePrivateType *Private; - FILE *File; - - if (GifFile == NULL) - return GIF_ERROR; - - Private = (GifFilePrivateType *) GifFile->Private; - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - - File = Private->File; - - Buf = ';'; - WRITE(GifFile, &Buf, 1); - - if (GifFile->Image.ColorMap) { - FreeMapObject(GifFile->Image.ColorMap); - GifFile->Image.ColorMap = NULL; - } - if (GifFile->SColorMap) { - FreeMapObject(GifFile->SColorMap); - GifFile->SColorMap = NULL; - } - if (Private) { - if (Private->HashTable) { - free((char *) Private->HashTable); - } - free((char *) Private); - } - free(GifFile); - - if (File && fclose(File) != 0) { - _GifError = E_GIF_ERR_CLOSE_FAILED; - return GIF_ERROR; - } - return GIF_OK; -} - -/****************************************************************************** - * Put 2 bytes (word) into the given file: - *****************************************************************************/ -static int -EGifPutWord(int Word, - GifFileType * GifFile) { - - unsigned char c[2]; - - c[0] = Word & 0xff; - c[1] = (Word >> 8) & 0xff; -#ifndef DEBUG_NO_PREFIX - if (WRITE(GifFile, c, 2) == 2) - return GIF_OK; - else - return GIF_ERROR; -#else - return GIF_OK; -#endif /* DEBUG_NO_PREFIX */ -} - -/****************************************************************************** - * Setup the LZ compression for this image: - *****************************************************************************/ -static int -EGifSetupCompress(GifFileType * GifFile) { - - int BitsPerPixel; - GifByteType Buf; - GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; - - /* Test and see what color map to use, and from it # bits per pixel: */ - if (GifFile->Image.ColorMap) - BitsPerPixel = GifFile->Image.ColorMap->BitsPerPixel; - else if (GifFile->SColorMap) - BitsPerPixel = GifFile->SColorMap->BitsPerPixel; - else { - _GifError = E_GIF_ERR_NO_COLOR_MAP; - return GIF_ERROR; - } - - Buf = BitsPerPixel = (BitsPerPixel < 2 ? 2 : BitsPerPixel); - WRITE(GifFile, &Buf, 1); /* Write the Code size to file. */ - - Private->Buf[0] = 0; /* Nothing was output yet. */ - Private->BitsPerPixel = BitsPerPixel; - Private->ClearCode = (1 << BitsPerPixel); - Private->EOFCode = Private->ClearCode + 1; - Private->RunningCode = Private->EOFCode + 1; - Private->RunningBits = BitsPerPixel + 1; /* Number of bits per code. */ - Private->MaxCode1 = 1 << Private->RunningBits; /* Max. code + 1. */ - Private->CrntCode = FIRST_CODE; /* Signal that this is first one! */ - Private->CrntShiftState = 0; /* No information in CrntShiftDWord. */ - Private->CrntShiftDWord = 0; - - /* Clear hash table and send Clear to make sure the decoder do the same. */ - _ClearHashTable(Private->HashTable); - - if (EGifCompressOutput(GifFile, Private->ClearCode) == GIF_ERROR) { - _GifError = E_GIF_ERR_DISK_IS_FULL; - return GIF_ERROR; - } - return GIF_OK; -} - -/****************************************************************************** - * The LZ compression routine: - * This version compresses the given buffer Line of length LineLen. - * This routine can be called a few times (one per scan line, for example), in - * order to complete the whole image. -******************************************************************************/ -static int -EGifCompressLine(GifFileType * GifFile, - GifPixelType * Line, - int LineLen) { - - int i = 0, CrntCode, NewCode; - unsigned long NewKey; - GifPixelType Pixel; - GifHashTableType *HashTable; - GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; - - HashTable = Private->HashTable; - - if (Private->CrntCode == FIRST_CODE) /* Its first time! */ - CrntCode = Line[i++]; - else - CrntCode = Private->CrntCode; /* Get last code in compression. */ - - while (i < LineLen) { /* Decode LineLen items. */ - Pixel = Line[i++]; /* Get next pixel from stream. */ - /* Form a new unique key to search hash table for the code combines - * CrntCode as Prefix string with Pixel as postfix char. - */ - NewKey = (((UINT32) CrntCode) << 8) + Pixel; - if ((NewCode = _ExistsHashTable(HashTable, NewKey)) >= 0) { - /* This Key is already there, or the string is old one, so - * simple take new code as our CrntCode: - */ - CrntCode = NewCode; - } else { - /* Put it in hash table, output the prefix code, and make our - * CrntCode equal to Pixel. - */ - if (EGifCompressOutput(GifFile, CrntCode) == GIF_ERROR) { - _GifError = E_GIF_ERR_DISK_IS_FULL; - return GIF_ERROR; - } - CrntCode = Pixel; - - /* If however the HashTable if full, we send a clear first and - * Clear the hash table. - */ - if (Private->RunningCode >= LZ_MAX_CODE) { - /* Time to do some clearance: */ - if (EGifCompressOutput(GifFile, Private->ClearCode) - == GIF_ERROR) { - _GifError = E_GIF_ERR_DISK_IS_FULL; - return GIF_ERROR; - } - Private->RunningCode = Private->EOFCode + 1; - Private->RunningBits = Private->BitsPerPixel + 1; - Private->MaxCode1 = 1 << Private->RunningBits; - _ClearHashTable(HashTable); - } else { - /* Put this unique key with its relative Code in hash table: */ - _InsertHashTable(HashTable, NewKey, Private->RunningCode++); - } - } - - } - - /* Preserve the current state of the compression algorithm: */ - Private->CrntCode = CrntCode; - - if (Private->PixelCount == 0) { - /* We are done - output last Code and flush output buffers: */ - if (EGifCompressOutput(GifFile, CrntCode) == GIF_ERROR) { - _GifError = E_GIF_ERR_DISK_IS_FULL; - return GIF_ERROR; - } - if (EGifCompressOutput(GifFile, Private->EOFCode) == GIF_ERROR) { - _GifError = E_GIF_ERR_DISK_IS_FULL; - return GIF_ERROR; - } - if (EGifCompressOutput(GifFile, FLUSH_OUTPUT) == GIF_ERROR) { - _GifError = E_GIF_ERR_DISK_IS_FULL; - return GIF_ERROR; - } - } - - return GIF_OK; -} - -/****************************************************************************** - * The LZ compression output routine: - * This routine is responsible for the compression of the bit stream into - * 8 bits (bytes) packets. - * Returns GIF_OK if written succesfully. - *****************************************************************************/ -static int -EGifCompressOutput(GifFileType * GifFile, - int Code) { - - GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; - int retval = GIF_OK; - - if (Code == FLUSH_OUTPUT) { - while (Private->CrntShiftState > 0) { - /* Get Rid of what is left in DWord, and flush it. */ - if (EGifBufferedOutput(GifFile, Private->Buf, - Private->CrntShiftDWord & 0xff) == GIF_ERROR) - retval = GIF_ERROR; - Private->CrntShiftDWord >>= 8; - Private->CrntShiftState -= 8; - } - Private->CrntShiftState = 0; /* For next time. */ - if (EGifBufferedOutput(GifFile, Private->Buf, - FLUSH_OUTPUT) == GIF_ERROR) - retval = GIF_ERROR; - } else { - Private->CrntShiftDWord |= ((long)Code) << Private->CrntShiftState; - Private->CrntShiftState += Private->RunningBits; - while (Private->CrntShiftState >= 8) { - /* Dump out full bytes: */ - if (EGifBufferedOutput(GifFile, Private->Buf, - Private->CrntShiftDWord & 0xff) == GIF_ERROR) - retval = GIF_ERROR; - Private->CrntShiftDWord >>= 8; - Private->CrntShiftState -= 8; - } - } - - /* If code cannt fit into RunningBits bits, must raise its size. Note */ - /* however that codes above 4095 are used for special signaling. */ - if (Private->RunningCode >= Private->MaxCode1 && Code <= 4095) { - Private->MaxCode1 = 1 << ++Private->RunningBits; - } - - return retval; -} - -/****************************************************************************** - * This routines buffers the given characters until 255 characters are ready - * to be output. If Code is equal to -1 the buffer is flushed (EOF). - * The buffer is Dumped with first byte as its size, as GIF format requires. - * Returns GIF_OK if written succesfully. - *****************************************************************************/ -static int -EGifBufferedOutput(GifFileType * GifFile, - GifByteType * Buf, - int c) { - - if (c == FLUSH_OUTPUT) { - /* Flush everything out. */ - if (Buf[0] != 0 - && WRITE(GifFile, Buf, Buf[0] + 1) != (unsigned)(Buf[0] + 1)) { - _GifError = E_GIF_ERR_WRITE_FAILED; - return GIF_ERROR; - } - /* Mark end of compressed data, by an empty block (see GIF doc): */ - Buf[0] = 0; - if (WRITE(GifFile, Buf, 1) != 1) { - _GifError = E_GIF_ERR_WRITE_FAILED; - return GIF_ERROR; - } - } else { - if (Buf[0] == 255) { - /* Dump out this buffer - it is full: */ - if (WRITE(GifFile, Buf, Buf[0] + 1) != (unsigned)(Buf[0] + 1)) { - _GifError = E_GIF_ERR_WRITE_FAILED; - return GIF_ERROR; - } - Buf[0] = 0; - } - Buf[++Buf[0]] = c; - } - - return GIF_OK; -} - -/****************************************************************************** - * This routine writes to disk an in-core representation of a GIF previously - * created by DGifSlurp(). - *****************************************************************************/ -int -EGifSpew(GifFileType * GifFileOut) { - - int i, j, gif89 = FALSE; - int bOff; /* Block Offset for adding sub blocks in Extensions */ - char SavedStamp[GIF_STAMP_LEN + 1]; - - for (i = 0; i < GifFileOut->ImageCount; i++) { - for (j = 0; j < GifFileOut->SavedImages[i].ExtensionBlockCount; j++) { - int function = - GifFileOut->SavedImages[i].ExtensionBlocks[j].Function; - - if (function == COMMENT_EXT_FUNC_CODE - || function == GRAPHICS_EXT_FUNC_CODE - || function == PLAINTEXT_EXT_FUNC_CODE - || function == APPLICATION_EXT_FUNC_CODE) - gif89 = TRUE; - } - } - - strncpy(SavedStamp, GifVersionPrefix, GIF_STAMP_LEN); - if (gif89) { - strncpy(GifVersionPrefix, GIF89_STAMP, GIF_STAMP_LEN); - } else { - strncpy(GifVersionPrefix, GIF87_STAMP, GIF_STAMP_LEN); - } - if (EGifPutScreenDesc(GifFileOut, - GifFileOut->SWidth, - GifFileOut->SHeight, - GifFileOut->SColorResolution, - GifFileOut->SBackGroundColor, - GifFileOut->SColorMap) == GIF_ERROR) { - strncpy(GifVersionPrefix, SavedStamp, GIF_STAMP_LEN); - return (GIF_ERROR); - } - strncpy(GifVersionPrefix, SavedStamp, GIF_STAMP_LEN); - - for (i = 0; i < GifFileOut->ImageCount; i++) { - SavedImage *sp = &GifFileOut->SavedImages[i]; - int SavedHeight = sp->ImageDesc.Height; - int SavedWidth = sp->ImageDesc.Width; - ExtensionBlock *ep; - - /* this allows us to delete images by nuking their rasters */ - if (sp->RasterBits == NULL) - continue; - - if (sp->ExtensionBlocks) { - for (j = 0; j < sp->ExtensionBlockCount; j++) { - ep = &sp->ExtensionBlocks[j]; - if (j == sp->ExtensionBlockCount - 1 || (ep+1)->Function != 0) { - /*** FIXME: Must check whether outputting - * is ever valid or if we should just - * drop anything with a 0 for the Function. (And whether - * we should drop here or in EGifPutExtension) - */ - if (EGifPutExtension(GifFileOut, - (ep->Function != 0) ? ep->Function : '\0', - ep->ByteCount, - ep->Bytes) == GIF_ERROR) { - return (GIF_ERROR); - } - } else { - EGifPutExtensionFirst(GifFileOut, ep->Function, ep->ByteCount, ep->Bytes); - for (bOff = j+1; bOff < sp->ExtensionBlockCount; bOff++) { - ep = &sp->ExtensionBlocks[bOff]; - if (ep->Function != 0) { - break; - } - EGifPutExtensionNext(GifFileOut, 0, - ep->ByteCount, ep->Bytes); - } - EGifPutExtensionLast(GifFileOut, 0, 0, NULL); - j = bOff-1; - } - } - } - - if (EGifPutImageDesc(GifFileOut, - sp->ImageDesc.Left, - sp->ImageDesc.Top, - SavedWidth, - SavedHeight, - sp->ImageDesc.Interlace, - sp->ImageDesc.ColorMap) == GIF_ERROR) - return (GIF_ERROR); - - for (j = 0; j < SavedHeight; j++) { - if (EGifPutLine(GifFileOut, - sp->RasterBits + j * SavedWidth, - SavedWidth) == GIF_ERROR) - return (GIF_ERROR); - } - } - - if (EGifCloseFile(GifFileOut) == GIF_ERROR) - return (GIF_ERROR); - - return (GIF_OK); -} diff --git a/src/gif/gif.pri b/src/gif/gif.pri deleted file mode 100644 index e2dd0a87..00000000 --- a/src/gif/gif.pri +++ /dev/null @@ -1,22 +0,0 @@ -VPATH += $$PWD -INCLUDEPATH += $$PWD - -DEFINES += HAVE_CONFIG_H -DEFINES += HAVE_FCNTL_H -DEFINES += HAVE_STDARG_H -!win32-msvc* { - DEFINES += HAVE_STDINT_H - DEFINES += HAVE_UNISTD_H -} - -SOURCES += gif_err.c -SOURCES += gifalloc.c -SOURCES += egif_lib.c -SOURCES += gif_hash.c -SOURCES += quantize.c -SOURCES += gifwriter.cpp - -HEADERS += gif_hash.h -HEADERS += gif_lib_private.h -HEADERS += gif_lib.h -HEADERS += gifwriter.h diff --git a/src/gif/gif_err.c b/src/gif/gif_err.c deleted file mode 100644 index 326727aa..00000000 --- a/src/gif/gif_err.c +++ /dev/null @@ -1,120 +0,0 @@ -/***************************************************************************** - * "Gif-Lib" - Yet another gif library. - * - * Written by: Gershon Elber IBM PC Ver 0.1, Jun. 1989 - ***************************************************************************** - * Handle error reporting for the GIF library. - ***************************************************************************** - * History: - * 17 Jun 89 - Version 1.0 by Gershon Elber. - ****************************************************************************/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include "gif_lib.h" - -int _GifError = 0; - -/***************************************************************************** - * Return the last GIF error (0 if none) and reset the error. - ****************************************************************************/ -int -GifLastError(void) { - int i = _GifError; - - _GifError = 0; - - return i; -} -#ifndef _GBA_NO_FILEIO - -/***************************************************************************** - * Print the last GIF error to stderr. - ****************************************************************************/ -void -PrintGifError(void) { - char *Err; - - switch (_GifError) { - case E_GIF_ERR_OPEN_FAILED: - Err = "Failed to open given file"; - break; - case E_GIF_ERR_WRITE_FAILED: - Err = "Failed to Write to given file"; - break; - case E_GIF_ERR_HAS_SCRN_DSCR: - Err = "Screen Descriptor already been set"; - break; - case E_GIF_ERR_HAS_IMAG_DSCR: - Err = "Image Descriptor is still active"; - break; - case E_GIF_ERR_NO_COLOR_MAP: - Err = "Neither Global Nor Local color map"; - break; - case E_GIF_ERR_DATA_TOO_BIG: - Err = "#Pixels bigger than Width * Height"; - break; - case E_GIF_ERR_NOT_ENOUGH_MEM: - Err = "Fail to allocate required memory"; - break; - case E_GIF_ERR_DISK_IS_FULL: - Err = "Write failed (disk full?)"; - break; - case E_GIF_ERR_CLOSE_FAILED: - Err = "Failed to close given file"; - break; - case E_GIF_ERR_NOT_WRITEABLE: - Err = "Given file was not opened for write"; - break; - case D_GIF_ERR_OPEN_FAILED: - Err = "Failed to open given file"; - break; - case D_GIF_ERR_READ_FAILED: - Err = "Failed to Read from given file"; - break; - case D_GIF_ERR_NOT_GIF_FILE: - Err = "Given file is NOT GIF file"; - break; - case D_GIF_ERR_NO_SCRN_DSCR: - Err = "No Screen Descriptor detected"; - break; - case D_GIF_ERR_NO_IMAG_DSCR: - Err = "No Image Descriptor detected"; - break; - case D_GIF_ERR_NO_COLOR_MAP: - Err = "Neither Global Nor Local color map"; - break; - case D_GIF_ERR_WRONG_RECORD: - Err = "Wrong record type detected"; - break; - case D_GIF_ERR_DATA_TOO_BIG: - Err = "#Pixels bigger than Width * Height"; - break; - case D_GIF_ERR_NOT_ENOUGH_MEM: - Err = "Fail to allocate required memory"; - break; - case D_GIF_ERR_CLOSE_FAILED: - Err = "Failed to close given file"; - break; - case D_GIF_ERR_NOT_READABLE: - Err = "Given file was not opened for read"; - break; - case D_GIF_ERR_IMAGE_DEFECT: - Err = "Image is defective, decoding aborted"; - break; - case D_GIF_ERR_EOF_TOO_SOON: - Err = "Image EOF detected, before image complete"; - break; - default: - Err = NULL; - break; - } - if (Err != NULL) - fprintf(stderr, "\nGIF-LIB error: %s.\n", Err); - else - fprintf(stderr, "\nGIF-LIB undefined error %d.\n", _GifError); -} -#endif /* _GBA_NO_FILEIO */ diff --git a/src/gif/gif_hash.c b/src/gif/gif_hash.c deleted file mode 100644 index 2591e366..00000000 --- a/src/gif/gif_hash.c +++ /dev/null @@ -1,160 +0,0 @@ -/***************************************************************************** -* "Gif-Lib" - Yet another gif library. * -* * -* Written by: Gershon Elber IBM PC Ver 0.1, Jun. 1989 * -****************************************************************************** -* Module to support the following operations: * -* * -* 1. InitHashTable - initialize hash table. * -* 2. ClearHashTable - clear the hash table to an empty state. * -* 2. InsertHashTable - insert one item into data structure. * -* 3. ExistsHashTable - test if item exists in data structure. * -* * -* This module is used to hash the GIF codes during encoding. * -****************************************************************************** -* History: * -* 14 Jun 89 - Version 1.0 by Gershon Elber. * -*****************************************************************************/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -/* Find a thirty-two bit int type */ -#ifdef HAVE_STDINT_H -#include -#endif -#ifdef HAVE_INTTYPES_H -#include -#endif -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif - -#ifdef __MSDOS__ -#include -#include -#include -#else -#include -#include -#endif /* __MSDOS__ */ - -#ifdef HAVE_FCNTL_H -#include -#endif /* HAVE_FCNTL_H */ -#include -#include -#include "gif_lib.h" -#include "gif_hash.h" -#include "gif_lib_private.h" - -/* #define DEBUG_HIT_RATE Debug number of misses per hash Insert/Exists. */ - -#ifdef DEBUG_HIT_RATE -static long NumberOfTests = 0, - NumberOfMisses = 0; -#endif /* DEBUG_HIT_RATE */ - -static int KeyItem(UINT32 Item); - -/****************************************************************************** -* Initialize HashTable - allocate the memory needed and clear it. * -******************************************************************************/ -GifHashTableType *_InitHashTable(void) -{ - GifHashTableType *HashTable; - - if ((HashTable = (GifHashTableType *) malloc(sizeof(GifHashTableType))) - == NULL) - return NULL; - - _ClearHashTable(HashTable); - - return HashTable; -} - -/****************************************************************************** -* Routine to clear the HashTable to an empty state. * -* This part is a little machine depended. Use the commented part otherwise. * -******************************************************************************/ -void _ClearHashTable(GifHashTableType *HashTable) -{ - memset(HashTable -> HTable, 0xFF, HT_SIZE * sizeof(UINT32)); -} - -/****************************************************************************** -* Routine to insert a new Item into the HashTable. The data is assumed to be * -* new one. * -******************************************************************************/ -void _InsertHashTable(GifHashTableType *HashTable, UINT32 Key, int Code) -{ - int HKey = KeyItem(Key); - UINT32 *HTable = HashTable -> HTable; - -#ifdef DEBUG_HIT_RATE - NumberOfTests++; - NumberOfMisses++; -#endif /* DEBUG_HIT_RATE */ - - while (HT_GET_KEY(HTable[HKey]) != 0xFFFFFL) { -#ifdef DEBUG_HIT_RATE - NumberOfMisses++; -#endif /* DEBUG_HIT_RATE */ - HKey = (HKey + 1) & HT_KEY_MASK; - } - HTable[HKey] = HT_PUT_KEY(Key) | HT_PUT_CODE(Code); -} - -/****************************************************************************** -* Routine to test if given Key exists in HashTable and if so returns its code * -* Returns the Code if key was found, -1 if not. * -******************************************************************************/ -int _ExistsHashTable(GifHashTableType *HashTable, UINT32 Key) -{ - int HKey = KeyItem(Key); - UINT32 *HTable = HashTable -> HTable, HTKey; - -#ifdef DEBUG_HIT_RATE - NumberOfTests++; - NumberOfMisses++; -#endif /* DEBUG_HIT_RATE */ - - while ((HTKey = HT_GET_KEY(HTable[HKey])) != 0xFFFFFL) { -#ifdef DEBUG_HIT_RATE - NumberOfMisses++; -#endif /* DEBUG_HIT_RATE */ - if (Key == HTKey) return HT_GET_CODE(HTable[HKey]); - HKey = (HKey + 1) & HT_KEY_MASK; - } - - return -1; -} - -/****************************************************************************** -* Routine to generate an HKey for the hashtable out of the given unique key. * -* The given Key is assumed to be 20 bits as follows: lower 8 bits are the * -* new postfix character, while the upper 12 bits are the prefix code. * -* Because the average hit ratio is only 2 (2 hash references per entry), * -* evaluating more complex keys (such as twin prime keys) does not worth it! * -******************************************************************************/ -static int KeyItem(UINT32 Item) -{ - return ((Item >> 12) ^ Item) & HT_KEY_MASK; -} - -#ifdef DEBUG_HIT_RATE -/****************************************************************************** -* Debugging routine to print the hit ratio - number of times the hash table * -* was tested per operation. This routine was used to test the KeyItem routine * -******************************************************************************/ -void HashTablePrintHitRatio(void) -{ - printf("Hash Table Hit Ratio is %ld/%ld = %ld%%.\n", - NumberOfMisses, NumberOfTests, - NumberOfMisses * 100 / NumberOfTests); -} -#endif /* DEBUG_HIT_RATE */ diff --git a/src/gif/gif_hash.h b/src/gif/gif_hash.h deleted file mode 100644 index 3696b47c..00000000 --- a/src/gif/gif_hash.h +++ /dev/null @@ -1,61 +0,0 @@ -/****************************************************************************** -* Declarations, global to other of the GIF-HASH.C module. * -* * -* Written by Gershon Elber, Jun 1989 * -******************************************************************************* -* History: * -* 14 Jun 89 - Version 1.0 by Gershon Elber. * -******************************************************************************/ - -#ifndef _GIF_HASH_H_ -#define _GIF_HASH_H_ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -/* Find a thirty-two bit int type */ -#ifdef HAVE_STDINT_H -#include -#else if defined(Q_CC_MSVC) -typedef unsigned __int32 uint32_t; -#endif -#ifdef HAVE_INTTYPES_H -#include -#endif -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif - -#ifdef HAVE_BASETSD_H -#include -#endif - -#define HT_SIZE 8192 /* 12bits = 4096 or twice as big! */ -#define HT_KEY_MASK 0x1FFF /* 13bits keys */ -#define HT_KEY_NUM_BITS 13 /* 13bits keys */ -#define HT_MAX_KEY 8191 /* 13bits - 1, maximal code possible */ -#define HT_MAX_CODE 4095 /* Biggest code possible in 12 bits. */ - -/* The 32 bits of the long are divided into two parts for the key & code: */ -/* 1. The code is 12 bits as our compression algorithm is limited to 12bits */ -/* 2. The key is 12 bits Prefix code + 8 bit new char or 20 bits. */ -/* The key is the upper 20 bits. The code is the lower 12. */ -#define HT_GET_KEY(l) (l >> 12) -#define HT_GET_CODE(l) (l & 0x0FFF) -#define HT_PUT_KEY(l) (l << 12) -#define HT_PUT_CODE(l) (l & 0x0FFF) - -typedef struct GifHashTableType { - UINT32 HTable[HT_SIZE]; -} GifHashTableType; - -GifHashTableType *_InitHashTable(void); -void _ClearHashTable(GifHashTableType *HashTable); -void _InsertHashTable(GifHashTableType *HashTable, UINT32 Key, int Code); -int _ExistsHashTable(GifHashTableType *HashTable, UINT32 Key); - -#endif /* _GIF_HASH_H_ */ diff --git a/src/gif/gif_lib.h b/src/gif/gif_lib.h deleted file mode 100644 index 54acd91b..00000000 --- a/src/gif/gif_lib.h +++ /dev/null @@ -1,336 +0,0 @@ -/****************************************************************************** - * In order to make life a little bit easier when using the GIF file format, - * this library was written, and which does all the dirty work... - * - * Written by Gershon Elber, Jun. 1989 - * Hacks by Eric S. Raymond, Sep. 1992 - ****************************************************************************** - * History: - * 14 Jun 89 - Version 1.0 by Gershon Elber. - * 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names) - * 15 Sep 90 - Version 2.0 by Eric S. Raymond (Changes to suoport GIF slurp) - * 26 Jun 96 - Version 3.0 by Eric S. Raymond (Full GIF89 support) - * 17 Dec 98 - Version 4.0 by Toshio Kuratomi (Fix extension writing code) - *****************************************************************************/ - -#ifndef _GIF_LIB_H_ -#define _GIF_LIB_H_ 1 - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define GIF_LIB_VERSION " Version 4.1, " - -#define GIF_ERROR 0 -#define GIF_OK 1 - -#ifndef TRUE -#define TRUE 1 -#endif /* TRUE */ -#ifndef FALSE -#define FALSE 0 -#endif /* FALSE */ - -#ifndef NULL -#define NULL 0 -#endif /* NULL */ - -#define GIF_STAMP "GIFVER" /* First chars in file - GIF stamp. */ -#define GIF_STAMP_LEN sizeof(GIF_STAMP) - 1 -#define GIF_VERSION_POS 3 /* Version first character in stamp. */ -#define GIF87_STAMP "GIF87a" /* First chars in file - GIF stamp. */ -#define GIF89_STAMP "GIF89a" /* First chars in file - GIF stamp. */ - -#define GIF_FILE_BUFFER_SIZE 16384 /* Files uses bigger buffers than usual. */ - -typedef int GifBooleanType; -typedef unsigned char GifPixelType; -typedef unsigned char *GifRowType; -typedef unsigned char GifByteType; -#ifdef _GBA_OPTMEM - typedef unsigned short GifPrefixType; - typedef short GifWord; -#else - typedef unsigned int GifPrefixType; - typedef int GifWord; -#endif - -#define GIF_MESSAGE(Msg) fprintf(stderr, "\n%s: %s\n", PROGRAM_NAME, Msg) -#define GIF_EXIT(Msg) { GIF_MESSAGE(Msg); exit(-3); } - -#ifdef SYSV -#define VoidPtr char * -#else -#define VoidPtr void * -#endif /* SYSV */ - -typedef struct GifColorType { - GifByteType Red, Green, Blue; -} GifColorType; - -typedef struct ColorMapObject { - int ColorCount; - int BitsPerPixel; - GifColorType *Colors; /* on malloc(3) heap */ -} ColorMapObject; - -typedef struct GifImageDesc { - GifWord Left, Top, Width, Height, /* Current image dimensions. */ - Interlace; /* Sequential/Interlaced lines. */ - ColorMapObject *ColorMap; /* The local color map */ -} GifImageDesc; - -typedef struct GifFileType { - GifWord SWidth, SHeight, /* Screen dimensions. */ - SColorResolution, /* How many colors can we generate? */ - SBackGroundColor; /* I hope you understand this one... */ - ColorMapObject *SColorMap; /* NULL if not exists. */ - int ImageCount; /* Number of current image */ - GifImageDesc Image; /* Block describing current image */ - struct SavedImage *SavedImages; /* Use this to accumulate file state */ - VoidPtr UserData; /* hook to attach user data (TVT) */ - VoidPtr Private; /* Don't mess with this! */ -} GifFileType; - -typedef enum { - UNDEFINED_RECORD_TYPE, - SCREEN_DESC_RECORD_TYPE, - IMAGE_DESC_RECORD_TYPE, /* Begin with ',' */ - EXTENSION_RECORD_TYPE, /* Begin with '!' */ - TERMINATE_RECORD_TYPE /* Begin with ';' */ -} GifRecordType; - -/* DumpScreen2Gif routine constants identify type of window/screen to dump. - * Note all values below 1000 are reserved for the IBMPC different display - * devices (it has many!) and are compatible with the numbering TC2.0 - * (Turbo C 2.0 compiler for IBM PC) gives to these devices. - */ -typedef enum { - GIF_DUMP_SGI_WINDOW = 1000, - GIF_DUMP_X_WINDOW = 1001 -} GifScreenDumpType; - -/* func type to read gif data from arbitrary sources (TVT) */ -typedef int (*InputFunc) (GifFileType *, GifByteType *, int); - -/* func type to write gif data ro arbitrary targets. - * Returns count of bytes written. (MRB) - */ -typedef int (*OutputFunc) (GifFileType *, const GifByteType *, int); - -/****************************************************************************** - * GIF89 extension function codes -******************************************************************************/ - -#define COMMENT_EXT_FUNC_CODE 0xfe /* comment */ -#define GRAPHICS_EXT_FUNC_CODE 0xf9 /* graphics control */ -#define PLAINTEXT_EXT_FUNC_CODE 0x01 /* plaintext */ -#define APPLICATION_EXT_FUNC_CODE 0xff /* application block */ - -/****************************************************************************** - * O.K., here are the routines one can access in order to encode GIF file: - * (GIF_LIB file EGIF_LIB.C). -******************************************************************************/ - -GifFileType *EGifOpenFileName(const char *GifFileName, - int GifTestExistance); -GifFileType *EGifOpenFileHandle(int GifFileHandle); -GifFileType *EGifOpen(void *userPtr, OutputFunc writeFunc); - -int EGifSpew(GifFileType * GifFile); -void EGifSetGifVersion(const char *Version); -int EGifPutScreenDesc(GifFileType * GifFile, - int GifWidth, int GifHeight, int GifColorRes, - int GifBackGround, - const ColorMapObject * GifColorMap); -int EGifPutImageDesc(GifFileType * GifFile, int GifLeft, int GifTop, - int Width, int GifHeight, int GifInterlace, - const ColorMapObject * GifColorMap); -int EGifPutLine(GifFileType * GifFile, GifPixelType * GifLine, - int GifLineLen); -int EGifPutPixel(GifFileType * GifFile, GifPixelType GifPixel); -int EGifPutComment(GifFileType * GifFile, const char *GifComment); -int EGifPutExtensionFirst(GifFileType * GifFile, int GifExtCode, - int GifExtLen, const VoidPtr GifExtension); -int EGifPutExtensionNext(GifFileType * GifFile, int GifExtCode, - int GifExtLen, const VoidPtr GifExtension); -int EGifPutExtensionLast(GifFileType * GifFile, int GifExtCode, - int GifExtLen, const VoidPtr GifExtension); -int EGifPutExtension(GifFileType * GifFile, int GifExtCode, int GifExtLen, - const VoidPtr GifExtension); -int EGifPutCode(GifFileType * GifFile, int GifCodeSize, - const GifByteType * GifCodeBlock); -int EGifPutCodeNext(GifFileType * GifFile, - const GifByteType * GifCodeBlock); -int EGifCloseFile(GifFileType * GifFile); - -#define E_GIF_ERR_OPEN_FAILED 1 /* And EGif possible errors. */ -#define E_GIF_ERR_WRITE_FAILED 2 -#define E_GIF_ERR_HAS_SCRN_DSCR 3 -#define E_GIF_ERR_HAS_IMAG_DSCR 4 -#define E_GIF_ERR_NO_COLOR_MAP 5 -#define E_GIF_ERR_DATA_TOO_BIG 6 -#define E_GIF_ERR_NOT_ENOUGH_MEM 7 -#define E_GIF_ERR_DISK_IS_FULL 8 -#define E_GIF_ERR_CLOSE_FAILED 9 -#define E_GIF_ERR_NOT_WRITEABLE 10 - -/****************************************************************************** - * O.K., here are the routines one can access in order to decode GIF file: - * (GIF_LIB file DGIF_LIB.C). - *****************************************************************************/ -#ifndef _GBA_NO_FILEIO -GifFileType *DGifOpenFileName(const char *GifFileName); -GifFileType *DGifOpenFileHandle(int GifFileHandle); -int DGifSlurp(GifFileType * GifFile); -#endif /* _GBA_NO_FILEIO */ -GifFileType *DGifOpen(void *userPtr, InputFunc readFunc); /* new one - * (TVT) */ -int DGifGetScreenDesc(GifFileType * GifFile); -int DGifGetRecordType(GifFileType * GifFile, GifRecordType * GifType); -int DGifGetImageDesc(GifFileType * GifFile); -int DGifGetLine(GifFileType * GifFile, GifPixelType * GifLine, int GifLineLen); -int DGifGetPixel(GifFileType * GifFile, GifPixelType GifPixel); -int DGifGetComment(GifFileType * GifFile, char *GifComment); -int DGifGetExtension(GifFileType * GifFile, int *GifExtCode, - GifByteType ** GifExtension); -int DGifGetExtensionNext(GifFileType * GifFile, GifByteType ** GifExtension); -int DGifGetCode(GifFileType * GifFile, int *GifCodeSize, - GifByteType ** GifCodeBlock); -int DGifGetCodeNext(GifFileType * GifFile, GifByteType ** GifCodeBlock); -int DGifGetLZCodes(GifFileType * GifFile, int *GifCode); -int DGifCloseFile(GifFileType * GifFile); - -#define D_GIF_ERR_OPEN_FAILED 101 /* And DGif possible errors. */ -#define D_GIF_ERR_READ_FAILED 102 -#define D_GIF_ERR_NOT_GIF_FILE 103 -#define D_GIF_ERR_NO_SCRN_DSCR 104 -#define D_GIF_ERR_NO_IMAG_DSCR 105 -#define D_GIF_ERR_NO_COLOR_MAP 106 -#define D_GIF_ERR_WRONG_RECORD 107 -#define D_GIF_ERR_DATA_TOO_BIG 108 -#define D_GIF_ERR_NOT_ENOUGH_MEM 109 -#define D_GIF_ERR_CLOSE_FAILED 110 -#define D_GIF_ERR_NOT_READABLE 111 -#define D_GIF_ERR_IMAGE_DEFECT 112 -#define D_GIF_ERR_EOF_TOO_SOON 113 - -/****************************************************************************** - * O.K., here are the routines from GIF_LIB file QUANTIZE.C. -******************************************************************************/ -int QuantizeBuffer(unsigned int Width, unsigned int Height, - int *ColorMapSize, GifByteType * RedInput, - GifByteType * GreenInput, GifByteType * BlueInput, - GifByteType * OutputBuffer, - GifColorType * OutputColorMap); - -/****************************************************************************** - * O.K., here are the routines from GIF_LIB file QPRINTF.C. -******************************************************************************/ -extern int GifQuietPrint; - -#ifdef HAVE_STDARG_H - extern void GifQprintf(char *Format, ...); -#elif defined (HAVE_VARARGS_H) - extern void GifQprintf(); -#endif /* HAVE_STDARG_H */ - -/****************************************************************************** - * O.K., here are the routines from GIF_LIB file GIF_ERR.C. -******************************************************************************/ -#ifndef _GBA_NO_FILEIO -extern void PrintGifError(void); -#endif /* _GBA_NO_FILEIO */ -extern int GifLastError(void); - -/****************************************************************************** - * O.K., here are the routines from GIF_LIB file DEV2GIF.C. -******************************************************************************/ -extern int DumpScreen2Gif(const char *FileName, - int ReqGraphDriver, - long ReqGraphMode1, - long ReqGraphMode2, - long ReqGraphMode3); - -/***************************************************************************** - * - * Everything below this point is new after version 1.2, supporting `slurp - * mode' for doing I/O in two big belts with all the image-bashing in core. - * - *****************************************************************************/ - -/****************************************************************************** - * Color Map handling from ALLOCGIF.C - *****************************************************************************/ - -extern ColorMapObject *MakeMapObject(int ColorCount, - const GifColorType * ColorMap); -extern void FreeMapObject(ColorMapObject * Object); -extern ColorMapObject *UnionColorMap(const ColorMapObject * ColorIn1, - const ColorMapObject * ColorIn2, - GifPixelType ColorTransIn2[]); -extern int BitSize(int n); - -/****************************************************************************** - * Support for the in-core structures allocation (slurp mode). - *****************************************************************************/ - -/* This is the in-core version of an extension record */ -typedef struct { - int ByteCount; - char *Bytes; /* on malloc(3) heap */ - int Function; /* Holds the type of the Extension block. */ -} ExtensionBlock; - -/* This holds an image header, its unpacked raster bits, and extensions */ -typedef struct SavedImage { - GifImageDesc ImageDesc; - unsigned char *RasterBits; /* on malloc(3) heap */ - int Function; /* DEPRECATED: Use ExtensionBlocks[x].Function instead */ - int ExtensionBlockCount; - ExtensionBlock *ExtensionBlocks; /* on malloc(3) heap */ -} SavedImage; - -extern void ApplyTranslation(SavedImage * Image, GifPixelType Translation[]); -extern void MakeExtension(SavedImage * New, int Function); -extern int AddExtensionBlock(SavedImage * New, int Len, - unsigned char ExtData[]); -extern void FreeExtension(SavedImage * Image); -extern SavedImage *MakeSavedImage(GifFileType * GifFile, - const SavedImage * CopyFrom); -extern void FreeSavedImages(GifFileType * GifFile); - -/****************************************************************************** - * The library's internal utility font - *****************************************************************************/ - -#define GIF_FONT_WIDTH 8 -#define GIF_FONT_HEIGHT 8 -extern unsigned char AsciiTable[][GIF_FONT_WIDTH]; - -#ifdef _WIN32 - extern void DrawGifText(SavedImage * Image, -#else - extern void DrawText(SavedImage * Image, -#endif - const int x, const int y, - const char *legend, const int color); - -extern void DrawBox(SavedImage * Image, - const int x, const int y, - const int w, const int d, const int color); - -void DrawRectangle(SavedImage * Image, - const int x, const int y, - const int w, const int d, const int color); - -extern void DrawBoxedText(SavedImage * Image, - const int x, const int y, - const char *legend, - const int border, const int bg, const int fg); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* _GIF_LIB_H */ diff --git a/src/gif/gif_lib_private.h b/src/gif/gif_lib_private.h deleted file mode 100644 index b31c9c5d..00000000 --- a/src/gif/gif_lib_private.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _GIF_LIB_PRIVATE_H -#define _GIF_LIB_PRIVATE_H - -#include "gif_lib.h" -#include "gif_hash.h" - -#define PROGRAM_NAME "GIFLIB" - -#ifdef SYSV -#define VersionStr "Gif library module,\t\tEric S. Raymond\n\ - (C) Copyright 1997 Eric S. Raymond\n" -#else -#define VersionStr PROGRAM_NAME " IBMPC " GIF_LIB_VERSION \ - " Eric S. Raymond, " __DATE__ ", " \ - __TIME__ "\n" "(C) Copyright 1997 Eric S. Raymond\n" -#endif /* SYSV */ - -#define LZ_MAX_CODE 4095 /* Biggest code possible in 12 bits. */ -#define LZ_BITS 12 - -#define FLUSH_OUTPUT 4096 /* Impossible code, to signal flush. */ -#define FIRST_CODE 4097 /* Impossible code, to signal first. */ -#define NO_SUCH_CODE 4098 /* Impossible code, to signal empty. */ - -#define FILE_STATE_WRITE 0x01 -#define FILE_STATE_SCREEN 0x02 -#define FILE_STATE_IMAGE 0x04 -#define FILE_STATE_READ 0x08 - -#define IS_READABLE(Private) (Private->FileState & FILE_STATE_READ) -#define IS_WRITEABLE(Private) (Private->FileState & FILE_STATE_WRITE) - -typedef struct GifFilePrivateType { - GifWord FileState, FileHandle, /* Where all this data goes to! */ - BitsPerPixel, /* Bits per pixel (Codes uses at least this + 1). */ - ClearCode, /* The CLEAR LZ code. */ - EOFCode, /* The EOF LZ code. */ - RunningCode, /* The next code algorithm can generate. */ - RunningBits, /* The number of bits required to represent RunningCode. */ - MaxCode1, /* 1 bigger than max. possible code, in RunningBits bits. */ - LastCode, /* The code before the current code. */ - CrntCode, /* Current algorithm code. */ - StackPtr, /* For character stack (see below). */ - CrntShiftState; /* Number of bits in CrntShiftDWord. */ - unsigned long CrntShiftDWord; /* For bytes decomposition into codes. */ - unsigned long PixelCount; /* Number of pixels in image. */ - FILE *File; /* File as stream. */ - InputFunc Read; /* function to read gif input (TVT) */ - OutputFunc Write; /* function to write gif output (MRB) */ - GifByteType Buf[256]; /* Compressed input is buffered here. */ - GifByteType Stack[LZ_MAX_CODE]; /* Decoded pixels are stacked here. */ - GifByteType Suffix[LZ_MAX_CODE + 1]; /* So we can trace the codes. */ - GifPrefixType Prefix[LZ_MAX_CODE + 1]; - GifHashTableType *HashTable; -} GifFilePrivateType; - -extern int _GifError; - -#endif /* _GIF_LIB_PRIVATE_H */ diff --git a/src/gif/gifalloc.c b/src/gif/gifalloc.c deleted file mode 100644 index 3665aebb..00000000 --- a/src/gif/gifalloc.c +++ /dev/null @@ -1,443 +0,0 @@ -/***************************************************************************** - * "Gif-Lib" - Yet another gif library. - * - * Written by: Gershon Elber Ver 0.1, Jun. 1989 - * Extensively hacked by: Eric S. Raymond Ver 1.?, Sep 1992 - ***************************************************************************** - * GIF construction tools - ***************************************************************************** - * History: - * 15 Sep 92 - Version 1.0 by Eric Raymond. - ****************************************************************************/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include "gif_lib.h" - -#define MAX(x, y) (((x) > (y)) ? (x) : (y)) - -/****************************************************************************** - * Miscellaneous utility functions - *****************************************************************************/ - -/* return smallest bitfield size n will fit in */ -int -BitSize(int n) { - - register int i; - - for (i = 1; i <= 8; i++) - if ((1 << i) >= n) - break; - return (i); -} - -/****************************************************************************** - * Color map object functions - *****************************************************************************/ - -/* - * Allocate a color map of given size; initialize with contents of - * ColorMap if that pointer is non-NULL. - */ -ColorMapObject * -MakeMapObject(int ColorCount, - const GifColorType * ColorMap) { - - ColorMapObject *Object; - - /*** FIXME: Our ColorCount has to be a power of two. Is it necessary to - * make the user know that or should we automatically round up instead? */ - if (ColorCount != (1 << BitSize(ColorCount))) { - return ((ColorMapObject *) NULL); - } - - Object = (ColorMapObject *)malloc(sizeof(ColorMapObject)); - if (Object == (ColorMapObject *) NULL) { - return ((ColorMapObject *) NULL); - } - - Object->Colors = (GifColorType *)calloc(ColorCount, sizeof(GifColorType)); - if (Object->Colors == (GifColorType *) NULL) { - return ((ColorMapObject *) NULL); - } - - Object->ColorCount = ColorCount; - Object->BitsPerPixel = BitSize(ColorCount); - - if (ColorMap) { - memcpy((char *)Object->Colors, - (char *)ColorMap, ColorCount * sizeof(GifColorType)); - } - - return (Object); -} - -/* - * Free a color map object - */ -void -FreeMapObject(ColorMapObject * Object) { - - if (Object != NULL) { - free(Object->Colors); - free(Object); - /*** FIXME: - * When we are willing to break API we need to make this function - * FreeMapObject(ColorMapObject **Object) - * and do this assignment to NULL here: - * *Object = NULL; - */ - } -} - -#ifdef DEBUG -void -DumpColorMap(ColorMapObject * Object, - FILE * fp) { - - if (Object) { - int i, j, Len = Object->ColorCount; - - for (i = 0; i < Len; i += 4) { - for (j = 0; j < 4 && j < Len; j++) { - fprintf(fp, "%3d: %02x %02x %02x ", i + j, - Object->Colors[i + j].Red, - Object->Colors[i + j].Green, - Object->Colors[i + j].Blue); - } - fprintf(fp, "\n"); - } - } -} -#endif /* DEBUG */ - -/* - * Compute the union of two given color maps and return it. If result can't - * fit into 256 colors, NULL is returned, the allocated union otherwise. - * ColorIn1 is copied as is to ColorUnion, while colors from ColorIn2 are - * copied iff they didn't exist before. ColorTransIn2 maps the old - * ColorIn2 into ColorUnion color map table. - */ -ColorMapObject * -UnionColorMap(const ColorMapObject * ColorIn1, - const ColorMapObject * ColorIn2, - GifPixelType ColorTransIn2[]) { - - int i, j, CrntSlot, RoundUpTo, NewBitSize; - ColorMapObject *ColorUnion; - - /* - * Allocate table which will hold the result for sure. - */ - ColorUnion = MakeMapObject(MAX(ColorIn1->ColorCount, - ColorIn2->ColorCount) * 2, NULL); - - if (ColorUnion == NULL) - return (NULL); - - /* Copy ColorIn1 to ColorUnionSize; */ - /*** FIXME: What if there are duplicate entries into the colormap to begin - * with? */ - for (i = 0; i < ColorIn1->ColorCount; i++) - ColorUnion->Colors[i] = ColorIn1->Colors[i]; - CrntSlot = ColorIn1->ColorCount; - - /* - * Potentially obnoxious hack: - * - * Back CrntSlot down past all contiguous {0, 0, 0} slots at the end - * of table 1. This is very useful if your display is limited to - * 16 colors. - */ - while (ColorIn1->Colors[CrntSlot - 1].Red == 0 - && ColorIn1->Colors[CrntSlot - 1].Green == 0 - && ColorIn1->Colors[CrntSlot - 1].Blue == 0) - CrntSlot--; - - /* Copy ColorIn2 to ColorUnionSize (use old colors if they exist): */ - for (i = 0; i < ColorIn2->ColorCount && CrntSlot <= 256; i++) { - /* Let's see if this color already exists: */ - /*** FIXME: Will it ever occur that ColorIn2 will contain duplicate - * entries? So we should search from 0 to CrntSlot rather than - * ColorIn1->ColorCount? - */ - for (j = 0; j < ColorIn1->ColorCount; j++) - if (memcmp (&ColorIn1->Colors[j], &ColorIn2->Colors[i], - sizeof(GifColorType)) == 0) - break; - - if (j < ColorIn1->ColorCount) - ColorTransIn2[i] = j; /* color exists in Color1 */ - else { - /* Color is new - copy it to a new slot: */ - ColorUnion->Colors[CrntSlot] = ColorIn2->Colors[i]; - ColorTransIn2[i] = CrntSlot++; - } - } - - if (CrntSlot > 256) { - FreeMapObject(ColorUnion); - return ((ColorMapObject *) NULL); - } - - NewBitSize = BitSize(CrntSlot); - RoundUpTo = (1 << NewBitSize); - - if (RoundUpTo != ColorUnion->ColorCount) { - register GifColorType *Map = ColorUnion->Colors; - - /* - * Zero out slots up to next power of 2. - * We know these slots exist because of the way ColorUnion's - * start dimension was computed. - */ - for (j = CrntSlot; j < RoundUpTo; j++) - Map[j].Red = Map[j].Green = Map[j].Blue = 0; - - /* perhaps we can shrink the map? */ - if (RoundUpTo < ColorUnion->ColorCount) - ColorUnion->Colors = (GifColorType *)realloc(Map, - sizeof(GifColorType) * RoundUpTo); - } - - ColorUnion->ColorCount = RoundUpTo; - ColorUnion->BitsPerPixel = NewBitSize; - - return (ColorUnion); -} - -/* - * Apply a given color translation to the raster bits of an image - */ -void -ApplyTranslation(SavedImage * Image, - GifPixelType Translation[]) { - - register int i; - register int RasterSize = Image->ImageDesc.Height * Image->ImageDesc.Width; - - for (i = 0; i < RasterSize; i++) - Image->RasterBits[i] = Translation[Image->RasterBits[i]]; -} - -/****************************************************************************** - * Extension record functions - *****************************************************************************/ - -void -MakeExtension(SavedImage * New, - int Function) { - - New->Function = Function; - /*** FIXME: - * Someday we might have to deal with multiple extensions. - * ??? Was this a note from Gershon or from me? Does the multiple - * extension blocks solve this or do we need multiple Functions? Or is - * this an obsolete function? (People should use AddExtensionBlock - * instead?) - * Looks like AddExtensionBlock needs to take the int Function argument - * then it can take the place of this function. Right now people have to - * use both. Fix AddExtensionBlock and add this to the deprecation list. - */ -} - -int -AddExtensionBlock(SavedImage * New, - int Len, - unsigned char ExtData[]) { - - ExtensionBlock *ep; - - if (New->ExtensionBlocks == NULL) - New->ExtensionBlocks=(ExtensionBlock *)malloc(sizeof(ExtensionBlock)); - else - New->ExtensionBlocks = (ExtensionBlock *)realloc(New->ExtensionBlocks, - sizeof(ExtensionBlock) * - (New->ExtensionBlockCount + 1)); - - if (New->ExtensionBlocks == NULL) - return (GIF_ERROR); - - ep = &New->ExtensionBlocks[New->ExtensionBlockCount++]; - - ep->ByteCount=Len; - ep->Bytes = (char *)malloc(ep->ByteCount); - if (ep->Bytes == NULL) - return (GIF_ERROR); - - if (ExtData) { - memcpy(ep->Bytes, ExtData, Len); - ep->Function = New->Function; - } - - return (GIF_OK); -} - -void -FreeExtension(SavedImage * Image) -{ - ExtensionBlock *ep; - - if ((Image == NULL) || (Image->ExtensionBlocks == NULL)) { - return; - } - for (ep = Image->ExtensionBlocks; - ep < (Image->ExtensionBlocks + Image->ExtensionBlockCount); ep++) - (void)free((char *)ep->Bytes); - free((char *)Image->ExtensionBlocks); - Image->ExtensionBlocks = NULL; -} - -/****************************************************************************** - * Image block allocation functions -******************************************************************************/ - -/* Private Function: - * Frees the last image in the GifFile->SavedImages array - */ -void -FreeLastSavedImage(GifFileType *GifFile) { - - SavedImage *sp; - - if ((GifFile == NULL) || (GifFile->SavedImages == NULL)) - return; - - /* Remove one SavedImage from the GifFile */ - GifFile->ImageCount--; - sp = &GifFile->SavedImages[GifFile->ImageCount]; - - /* Deallocate its Colormap */ - if (sp->ImageDesc.ColorMap) { - FreeMapObject(sp->ImageDesc.ColorMap); - sp->ImageDesc.ColorMap = NULL; - } - - /* Deallocate the image data */ - if (sp->RasterBits) - free((char *)sp->RasterBits); - - /* Deallocate any extensions */ - if (sp->ExtensionBlocks) - FreeExtension(sp); - - /*** FIXME: We could realloc the GifFile->SavedImages structure but is - * there a point to it? Saves some memory but we'd have to do it every - * time. If this is used in FreeSavedImages then it would be inefficient - * (The whole array is going to be deallocated.) If we just use it when - * we want to free the last Image it's convenient to do it here. - */ -} - -/* - * Append an image block to the SavedImages array - */ -SavedImage * -MakeSavedImage(GifFileType * GifFile, - const SavedImage * CopyFrom) { - - SavedImage *sp; - - if (GifFile->SavedImages == NULL) - GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage)); - else - GifFile->SavedImages = (SavedImage *)realloc(GifFile->SavedImages, - sizeof(SavedImage) * (GifFile->ImageCount + 1)); - - if (GifFile->SavedImages == NULL) - return ((SavedImage *)NULL); - else { - sp = &GifFile->SavedImages[GifFile->ImageCount++]; - memset((char *)sp, '\0', sizeof(SavedImage)); - - if (CopyFrom) { - memcpy((char *)sp, CopyFrom, sizeof(SavedImage)); - - /* - * Make our own allocated copies of the heap fields in the - * copied record. This guards against potential aliasing - * problems. - */ - - /* first, the local color map */ - if (sp->ImageDesc.ColorMap) { - sp->ImageDesc.ColorMap = MakeMapObject( - CopyFrom->ImageDesc.ColorMap->ColorCount, - CopyFrom->ImageDesc.ColorMap->Colors); - if (sp->ImageDesc.ColorMap == NULL) { - FreeLastSavedImage(GifFile); - return (SavedImage *)(NULL); - } - } - - /* next, the raster */ - sp->RasterBits = (unsigned char *)malloc(sizeof(GifPixelType) * - CopyFrom->ImageDesc.Height * - CopyFrom->ImageDesc.Width); - if (sp->RasterBits == NULL) { - FreeLastSavedImage(GifFile); - return (SavedImage *)(NULL); - } - memcpy(sp->RasterBits, CopyFrom->RasterBits, - sizeof(GifPixelType) * CopyFrom->ImageDesc.Height * - CopyFrom->ImageDesc.Width); - - /* finally, the extension blocks */ - if (sp->ExtensionBlocks) { - sp->ExtensionBlocks = (ExtensionBlock *)malloc( - sizeof(ExtensionBlock) * - CopyFrom->ExtensionBlockCount); - if (sp->ExtensionBlocks == NULL) { - FreeLastSavedImage(GifFile); - return (SavedImage *)(NULL); - } - memcpy(sp->ExtensionBlocks, CopyFrom->ExtensionBlocks, - sizeof(ExtensionBlock) * CopyFrom->ExtensionBlockCount); - - /* - * For the moment, the actual blocks can take their - * chances with free(). We'll fix this later. - *** FIXME: [Better check this out... Toshio] - * 2004 May 27: Looks like this was an ESR note. - * It means the blocks are shallow copied from InFile to - * OutFile. However, I don't see that in this code.... - * Did ESR fix it but never remove this note (And other notes - * in gifspnge?) - */ - } - } - - return (sp); - } -} - -void -FreeSavedImages(GifFileType * GifFile) { - - SavedImage *sp; - - if ((GifFile == NULL) || (GifFile->SavedImages == NULL)) { - return; - } - for (sp = GifFile->SavedImages; - sp < GifFile->SavedImages + GifFile->ImageCount; sp++) { - if (sp->ImageDesc.ColorMap) { - FreeMapObject(sp->ImageDesc.ColorMap); - sp->ImageDesc.ColorMap = NULL; - } - - if (sp->RasterBits) - free((char *)sp->RasterBits); - - if (sp->ExtensionBlocks) - FreeExtension(sp); - } - free((char *)GifFile->SavedImages); - GifFile->SavedImages=NULL; -} diff --git a/src/gif/gifwriter.cpp b/src/gif/gifwriter.cpp deleted file mode 100644 index c0a010ce..00000000 --- a/src/gif/gifwriter.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - This file is part of the PhantomJS project from Ofi Labs. - - Copyright (C) 2011 Ariya Hidayat - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "gifwriter.h" - -#include "gif_lib.h" - -#include -#include - -static int saveGifBlock(GifFileType *gif, const GifByteType *data, int i) -{ - QFile *file = (QFile*)(gif->UserData); - return file->write((const char*)data, i); -} - -bool exportGif(const QImage &img, const QString &fileName) -{ - QFile file; - file.setFileName(fileName); - if (!file.open(QFile::WriteOnly)) { - return false; - } - - QImage image = img; - - int dim = image.width() * image.height(); - GifByteType *rBuffer = new GifByteType[dim]; - GifByteType *gBuffer = new GifByteType[dim]; - GifByteType *bBuffer = new GifByteType[dim]; - for (int i = 0; i < image.width(); ++i) { - for (int j = 0; j < image.height(); ++j) { - QRgb color = image.pixel(i, j); - rBuffer[i + j * image.width()] = qRed(color); - gBuffer[i + j * image.width()] = qGreen(color); - bBuffer[i + j * image.width()] = qBlue(color); - } - } - - int ColorMapSize = 255; - ColorMapObject cmap; - cmap.ColorCount = ColorMapSize; - cmap.BitsPerPixel = 8; - cmap.Colors = new GifColorType[ColorMapSize]; - GifByteType *outputBuffer = new GifByteType[dim]; - QuantizeBuffer(image.width(), image.height(), &ColorMapSize, - rBuffer, gBuffer, bBuffer, outputBuffer, cmap.Colors); - - QVector colorTable; - colorTable.reserve(256); - for (int i = 0; i < ColorMapSize; ++i) { - GifColorType color = cmap.Colors[i]; - colorTable += qRgb(color.Red, color.Green, color.Blue); - } - colorTable += qRgba(0, 0, 0, 0); - while (colorTable.count() < 256) - colorTable += qRgb(0, 0, 0); - - delete [] outputBuffer; - delete [] rBuffer; - delete [] gBuffer; - delete [] bBuffer; - - image = image.convertToFormat(QImage::Format_Indexed8, colorTable); - - colorTable = image.colorTable(); - cmap.ColorCount = 256; - cmap.BitsPerPixel = 8; - int bgcolor = -1; - for (int c = 0; c < 256; ++c) { - cmap.Colors[c].Red = qRed(colorTable[c]); - cmap.Colors[c].Green = qGreen(colorTable[c]); - cmap.Colors[c].Blue = qBlue(colorTable[c]); - if (qAlpha(colorTable[c]) == 0) - bgcolor = c; - } - EGifSetGifVersion("87a"); - - GifFileType *gif = EGifOpen(&file, saveGifBlock); - gif->ImageCount = 1; - EGifPutScreenDesc(gif, image.width(), image.height(), 256, 0, &cmap); - if (bgcolor >= 0) { - char extension[] = { 1, 0, 0, bgcolor }; - EGifPutExtension(gif, GRAPHICS_EXT_FUNC_CODE, 4, extension); - } - EGifPutImageDesc(gif, 0, 0, image.width(), image.height(), 0, &cmap); - - for (int y = 0; y < image.height(); ++y) { - if (EGifPutLine(gif, (GifPixelType*)(image.scanLine(y)), img.width()) == GIF_ERROR) { - break; - } - } - - EGifCloseFile(gif); - file.close(); - - delete [] cmap.Colors; - - return true; -} diff --git a/src/gif/gifwriter.h b/src/gif/gifwriter.h deleted file mode 100644 index f0260f09..00000000 --- a/src/gif/gifwriter.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - This file is part of the PhantomJS project from Ofi Labs. - - Copyright (C) 2011 Ariya Hidayat - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef GIFWRITER_H -#define GIFWRITER_H - -#include -#include - -bool exportGif(const QImage &image, const QString &fileName); - -#endif diff --git a/src/gif/quantize.c b/src/gif/quantize.c deleted file mode 100644 index 7dece307..00000000 --- a/src/gif/quantize.c +++ /dev/null @@ -1,330 +0,0 @@ -/***************************************************************************** - * "Gif-Lib" - Yet another gif library. - * - * Written by: Gershon Elber IBM PC Ver 0.1, Jun. 1989 - ****************************************************************************** - * Module to quatize high resolution image into lower one. You may want to - * peek into the following article this code is based on: - * "Color Image Quantization for frame buffer Display", by Paul Heckbert - * SIGGRAPH 1982 page 297-307. - ****************************************************************************** - * History: - * 5 Jan 90 - Version 1.0 by Gershon Elber. - *****************************************************************************/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef __MSDOS__ -#include -#include -#include -#endif /* __MSDOS__ */ - -#include -#include -#include "gif_lib.h" -#include "gif_lib_private.h" - -#define ABS(x) ((x) > 0 ? (x) : (-(x))) - -/* The colors are stripped to 5 bits per primary color if non MSDOS system - * or to 4 (not enough memory...) if MSDOS as first step. - */ -#ifdef __MSDOS__ -#define COLOR_ARRAY_SIZE 4096 -#define BITS_PER_PRIM_COLOR 4 -#define MAX_PRIM_COLOR 0x0f -#else -#define COLOR_ARRAY_SIZE 2097152 -#define BITS_PER_PRIM_COLOR 7 -#define MAX_PRIM_COLOR 0x7f -#endif /* __MSDOS__ */ - -static int SortRGBAxis; - -typedef struct QuantizedColorType { - GifByteType RGB[3]; - GifByteType NewColorIndex; - long Count; - struct QuantizedColorType *Pnext; -} QuantizedColorType; - -typedef struct NewColorMapType { - GifByteType RGBMin[3], RGBWidth[3]; - unsigned int NumEntries; /* # of QuantizedColorType in linked list below */ - unsigned long Count; /* Total number of pixels in all the entries */ - QuantizedColorType *QuantizedColors; -} NewColorMapType; - -static int SubdivColorMap(NewColorMapType * NewColorSubdiv, - unsigned int ColorMapSize, - unsigned int *NewColorMapSize); -static int SortCmpRtn(const VoidPtr Entry1, const VoidPtr Entry2); - -/****************************************************************************** - * Quantize high resolution image into lower one. Input image consists of a - * 2D array for each of the RGB colors with size Width by Height. There is no - * Color map for the input. Output is a quantized image with 2D array of - * indexes into the output color map. - * Note input image can be 24 bits at the most (8 for red/green/blue) and - * the output has 256 colors at the most (256 entries in the color map.). - * ColorMapSize specifies size of color map up to 256 and will be updated to - * real size before returning. - * Also non of the parameter are allocated by this routine. - * This function returns GIF_OK if succesfull, GIF_ERROR otherwise. - ******************************************************************************/ -int -QuantizeBuffer(unsigned int Width, - unsigned int Height, - int *ColorMapSize, - GifByteType * RedInput, - GifByteType * GreenInput, - GifByteType * BlueInput, - GifByteType * OutputBuffer, - GifColorType * OutputColorMap) { - - unsigned int Index, NumOfEntries; - int i, j, MaxRGBError[3]; - unsigned int NewColorMapSize; - long Red, Green, Blue; - NewColorMapType NewColorSubdiv[256]; - QuantizedColorType *ColorArrayEntries, *QuantizedColor; - - ColorArrayEntries = (QuantizedColorType *)malloc( - sizeof(QuantizedColorType) * COLOR_ARRAY_SIZE); - if (ColorArrayEntries == NULL) { - _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; - return GIF_ERROR; - } - - for (i = 0; i < COLOR_ARRAY_SIZE; i++) { - ColorArrayEntries[i].RGB[0] = i >> (2 * BITS_PER_PRIM_COLOR); - ColorArrayEntries[i].RGB[1] = (i >> BITS_PER_PRIM_COLOR) & - MAX_PRIM_COLOR; - ColorArrayEntries[i].RGB[2] = i & MAX_PRIM_COLOR; - ColorArrayEntries[i].Count = 0; - } - - /* Sample the colors and their distribution: */ - for (i = 0; i < (int)(Width * Height); i++) { - Index = ((RedInput[i] >> (8 - BITS_PER_PRIM_COLOR)) << - (2 * BITS_PER_PRIM_COLOR)) + - ((GreenInput[i] >> (8 - BITS_PER_PRIM_COLOR)) << - BITS_PER_PRIM_COLOR) + - (BlueInput[i] >> (8 - BITS_PER_PRIM_COLOR)); - ColorArrayEntries[Index].Count++; - } - - /* Put all the colors in the first entry of the color map, and call the - * recursive subdivision process. */ - for (i = 0; i < 256; i++) { - NewColorSubdiv[i].QuantizedColors = NULL; - NewColorSubdiv[i].Count = NewColorSubdiv[i].NumEntries = 0; - for (j = 0; j < 3; j++) { - NewColorSubdiv[i].RGBMin[j] = 0; - NewColorSubdiv[i].RGBWidth[j] = 255; - } - } - - /* Find the non empty entries in the color table and chain them: */ - for (i = 0; i < COLOR_ARRAY_SIZE; i++) - if (ColorArrayEntries[i].Count > 0) - break; - QuantizedColor = NewColorSubdiv[0].QuantizedColors = &ColorArrayEntries[i]; - NumOfEntries = 1; - while (++i < COLOR_ARRAY_SIZE) - if (ColorArrayEntries[i].Count > 0) { - QuantizedColor->Pnext = &ColorArrayEntries[i]; - QuantizedColor = &ColorArrayEntries[i]; - NumOfEntries++; - } - QuantizedColor->Pnext = NULL; - - NewColorSubdiv[0].NumEntries = NumOfEntries; /* Different sampled colors */ - NewColorSubdiv[0].Count = ((long)Width) * Height; /* Pixels */ - NewColorMapSize = 1; - if (SubdivColorMap(NewColorSubdiv, *ColorMapSize, &NewColorMapSize) != - GIF_OK) { - free((char *)ColorArrayEntries); - return GIF_ERROR; - } - if (NewColorMapSize < *ColorMapSize) { - /* And clear rest of color map: */ - for (i = NewColorMapSize; i < *ColorMapSize; i++) - OutputColorMap[i].Red = OutputColorMap[i].Green = - OutputColorMap[i].Blue = 0; - } - - /* Average the colors in each entry to be the color to be used in the - * output color map, and plug it into the output color map itself. */ - for (i = 0; i < NewColorMapSize; i++) { - if ((j = NewColorSubdiv[i].NumEntries) > 0) { - QuantizedColor = NewColorSubdiv[i].QuantizedColors; - Red = Green = Blue = 0; - while (QuantizedColor) { - QuantizedColor->NewColorIndex = i; - Red += QuantizedColor->RGB[0]; - Green += QuantizedColor->RGB[1]; - Blue += QuantizedColor->RGB[2]; - QuantizedColor = QuantizedColor->Pnext; - } - OutputColorMap[i].Red = (Red << (8 - BITS_PER_PRIM_COLOR)) / j; - OutputColorMap[i].Green = (Green << (8 - BITS_PER_PRIM_COLOR)) / j; - OutputColorMap[i].Blue = (Blue << (8 - BITS_PER_PRIM_COLOR)) / j; - } else - fprintf(stderr, - "\n%s: Null entry in quantized color map - that's weird.\n", - PROGRAM_NAME); - } - - /* Finally scan the input buffer again and put the mapped index in the - * output buffer. */ - MaxRGBError[0] = MaxRGBError[1] = MaxRGBError[2] = 0; - for (i = 0; i < (int)(Width * Height); i++) { - Index = ((RedInput[i] >> (8 - BITS_PER_PRIM_COLOR)) << - (2 * BITS_PER_PRIM_COLOR)) + - ((GreenInput[i] >> (8 - BITS_PER_PRIM_COLOR)) << - BITS_PER_PRIM_COLOR) + - (BlueInput[i] >> (8 - BITS_PER_PRIM_COLOR)); - Index = ColorArrayEntries[Index].NewColorIndex; - OutputBuffer[i] = Index; - if (MaxRGBError[0] < ABS(OutputColorMap[Index].Red - RedInput[i])) - MaxRGBError[0] = ABS(OutputColorMap[Index].Red - RedInput[i]); - if (MaxRGBError[1] < ABS(OutputColorMap[Index].Green - GreenInput[i])) - MaxRGBError[1] = ABS(OutputColorMap[Index].Green - GreenInput[i]); - if (MaxRGBError[2] < ABS(OutputColorMap[Index].Blue - BlueInput[i])) - MaxRGBError[2] = ABS(OutputColorMap[Index].Blue - BlueInput[i]); - } - -#ifdef DEBUG - fprintf(stderr, - "Quantization L(0) errors: Red = %d, Green = %d, Blue = %d.\n", - MaxRGBError[0], MaxRGBError[1], MaxRGBError[2]); -#endif /* DEBUG */ - - free((char *)ColorArrayEntries); - - *ColorMapSize = NewColorMapSize; - - return GIF_OK; -} - -/****************************************************************************** - * Routine to subdivide the RGB space recursively using median cut in each - * axes alternatingly until ColorMapSize different cubes exists. - * The biggest cube in one dimension is subdivide unless it has only one entry. - * Returns GIF_ERROR if failed, otherwise GIF_OK. - ******************************************************************************/ -static int -SubdivColorMap(NewColorMapType * NewColorSubdiv, - unsigned int ColorMapSize, - unsigned int *NewColorMapSize) { - - int MaxSize; - unsigned int i, j, Index = 0, NumEntries, MinColor, MaxColor; - long Sum, Count; - QuantizedColorType *QuantizedColor, **SortArray; - - while (ColorMapSize > *NewColorMapSize) { - /* Find candidate for subdivision: */ - MaxSize = -1; - for (i = 0; i < *NewColorMapSize; i++) { - for (j = 0; j < 3; j++) { - if ((((int)NewColorSubdiv[i].RGBWidth[j]) > MaxSize) && - (NewColorSubdiv[i].NumEntries > 1)) { - MaxSize = NewColorSubdiv[i].RGBWidth[j]; - Index = i; - SortRGBAxis = j; - } - } - } - - if (MaxSize == -1) - return GIF_OK; - - /* Split the entry Index into two along the axis SortRGBAxis: */ - - /* Sort all elements in that entry along the given axis and split at - * the median. */ - SortArray = (QuantizedColorType **)malloc( - sizeof(QuantizedColorType *) * - NewColorSubdiv[Index].NumEntries); - if (SortArray == NULL) - return GIF_ERROR; - for (j = 0, QuantizedColor = NewColorSubdiv[Index].QuantizedColors; - j < NewColorSubdiv[Index].NumEntries && QuantizedColor != NULL; - j++, QuantizedColor = QuantizedColor->Pnext) - SortArray[j] = QuantizedColor; - - qsort(SortArray, NewColorSubdiv[Index].NumEntries, - sizeof(QuantizedColorType *), SortCmpRtn); - - /* Relink the sorted list into one: */ - for (j = 0; j < NewColorSubdiv[Index].NumEntries - 1; j++) - SortArray[j]->Pnext = SortArray[j + 1]; - SortArray[NewColorSubdiv[Index].NumEntries - 1]->Pnext = NULL; - NewColorSubdiv[Index].QuantizedColors = QuantizedColor = SortArray[0]; - free((char *)SortArray); - - /* Now simply add the Counts until we have half of the Count: */ - Sum = NewColorSubdiv[Index].Count / 2 - QuantizedColor->Count; - NumEntries = 1; - Count = QuantizedColor->Count; - while ((Sum -= QuantizedColor->Pnext->Count) >= 0 && - QuantizedColor->Pnext != NULL && - QuantizedColor->Pnext->Pnext != NULL) { - QuantizedColor = QuantizedColor->Pnext; - NumEntries++; - Count += QuantizedColor->Count; - } - /* Save the values of the last color of the first half, and first - * of the second half so we can update the Bounding Boxes later. - * Also as the colors are quantized and the BBoxes are full 0..255, - * they need to be rescaled. - */ - MaxColor = QuantizedColor->RGB[SortRGBAxis]; /* Max. of first half */ - MinColor = QuantizedColor->Pnext->RGB[SortRGBAxis]; /* of second */ - MaxColor <<= (8 - BITS_PER_PRIM_COLOR); - MinColor <<= (8 - BITS_PER_PRIM_COLOR); - - /* Partition right here: */ - NewColorSubdiv[*NewColorMapSize].QuantizedColors = - QuantizedColor->Pnext; - QuantizedColor->Pnext = NULL; - NewColorSubdiv[*NewColorMapSize].Count = Count; - NewColorSubdiv[Index].Count -= Count; - NewColorSubdiv[*NewColorMapSize].NumEntries = - NewColorSubdiv[Index].NumEntries - NumEntries; - NewColorSubdiv[Index].NumEntries = NumEntries; - for (j = 0; j < 3; j++) { - NewColorSubdiv[*NewColorMapSize].RGBMin[j] = - NewColorSubdiv[Index].RGBMin[j]; - NewColorSubdiv[*NewColorMapSize].RGBWidth[j] = - NewColorSubdiv[Index].RGBWidth[j]; - } - NewColorSubdiv[*NewColorMapSize].RGBWidth[SortRGBAxis] = - NewColorSubdiv[*NewColorMapSize].RGBMin[SortRGBAxis] + - NewColorSubdiv[*NewColorMapSize].RGBWidth[SortRGBAxis] - MinColor; - NewColorSubdiv[*NewColorMapSize].RGBMin[SortRGBAxis] = MinColor; - - NewColorSubdiv[Index].RGBWidth[SortRGBAxis] = - MaxColor - NewColorSubdiv[Index].RGBMin[SortRGBAxis]; - - (*NewColorMapSize)++; - } - - return GIF_OK; -} - -/**************************************************************************** - * Routine called by qsort to compare to entries. - ****************************************************************************/ -static int -SortCmpRtn(const VoidPtr Entry1, - const VoidPtr Entry2) { - - return (*((QuantizedColorType **) Entry1))->RGB[SortRGBAxis] - - (*((QuantizedColorType **) Entry2))->RGB[SortRGBAxis]; -} diff --git a/src/phantomjs.pro b/src/phantomjs.pro index c079b460..9d67dab8 100644 --- a/src/phantomjs.pro +++ b/src/phantomjs.pro @@ -62,7 +62,6 @@ OTHER_FILES += \ modules/cookiejar.js \ repl.js -include(gif/gif.pri) include(mongoose/mongoose.pri) include(linenoise/linenoise.pri) include(qcommandline/qcommandline.pri) diff --git a/src/webpage.cpp b/src/webpage.cpp index 095e5f83..75139176 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -56,8 +56,6 @@ #include #include -#include - #include "phantom.h" #include "networkaccessmanager.h" #include "utils.h" @@ -922,9 +920,6 @@ bool WebPage::render(const QString &fileName, const QVariantMap &option) else if (fileName.endsWith(".pdf", Qt::CaseInsensitive) ){ format = "pdf"; } - else if (fileName.endsWith(".gif", Qt::CaseInsensitive) ){ - format = "gif"; - } if( option.contains("quality") ){ quality = option.value("quality").toInt(); @@ -934,10 +929,6 @@ bool WebPage::render(const QString &fileName, const QVariantMap &option) if ( format == "pdf" ){ retval = renderPdf(outFileName); } - else if ( format == "gif" ) { - QImage rawPageRendering = renderImage(); - retval = exportGif(rawPageRendering, outFileName); - } else{ QImage rawPageRendering = renderImage(); diff --git a/test/webpage-spec-renders/test.gif b/test/webpage-spec-renders/test.gif deleted file mode 100644 index 41f2173527d96b9fe20e7ba7728b1e391be13f95..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23635 zcmeEN^;;V}v@W#RC~gIc4tIB0ac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kVTA#PLc9j>)H~U{v8N5|G$sv8rD4f9y$i+!L(pUYp z-s#MlZpekMY}Hz$ZCB4r^pL@Jd}q1dV!gyOkIduR^7zfv2WZs+462kas{b$v$j3$D zqJ-)GO@f84a(F|nNt~&f+Nu3`qccaF_j#?~c)=e#+P{3Xq)PLeT(q(q*HWF$>a9v9 zn8vet(4&QB6JR&yT&1yn(GPCXu^n>f*|#drWfqe(KH$Zi)hQnH&blv_yt31rf?Vs=Yg^LQ{J{gR;%7Ft zWjWtRoWv1MtMpyV$0g?}z28b++#%cYh~DLiKCUMnl89a2fm_tyndv^BToA6(f8MB- zez%XlzB?J7;(4jgJ;rCew`W{ntlRpqFSZ-tIkueIg)OB;np|d{Z2y{B)hRpaw|?Eb zd%Bw{kY1kM@k!>p-hP5Tv2oY40O<43p36O&?t}f*^Iq%wKGC`R@3ZB;iT=&s_|O}_ z@lAZLr(3^ee)At*?2Uc$vAe?i#jPV;-jy2kB{%V>-q}4K+M9mlDc-Ro{q9Mg@=={g zf&=1HAK}^EeCJyrHtBHazVZJYa&@cc?cU@gp5Q0n?t9<#MN5%}Kfv02vbjImU)N=Z))r9{$>$k! j&DpnHanNO$AAmqHC!%$?2?ZC52PrsLgjJ37RX_kc0F$i> diff --git a/test/webpage-spec.js b/test/webpage-spec.js index 6a30e996..5e11b56b 100644 --- a/test/webpage-spec.js +++ b/test/webpage-spec.js @@ -2210,14 +2210,6 @@ xdescribe("WebPage render image", function(){ render_test("pdf", { format: "pdf" }); }); - it("should render GIF file", function(){ - render_test("gif"); - }); - - it("should render GIF file with format option", function(){ - render_test("gif", { format: "gif" }); - }); - it("should render PNG file", function(){ render_test("png"); }); diff --git a/third-party.txt b/third-party.txt index e62419e9..1d0f439b 100644 --- a/third-party.txt +++ b/third-party.txt @@ -35,10 +35,6 @@ QCommandLine - http://xf.iksaif.net/dev/qcommandline.html License: GNU Lesser General Public License (LGPL) version 2.1. Reference: http://dev.iksaif.net/projects/qcommandline/repository/revisions/master/entry/COPYING -GIFLIB - http://giflib.sourceforge.net/ -License: MIT -Reference: http://giflib.cvs.sourceforge.net/viewvc/giflib/giflib/COPYING - wkhtmlpdf - http://code.google.com/p/wkhtmltopdf/ License: GNU Lesser General Public License (LGPL) Reference: http://code.google.com/p/wkhtmltopdf/