Alien-FreeImage
view release on metacpan or search on metacpan
src/Source/LibJPEG/wrgif.c view on Meta::CPAN
/*
* wrgif.c
*
* Copyright (C) 1991-1997, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains routines to write output images in GIF format.
*
**************************************************************************
* NOTE: to avoid entanglements with Unisys' patent on LZW compression, *
* this code has been modified to output "uncompressed GIF" files. *
* There is no trace of the LZW algorithm in this file. *
**************************************************************************
*
* These routines may need modification for non-Unix environments or
* specialized applications. As they stand, they assume output to
* an ordinary stdio stream.
*/
/*
* This code is loosely based on ppmtogif from the PBMPLUS distribution
* of Feb. 1991. That file contains the following copyright notice:
* Based on GIFENCODE by David Rowley <mgardi@watdscu.waterloo.edu>.
* Lempel-Ziv compression based on "compress" by Spencer W. Thomas et al.
* Copyright (C) 1989 by Jef Poskanzer.
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation. This software is provided "as is" without express or
* implied warranty.
*
* We are also required to state that
* "The Graphics Interchange Format(c) is the Copyright property of
* CompuServe Incorporated. GIF(sm) is a Service Mark property of
* CompuServe Incorporated."
*/
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#ifdef GIF_SUPPORTED
/* Private version of data destination object */
typedef struct {
struct djpeg_dest_struct pub; /* public fields */
j_decompress_ptr cinfo; /* back link saves passing separate parm */
/* State for packing variable-width codes into a bitstream */
int n_bits; /* current number of bits/code */
int maxcode; /* maximum code, given n_bits */
INT32 cur_accum; /* holds bits not yet output */
int cur_bits; /* # of bits in cur_accum */
/* State for GIF code assignment */
int ClearCode; /* clear code (doesn't change) */
int EOFCode; /* EOF code (ditto) */
int code_counter; /* counts output symbols */
/* GIF data packet construction buffer */
int bytesinpkt; /* # of bytes in current packet */
char packetbuf[256]; /* workspace for accumulating packet */
} gif_dest_struct;
typedef gif_dest_struct * gif_dest_ptr;
/* Largest value that will fit in N bits */
#define MAXCODE(n_bits) ((1 << (n_bits)) - 1)
/*
* Routines to package finished data bytes into GIF data blocks.
( run in 1.055 second using v1.01-cache-2.11-cpan-64ef6c95b5d )