00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 #ifndef INC_GIFFILTR
00101 #define INC_GIFFILTR
00102
00103 #include "maskfilt.h"
00104
00105 #include "bmpprefs.h"
00106
00107
00108 class CXaraFileRecord;
00109
00110 #define ZERO 0
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 class GIFImportOptions : public BitmapImportOptions
00122 {
00123
00124 CC_DECLARE_MEMDUMP(GIFImportOptions);
00125 public:
00126 GIFImportOptions() : BitmapImportOptions() {m_bProvideProgress = TRUE;}
00127
00128 };
00129
00130 typedef UINT32 CENTISECONDS;
00131
00132
00133
00134
00135
00136
00137
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
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
00191 virtual BOOL CopyFrom(BitmapExportOptions *pOther);
00192
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;
00204 UINT32 m_LeftOffset;
00205 UINT32 m_TopOffset;
00206 CENTISECONDS m_AnimDelay;
00207 GIFDisposalMethod m_AnimDispose;
00208 UINT32 m_AnimLoop;
00209 Coord m_AnimSize;
00210 BOOL DelayValueIsDefault;
00211 static KernelBitmap** m_pBitmapList;
00212 static UINT32 m_ListSize;
00213
00214
00215 static CENTISECONDS g_AnimationDelay;
00216 static GIFDisposalMethod g_AnimationRestoreType;
00217 static UINT32 g_AnimationLoopCount;
00218 };
00219
00220 class KernelBitmap;
00221 class BaseCamelotFilter;
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
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
00247 virtual BOOL IsDefaultDocRequired(const TCHAR* pcszPathName);
00248
00249 virtual FilterType GetFilterType() const { return TI_GIF; }
00250
00251
00252 virtual BOOL ReadFromFile(OILBitmap* pOilBitmap);
00253
00254
00255 virtual BOOL ReadFromFile(OILBitmap* pOilBitmap, BaseCamelotFilter* pFilter,
00256 CCLexFile* pFile, BOOL IsCompressed);
00257
00258
00259 virtual BOOL WriteBitmapToFile(KernelBitmap* pKernelBitmap, BaseCamelotFilter* pFilter,
00260 CCLexFile* pFile, INT32 Compression);
00261
00262
00263 virtual BOOL SaveExportBitmapsToFile(CCLexFile* pFile, PathName* pPath, BitmapExportParam* pParam,
00264 BOOL DontShowFileName = FALSE);
00265
00266 void AlterPaletteContents( LPLOGPALETTE pPalette );
00267
00268
00269 virtual BOOL IsThisBppOk(UINT32 Bpp);
00270
00271
00272
00273 INT32 GetGifCompatibility();
00274
00275
00276 virtual UINT32 GetExportMsgID();
00277 virtual BOOL ShouldReuseExistingBitmaps();
00278 virtual void PostGetExportOptions(BitmapExportOptions* pOptions);
00279
00280 protected:
00281
00282
00283 virtual BitmapImportOptions* CreateImportOptions() const;
00284
00285
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
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
00310 static BOOL WriteToFile ( CCLexFile* File, LPBITMAPINFO Info, LPBYTE Bits,
00311 BOOL Interlace, INT32 Transparent,
00312 BaseCamelotFilter* pFilter = NULL);
00313
00314
00315 static OutputGIF DestGIF;
00316
00317
00318 INT32 GIFHowCompatible;
00319
00320 static FilterType s_FilterType;
00321
00322 BOOL m_DoingAnimation;
00323 UINT32 m_AnimationFrame;
00324
00325
00326 UINT32 Export2ndStageMsgID;
00327
00328
00329 UINT32 m_LeftOffset;
00330 UINT32 m_TopOffset;
00331
00332
00333 virtual BOOL AddOffsetFromBitmap(DocCoord * pOffset);
00334
00335
00336
00337 virtual BOOL SetFlagsFromBitmap(Layer * pLayer, KernelBitmap * pBitmap, UINT32 nBitmapToRead);
00338
00339
00340
00341 virtual BOOL SetAnimationPropertiesFromLoaded(Spread * pSpread);
00342
00343
00344
00345 virtual BOOL GetDragAndDropTranslation(ImportPosition* pPos, DocRect BoundsRect, Coord* Offset);
00346
00347 GIFDisposalMethod m_PreviousMethod;
00348 };
00349
00350
00351
00352
00353
00354
00355
00356
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
00387 INT32 m_TransColour;
00388 GIFDisposalMethod m_FrameRestore;
00389 CENTISECONDS m_FrameDelay;
00390
00391 UINT32 m_LeftOffset;
00392 UINT32 m_TopOffset;
00393
00394
00395
00396 LPBITMAPINFO m_pInfo;
00397 LPBYTE m_pBytes;
00398
00399
00400 LPBITMAPINFO m_pDiffInfo;
00401 LPBYTE m_pDiffBytes;
00402 };
00403
00404
00405 #endif // INC_GIFFILTR
00406
00407