giffiltr.h

Go to the documentation of this file.
00001 // $Id: giffiltr.h 1282 2006-06-09 09:46:49Z alex $
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 
00100 #ifndef INC_GIFFILTR
00101 #define INC_GIFFILTR
00102 
00103 #include "maskfilt.h"
00104 //#include "outptgif.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 #include "bmpprefs.h"   // SelectionType
00106 //#include "accures.h"
00107 
00108 class CXaraFileRecord;
00109 
00110 #define ZERO 0
00111 
00112 /********************************************************************************************
00113 
00114   > class GIFImportOptions : public BitmapImportOptions
00115 
00116     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00117     Created:    25/06/96
00118     Purpose:    Provides GIF specific options for the import
00119 
00120 ********************************************************************************************/
00121 class GIFImportOptions : public BitmapImportOptions
00122 {
00123     // Declare the class for memory tracking
00124     CC_DECLARE_MEMDUMP(GIFImportOptions);
00125 public:
00126     GIFImportOptions() : BitmapImportOptions() {m_bProvideProgress = TRUE;}
00127 
00128 };
00129 
00130 typedef UINT32 CENTISECONDS;
00131 /********************************************************************************************
00132 
00133 >   class GIFExportOptions : public MaskedFilterExportOptions
00134 
00135     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00136     Created:    30/10/96
00137     Purpose:    Base class for storing information about the bitmap we're exporting.
00138 
00139 ********************************************************************************************/
00140 class GIFExportOptions : public MaskedFilterExportOptions
00141 {
00142     CC_DECLARE_DYNCREATE(GIFExportOptions)
00143 public:
00144     static BOOL Declare();
00145 
00146     GIFExportOptions();
00147     GIFExportOptions(const FilterType FilterID, const StringBase* pFilterName);
00148 
00149     virtual BOOL    RetrieveDefaults();
00150     virtual BOOL    SetAsDefaults() const;
00151 
00152     // Save and load from named export set properties.
00153     virtual BOOL Write(CXaraFileRecord* pRec);
00154     virtual BOOL Read(CXaraFileRecord* pRec);
00155 
00156     virtual BOOL    GetSupportsImageMap() { return TRUE; }
00157 
00158     BOOL                GetGlobalPalette() const                        { return m_GlobalPalette; }
00159     void                SetGlobalPalette(UINT32 GlobalPalette)          { m_GlobalPalette = GlobalPalette; }
00160 
00161     UINT32              GetLeftOffset() const                           { return m_LeftOffset; }
00162     void                SetLeftOffset(UINT32 LeftOffset)                    { m_LeftOffset = LeftOffset; }
00163 
00164     UINT32              GetTopOffset() const                            { return m_TopOffset; }
00165     void                SetTopOffset(UINT32 TopOffset)                  { m_TopOffset = TopOffset; }
00166 
00167     GIFDisposalMethod   GetAnimationRestore();
00168     BOOL                SetAnimationRestore(const GIFDisposalMethod& DisposalMethod);
00169 
00170     CENTISECONDS        GetAnimationDelay();
00171     BOOL                SetAnimationDelay(CENTISECONDS Delay);
00172 
00173     UINT32              GetAnimationLoopCount() const;
00174     BOOL                SetAnimationLoopCount(UINT32 LoopCount, BOOL Value);
00175 
00176     Coord               GetAnimationSize() const;
00177     BOOL                SetAnimationSize(const Coord& Size);
00178 
00179     BOOL                GetDelayValueIsDefault()    const               { return DelayValueIsDefault; }
00180     BOOL                SetDelayValueIsDefault(BOOL Value)              { DelayValueIsDefault = Value; return TRUE; }
00181 
00182     static KernelBitmap**   GetBitmapList()                             { return m_pBitmapList; }
00183     static void             SetBitmapList(KernelBitmap** pBitmap)       { m_pBitmapList = pBitmap; }
00184 
00185     static UINT32               GetListSize()               { return m_ListSize; }
00186     static void             SetListSize(UINT32 n)           { m_ListSize = n;    }
00187     static void             IncListSize(UINT32 n)           { m_ListSize += n;   }  
00188     static void             DecListSize(UINT32 n)           { m_ListSize -= n;   } 
00189 
00190     // for object copying and comparing
00191     virtual BOOL CopyFrom(BitmapExportOptions *pOther);
00192 //  virtual BOOL Equal(BitmapExportOptions *pOther);
00193 
00194     virtual BOOL FileTypeChangeCopyFrom(BitmapExportOptions *pOther);
00195 
00196     UINT32  DelayIndex;
00197     UINT32  RestoreIndex;
00198     
00199     virtual UINT32 GetFilterNameStrID() { return _R(IDN_FILTERNAME_GIF);}
00200 
00201 
00202 protected:
00203     BOOL                m_GlobalPalette;    // Animation has a global rather than a local palette
00204     UINT32              m_LeftOffset;       // left offset from overall bounds of animation
00205     UINT32              m_TopOffset;        // top offset from overall bounds of animation
00206     CENTISECONDS        m_AnimDelay;        // Delay between frames for Animations
00207     GIFDisposalMethod   m_AnimDispose;      // Disposal method for frames in Animation
00208     UINT32              m_AnimLoop;         // Number of times to loop Animation
00209     Coord               m_AnimSize;         // Size for Animation frames
00210     BOOL                        DelayValueIsDefault;
00211     static KernelBitmap**       m_pBitmapList;
00212     static UINT32                   m_ListSize;
00213 
00214     // Persistant buffer
00215     static CENTISECONDS         g_AnimationDelay;       // Milliseconds between frames.
00216     static GIFDisposalMethod    g_AnimationRestoreType;
00217     static UINT32                   g_AnimationLoopCount;   // Times animation should repeat.
00218 };
00219 
00220 class KernelBitmap;
00221 class BaseCamelotFilter;
00222 
00223 /********************************************************************************************
00224 
00225 >   class TI_GIFFilter : public MaskedFilter
00226 
00227     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00228     Created:    24/4/95
00229     Purpose:    Encapsulates a Windows GIF export and import filter.
00230                 Derives off the masked filter which provides funcitonality for doing masked
00231                 bitmap export and import.
00232 
00233 ********************************************************************************************/
00234 
00235 class TI_GIFFilter : public MaskedFilter
00236 {
00237     CC_DECLARE_DYNAMIC(TI_GIFFilter);
00238     
00239 public:
00240     TI_GIFFilter();
00241     virtual BOOL Init();
00242 
00243     virtual INT32 HowCompatible( PathName& Filename, ADDR HeaderStart, UINT32 HeaderSize,
00244                                UINT32 FileSize );
00245 
00246     //Graham 5/11/97
00247     virtual BOOL IsDefaultDocRequired(const TCHAR* pcszPathName);
00248 
00249     virtual FilterType GetFilterType() const { return TI_GIF; }
00250 
00251     // Import related functions
00252     virtual BOOL ReadFromFile(OILBitmap* pOilBitmap);
00253 
00254     // This is the function for native/web files to use
00255     virtual BOOL ReadFromFile(OILBitmap* pOilBitmap, BaseCamelotFilter* pFilter,
00256                               CCLexFile* pFile, BOOL IsCompressed);
00257 
00258     // Function for web/native filters to use to write out the bitmap data to file
00259     virtual BOOL WriteBitmapToFile(KernelBitmap* pKernelBitmap, BaseCamelotFilter* pFilter,
00260                                    CCLexFile* pFile, INT32 Compression);
00261 
00262     // Function to write out a list of bitmaps to file
00263     virtual BOOL SaveExportBitmapsToFile(CCLexFile* pFile, PathName* pPath, BitmapExportParam* pParam,
00264                                          BOOL DontShowFileName = FALSE);
00265 
00266     void AlterPaletteContents( LPLOGPALETTE pPalette );
00267 
00268     // Check if this Bitmap filter can cope with saving at this Bpp/Colour depth
00269     virtual BOOL IsThisBppOk(UINT32 Bpp);
00270 
00271     // Public way of finding out how compatable the GIF filter thought the file was
00272     // We might want to bring in the Accusoft filter to help out.
00273     INT32 GetGifCompatibility();
00274 
00275     // Virtual overrides
00276     virtual UINT32 GetExportMsgID();
00277     virtual BOOL ShouldReuseExistingBitmaps(); 
00278     virtual void PostGetExportOptions(BitmapExportOptions* pOptions);
00279 
00280 protected:
00281 
00282     // Import related functions
00283     virtual BitmapImportOptions* CreateImportOptions() const;
00284 
00285     // Export related functions 
00286     virtual BitmapExportOptions* CreateExportOptions() const;
00287 
00288     virtual OutputDIB* GetOutputDIB ( void );
00289 
00290     virtual UINT32 GetHintType(void);
00291     virtual BOOL GetExportOptions( BitmapExportOptions* pOptions );
00292     virtual void CleanUpAfterExport();
00293     virtual BOOL EndWriteToFile( );
00294 
00295     virtual BOOL WriteFileHeader(void);
00296     virtual BOOL WritePreFrame(void);
00297     virtual BOOL WritePreSecondPass(void);
00298     virtual BOOL WritePostOptimisedPalette(void);
00299     virtual BOOL WriteFrame(void);
00300     virtual BOOL WritePostFrame(void);
00301     virtual BOOL WriteFileEnd(void);
00302 
00303     virtual BOOL WriteBitmapToFile(KernelBitmap* pKernelBitmap, double Dpi);
00304     
00305     // this is used for the actual writing of the file
00306     static BOOL WriteDataToFile( BOOL End, UINT32 Bpp, UINT32 Compression);
00307     static BOOL WriteToFile ( CCLexFile* File, LPBITMAPINFO Info, LPBYTE Bits,
00308                               String_64* ProgressString = NULL);
00309     // This is the form used for direct saving bitmaps into the native/web file format
00310     static BOOL WriteToFile ( CCLexFile* File, LPBITMAPINFO Info, LPBYTE Bits,
00311                               BOOL Interlace, INT32 Transparent,
00312                               BaseCamelotFilter* pFilter = NULL);
00313 
00314     // The class we use for actually outputting the GIF data and converting from 32 to n bpps
00315     static OutputGIF DestGIF;
00316 
00317     // This is so we can remember what we thought of the GIF file.
00318     INT32 GIFHowCompatible;
00319 
00320     static FilterType s_FilterType;     // Type of filter in use (TI_GIF .. TI_GIF_TRANSINTER)
00321 
00322     BOOL m_DoingAnimation;      // flag for wether or not we are generating a GIF animation
00323     UINT32 m_AnimationFrame;        // the frame we are on in the animation
00324 
00325     // The string to display when exporting the second stage.
00326     UINT32 Export2ndStageMsgID;
00327 
00328     // When we load a GIF, if there is any x,y offset, then we use 
00329     UINT32 m_LeftOffset;
00330     UINT32 m_TopOffset;
00331 
00332     // Give the filter a chance to add in an offset that was contained in the bitmap definition
00333     virtual BOOL AddOffsetFromBitmap(DocCoord * pOffset);
00334 
00335     // Give the filter a chance to change the layer's flags given the newly loaded bitmap
00336     // Only applies if loading multiple bitmaps onto new layers.
00337     virtual BOOL SetFlagsFromBitmap(Layer * pLayer, KernelBitmap * pBitmap, UINT32 nBitmapToRead);
00338 
00339     // Give the filter a chance to change the animation properties given the newly loaded bitmaps
00340     // Only applies if loading multiple bitmaps onto new layers.
00341     virtual BOOL SetAnimationPropertiesFromLoaded(Spread * pSpread);
00342 
00343     // Normal action is to centre the object around the drop position. We do not want this
00344     // and so oeverride this
00345     virtual BOOL GetDragAndDropTranslation(ImportPosition* pPos, DocRect BoundsRect, Coord* Offset);
00346 
00347     GIFDisposalMethod m_PreviousMethod;
00348 };
00349 
00350 /********************************************************************************************
00351 
00352 >   class AnimatedGIFImage : public ListItem
00353 
00354     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00355     Created:    2/6/97
00356     Purpose:    Stores details on the GIF image which is part of an export animation sequence.
00357     
00358 ********************************************************************************************/
00359 
00360 class AnimatedGIFImage : public ListItem
00361 {
00362     CC_DECLARE_DYNCREATE( AnimatedGIFImage )
00363 
00364 public:
00365     AnimatedGIFImage();
00366     ~AnimatedGIFImage();
00367 
00368     AnimatedGIFImage(const INT32 TransColour, const GIFDisposalMethod FrameRestore,
00369                      const CENTISECONDS FrameDelay,
00370                      const UINT32 LeftOffset, const UINT32 TopOffset,
00371                      const LPBITMAPINFO pInfo, const LPBYTE pBytes,
00372                      const LPBITMAPINFO pDiffInfo = NULL, const LPBYTE pDiffBytes = NULL);
00373 
00374     LPBITMAPINFO        GetOutputInfo() const   { return m_pInfo; }
00375     LPBYTE              GetOutputBits() const   { return m_pBytes; }
00376 
00377     void SetFrameRestore(const GIFDisposalMethod FrameRestore) { m_FrameRestore = FrameRestore; }
00378     
00379     INT32               GetTransColour() const  { return m_TransColour; }
00380     GIFDisposalMethod   GetFrameRestore() const { return m_FrameRestore; }
00381     CENTISECONDS        GetFrameDelay() const   { return m_FrameDelay; }
00382     UINT32              GetLeftOffset() const   { return m_LeftOffset; }
00383     UINT32              GetTopOffset()  const   { return m_TopOffset; }
00384 
00385 protected:
00386     // Useful information about this frame in the image
00387     INT32               m_TransColour;
00388     GIFDisposalMethod   m_FrameRestore;
00389     CENTISECONDS        m_FrameDelay;
00390 
00391     UINT32              m_LeftOffset;
00392     UINT32              m_TopOffset;
00393 
00394     // This is a note of the bitmap image that needs outputting
00395     // It is a reference and so does not need cleaning up
00396     LPBITMAPINFO        m_pInfo;
00397     LPBYTE              m_pBytes;
00398     // This is the difference bitmap that may have been allocated
00399     // This does need cleaing up
00400     LPBITMAPINFO        m_pDiffInfo;
00401     LPBYTE              m_pDiffBytes;
00402 };
00403 
00404 
00405 #endif // INC_GIFFILTR
00406 
00407 

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