outptgif.h

Go to the documentation of this file.
00001 // $Id: outptgif.h 1348 2006-06-21 12:47:25Z luke $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 
00099 // header for OutputGIF
00100 
00101 #ifndef INC_OUTPTGIF
00102 #define INC_OUTPTGIF
00103 
00104 #include "ccfile.h"                     // needs FilePos
00105 #include "dibconv.h"                    // needs DIBConvert
00106 #include "dibutil.h"                    // needs FNPTR_SCANLINE
00107 #include "outptdib.h"   
00108 #include "gifutil.h"                    // GIF header definitions
00109 
00110 #define GIFBITS         12
00111 #define MAX_LWZ_BITS    12
00112 #define HSIZE           5003            // 80% occupancy
00113 
00114 #define MAXCODE(n_bits)        (((code_int) 1 << (n_bits)) - 1)
00115 
00116 #define HashTabOf(i)       htab[i]
00117 #define CodeTabOf(i)    codetab[i]
00118 
00119 #define tab_prefixof(i)         CodeTabOf(i)
00120 #define tab_suffixof(i)        ((char_type*)(htab))[i]
00121 #define de_stack               ((char_type*)&tab_suffixof((code_int)1<<GIFBITS))
00122 
00123 class BaseCamelotFilter;
00124  
00125 /********************************************************************************************
00126 
00127 >   class OutputGIF : public OutputDIB
00128 
00129     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00130     Created:    24/4/95
00131     Purpose:    Contains functions to write a DIB to a GIF in segments, optionally
00132                 with compression, optionally converting from one depth to another. To use:
00133                 Open a CCLexFile for write. Call StartFile to write out the header. Call
00134                 WriteBlock to write out each block of the bitmap, starting from low memory.
00135                 When you're done, call TidyUp.
00136                 Similar to OutputDIB but strangely enough writes the data as a GIF instead
00137                 of a BMP or via the AccusoftFilters. 
00138     SeeAlso:    OutputDIB;
00139 
00140 ********************************************************************************************/
00141 
00142 class OutputGIF : public OutputDIB
00143 {
00144 public:
00145 
00146     OutputGIF();
00147     virtual ~OutputGIF() {}
00148 
00149     virtual BOOL StartFile( LPBITMAPINFOHEADER lpHeader, LPLOGPALETTE Palette, UINT32 OutputDepth, DWORD CompressionType,
00150                             UINT32 FinalHeight, INT32 ExportSize, UINT32 DitherType);
00151     virtual BOOL ReStartFile(LOGPALETTE* pNewPal);
00152     virtual BOOL WriteBlock( UINT32 YPos, UINT32 Height, LPBYTE BlockStart, UINT32 InputBPP = 32,
00153                              INT32 ProgressOffset = 0);
00154     virtual BOOL SetUpInfoHeader(const LPBITMAPINFOHEADER lpHeader, const UINT32 OutputDepth,
00155                                  const DWORD CompressionType, const UINT32 LIneWidth, const UINT32 FinalHeight,
00156                                  INT32 *PalSize); 
00157     virtual BOOL TidyUp();
00158 
00159     // Useful routines for calling to output the GIF data itself
00160     BOOL OutputGifFileHeader(CCLexFile *File, LPBITMAPINFOHEADER pInfo, BOOL Enhanced, INT32 TransColour,
00161                              LPLOGPALETTE pPalette = NULL, LPRGBQUAD pQuadPalette = NULL);
00162     BOOL OutputGifFileHeader(CCLexFile *File, BOOL Enhanced, INT32 TransColour);
00163     BOOL OutputGifImageExtensionHeader(CCLexFile *File, BOOL InterlaceState, INT32 TransparentColour,
00164                                        UINT32 Delay, UINT32 RestoreType);
00165     BOOL OutputGifImageBits(CCLexFile *File, LPBYTE pBlockStart, BOOL Interlace, BOOL LocalColourTable,
00166                             BaseCamelotFilter *pFilter = NULL,
00167                             UINT32 NewWidth = 0, UINT32 NewHeight = 0, UINT32 LeftOffset = 0, UINT32 TopOffset = 0,
00168                             LPRGBQUAD pDestPalette = NULL, UINT32 PaletteColourDepth = 0, UINT32 NewBitsPerPixel = 0);
00169     BOOL OutputGifTerminator(CCLexFile *File);
00170     BOOL OutputAnimationControl(CCLexFile *File, unsigned short Repeats);
00171 
00172     virtual LPBITMAPINFO GetDestBitmapInfo ( void );
00173     virtual LPBYTE GetDestBitmapBits ( void );
00174 
00175     INT32 GetColourDepth(INT32 NumberOfColours);
00176 
00177 protected:
00178 
00179     // The buffer to hold the destination bitmap before we actually write it out to file
00180     LPBITMAPINFO DestBitmapInfo;
00181     LPBYTE DestBitmapBytes;
00182     LPBYTE pNextStrip;
00183 
00184     // This stores the pointer to the BaseCamelotFilter, which might be required for progress
00185     // bar updates.
00186     BaseCamelotFilter * pCamFilter;
00187 
00188     // Some useful variables
00189     INT32 Width;                        // Width of the image
00190     INT32 Height;                       // Height of the image
00191     INT32 curx;                     // current x position
00192     INT32 cury;                     // current y position
00193     INT32 CurrentLine;              // count of the lines output so far, used for progress bar
00194     INT32 CountDown;
00195     BOOL InterlacingOn;
00196     INT32 Pass;                     // interlaced pass that we are on
00197 
00198     WORD BitsPerPixel;              // Colour depth required
00199     INT32 InitCodeSize;             // starting size of the bitmap data to compress
00200     INT32 Background;                   // background colour number
00201 
00202     LPBYTE DataBuffer;              // Start of buffer to compress
00203     //INT32 DataBufferSize;             // size of the data buffer
00204     UINT32 WidthOfLine;             // word/byte rounded line width rather than the pixel width
00205 
00206     typedef unsigned char char_type;
00207 
00208     INT32 n_bits;                       // number of bits/code
00209     code_int maxcode;                   // maximum code, given n_bits
00210 
00211     count_int htab [HSIZE];
00212     unsigned short codetab [HSIZE];
00213 
00214     code_int free_ent;      // first unused entry
00215 
00216     // block compression parameters -- after all codes are used up,
00217     // and compression rate changes, start over.
00218     INT32 clear_flg;
00219 
00220     INT32 offset;
00221     INT32 in_count;       // length of input
00222     INT32 out_count;        // # of codes output (for debugging)
00223 
00224     // For compress()
00225     INT32 g_init_bits;
00226 
00227     INT32 ClearCode;
00228     INT32 EOFCode;
00229 
00230     // for output()
00231     UINT32 cur_accum;
00232     INT32 cur_bits;
00233 
00234     INT32 a_count;      // Number of characters so far in this 'packet' (accumulator)
00235     char accum[ 256 ];  // Define the storage for the packet accumulator
00236 
00237     // Useful routines
00238     void CompressBlockToFile( LPBYTE Buffer, INT32 init_bits);
00239     void OutputCode( code_int code );
00240     void ClearBlock ();
00241     void ClearHashTable(count_int hsize);
00242     void CharacterInit();
00243     void OutputCharacter( INT32 c );
00244     void FlushCharacters();
00245     //void init_statics();
00246     INT32 GIFNextPixel();
00247     void BumpPixel();
00248     //BOOL BoundsSafe(INT32 x, INT32 y);
00249     //INT32 GetPixel(INT32 x, INT32 y);
00250 };
00251 
00252 #endif // INC_OUTPTGIF

Generated on Sat Nov 10 03:48:45 2007 for Camelot by  doxygen 1.4.4