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_BITFILT
00101 #define INC_BITFILT
00102
00103
00104
00105
00106 #include "bmpprefs.h"
00107
00108
00109 #include "bmpsrc.h"
00110
00111 #include "filtimop.h"
00112
00113 class GRenderRegion;
00114 class GRenderBitmap;
00115 class KernelBitmap;
00116 class NodeBitmap;
00117 class OILBitmap;
00118 class BitmapExportParam;
00119 class BitmapExportOptions;
00120 class BaseCamelotFilter;
00121 class Progress;
00122
00123
00124 class CCLexFile;
00125 class ImagemapFilter;
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137 class BitmapImportOptions : public CC_CLASS_MEMDUMP
00138 {
00139
00140 CC_DECLARE_MEMDUMP(BitmapImportOptions);
00141 public:
00142 BitmapImportOptions() : m_bValid(FALSE), m_bCancelled(TRUE),
00143 m_bProvideProgress(FALSE) {};
00144
00145 BOOL m_bValid;
00146 BOOL m_bCancelled;
00147 BOOL m_bProvideProgress;
00148 };
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 class BaseBitmapFilter : public BitmapFilter
00165 {
00166 CC_DECLARE_DYNAMIC(BaseBitmapFilter);
00167
00168 public:
00169 BaseBitmapFilter();
00170 ~BaseBitmapFilter();
00171
00172
00173 virtual BOOL Init() { return TRUE; }
00174
00175 static BOOL InitBaseClass();
00176
00177
00178
00179 virtual BOOL IsDefaultDocRequired(const TCHAR* pcszPathName);
00180
00181 virtual FilterType GetFilterType() const { return INVALID; }
00182
00183 BOOL DoImport(SelOperation *Op, CCLexFile*, Document *DestDoc,
00184 BOOL AutoChosen = FALSE, ImportPosition *Pos = NULL,
00185 KernelBitmap** ppImportedBitmap = NULL,
00186 DocCoord* pPosTranslate = NULL, String_256* = NULL);
00187
00188 virtual BOOL DoExport(Operation*, CCLexFile*, PathName*, Document*, BOOL);
00189 virtual BOOL DoExportBitmap(Operation*, CCLexFile*, PathName*, KernelBitmap*);
00190 virtual BOOL DoExportBitmaps(Operation*, CCLexFile*, PathName*, BitmapExportParam*);
00191 virtual BOOL DoExportWithOptions(Operation*, CCLexFile*, PathName*, Document*, BitmapExportOptions*, DocRect* = NULL);
00192 virtual BOOL DoExportBitmapWithOptions(Operation*, CCLexFile*, PathName*, KernelBitmap*, BitmapExportOptions *);
00193 virtual BOOL DoExportHelper(Operation* pOp,
00194 CCLexFile* pFile,
00195 PathName* pPath,
00196 Document* pDoc);
00197
00198 CCLexFile* GetImportFile() { return InputFile; }
00199
00200 virtual BOOL ImportBitmap(CCLexFile*, KernelBitmap**);
00201 BOOL ImportBitmap(CCLexFile*, KernelBitmap**, const UINT32 nBitmapToRead);
00202
00203
00204 virtual BOOL ReadFromFile(OILBitmap* pOilBitmap);
00205
00206
00207 virtual BOOL ReadFromFile(OILBitmap* pOilBitmap, BaseCamelotFilter *pFilter,
00208 CCLexFile * pFile, BOOL IsCompressed);
00209
00210
00211 void SetPreviewBitmap(BOOL);
00212
00213
00214 virtual BOOL ExportVisibleLayersOnly();
00215
00216
00217 UINT32 GetImportMsgID() { return ImportMsgID; }
00218
00219
00220 virtual UINT32 GetExportMsgID();
00221 virtual BOOL ShouldReuseExistingBitmaps() { return TRUE; }
00222
00223
00224 BOOL SetExportOptions ( BitmapExportOptions* pOptions );
00225
00226
00227 BOOL SetUpExportOptions(BitmapExportOptions **ppExportOptions, BOOL OnlyDefaults = FALSE);
00228 BOOL SetUpExportBitmapOptions(BitmapExportOptions **ppExportOptions, KernelBitmap *pBitmap,
00229 BOOL OnlyDefaults = FALSE);
00230
00231
00232 virtual BOOL IsSecondPassRequired();
00233
00234
00235 virtual BOOL GenerateOptimisedPalette(Spread *pSpread, BitmapExportOptions *pOptions, BOOL SnapToBrowserPalette);
00236 virtual BOOL GenerateOptimisedPalette(Spread *pSpread, UINT32 Depth, double DPI, BOOL SnapToBrowserPalette, UINT32 NumColsInPalette, BOOL UsePrimaryCols);
00237
00238 static BOOL GeneratingOptimisedPalette();
00239
00240
00241 virtual BOOL IsFormatLossy() const;
00242 virtual BitmapSource* CreateBitmapSource(OFFSET Size) const;
00243
00244
00245
00246 virtual void ExportHTMLTag(PathName* ppthToUse);
00247
00248
00249
00250 virtual BitmapExportOptions* CreateExportOptions() const;
00251 BitmapExportOptions* GetBitmapExportOptions() const;
00252 virtual BOOL GetExportOptions(BitmapExportOptions* pOptions);
00253
00254
00255
00256
00257 virtual void PostGetExportOptions(BitmapExportOptions* pOptions);
00258
00259 virtual BOOL SetUpClippingRectangleForExport(Spread *pSpread, SelectionType Selection);
00260
00261
00262 virtual BOOL WriteBitmapToFile(KernelBitmap* pKernelBitmap, BaseCamelotFilter* pFilter,
00263 CCLexFile* pFile, INT32 Compression);
00264
00265
00266 virtual BOOL SaveExportBitmapsToFile(CCLexFile* pFile, PathName* pPath, BitmapExportParam* pParam,
00267 BOOL DontShowFileName = FALSE);
00268
00269
00270 virtual BOOL IsThisBppOk(UINT32 Bpp);
00271
00272
00273
00274 virtual BOOL ExportRenderNodes(RenderRegion *pRegion, ExportDC *pDC,
00275 BOOL VisibleLayersOnly = FALSE,
00276 BOOL CheckSelected = FALSE, BOOL ShowProgress = TRUE);
00277
00278
00279 virtual BOOL GetRenderBottomToTop();
00280
00281
00282 DocRect GetClipRect() const { return ClipRect; }
00283
00284
00285 static KernelBitmap *GetExportBitmap() {return pExportBitmap; };
00286
00287
00288 static DocRect GetSizeOfDrawing(Spread *pSpread=NULL);
00289 static DocRect GetSizeOfSpread(Spread *pSpread);
00290 static BOOL GetSizeOfBitmap(INT32 *PixelWidth, INT32 *PixelHeight);
00291 static void CallPixelAlignedFiddle( DocRect * r );
00292
00293
00294 static const INT32 MinPelsPerMeter;
00295
00296 static const INT32 MinExportSize;
00297
00298
00299
00300 static INT32 m_NumberOfPaletteEntries;
00301
00302
00303
00304
00305 BOOL ExportImagemap(Operation*, PathName*, Document*);
00306
00307
00308 virtual BOOL CanDoImportDPI() { return FALSE; }
00309 virtual void SetImportDPI(DPI ImportDPI) {}
00310
00311 static BOOL GetZoomOnImport() { return s_fZoomOnImport; }
00312 static void SetZoomOnImport( BOOL fFlag ) { s_fZoomOnImport = fFlag; }
00313
00314 static BOOL GetWarnedZoomOnImport() { return s_fWarnedZoomOnImport; }
00315 static void SetWarnedZoomOnImport( BOOL fFlag ) { s_fWarnedZoomOnImport = fFlag; }
00316
00317 protected:
00318
00319 BOOL IsPreviewBitmap;
00320
00321
00322 BOOL ExportBitmap ( Operation *pOp,
00323 CCLexFile *pFile,
00324 PathName *pPath,
00325 Document *pDoc );
00326
00327
00328 BitmapImportOptions* m_pImportOptions;
00329
00330
00331
00332 virtual BOOL PrepareToImport();
00333 virtual void CleanUpAfterImport();
00334
00335
00336 BOOL PrepareBitmapSource();
00337
00338 virtual OFFSET GetDataStartOffset() const;
00339
00340
00341 virtual BitmapImportOptions* GetImportOptions();
00342 virtual BOOL ProcessImportOptions();
00343
00344 virtual BOOL CreateBitmapName(const CCLexFile* pDiskFile, const KernelBitmap* pBitmap,
00345 const UINT32 nBitmapNumber);
00346
00347
00348 UINT32 GetBitmapNumber() const;
00349 BOOL SetLastBitmap();
00350 BOOL SetBitmapNumber(const UINT32 nBitmapToRead);
00351 BOOL AreBitmapsToRead() const;
00352
00353
00354 virtual BOOL IncProgressBarCount(UINT32 n);
00355 void SetTotalProgressBarCount(UINT32 n);
00356
00357
00358 void ForceBackgroundRedrawOff(DocView*);
00359 void RestoreBackgroundRedrawState(DocView*);
00360
00361 void ForceAntialiasingFull(DocView*);
00362 void ForceAntialiasingOff(DocView*);
00363 void RestoreViewQuality(DocView*);
00364
00365
00366
00367
00368 virtual BOOL PrepareToExport(Spread *pSpread, UINT32 Depth, double DPI, SelectionType,
00369 UINT32 Dither = XARADITHER_ORDERED_GREY);
00370 virtual void CleanUpAfterExport();
00371
00372 virtual BOOL DoExportDoc(Operation*, CCLexFile*, PathName*, Document*,
00373 UINT32, double, const SelectionType&, BOOL UseExistingPalette = FALSE);
00374
00375 virtual UINT32 GetNumReservedColours();
00376
00377
00378 virtual BOOL WriteToFile( BOOL End );
00379 virtual BOOL EndWriteToFile( );
00380
00381 virtual BOOL WriteBitmapToFile(KernelBitmap* pKernelBitmap, double Dpi);
00382
00383
00384
00385
00386 virtual BOOL WriteFileHeader(void);
00387 virtual BOOL WritePreFrame(void);
00388 virtual BOOL WritePostOptimisedPalette(void);
00389 virtual BOOL WritePreSecondPass(void);
00390 virtual BOOL WriteFrame(void);
00391 virtual BOOL WritePostFrame(void);
00392 virtual BOOL WriteFileEnd(void);
00393
00394 virtual void AlterPaletteContents( LPLOGPALETTE pPalette );
00395
00396
00397 LPBITMAPINFO GetBitmapInfo() const;
00398 BOOL GetCurrentStripInfo( ADDR* ppBits,
00399 BMP_SIZE* pWidth, BMP_SIZE* pHeight,
00400 BMP_DEPTH* pDepth) const;
00401
00402 CCLexFile* GetExportFile() const;
00403
00404
00405
00406
00407
00408 virtual BOOL SetExportHint(Document* pDoc) { return(TRUE); }
00409
00410
00411
00412 static LPLOGPALETTE Create8bppPalette();
00413
00414 BOOL InsertBitmapOnNewLayer(SelOperation *pOp, Spread * pSpread, NodeBitmap *pNodeBitmap,
00415 Layer ** ppNewLayer);
00416
00417
00418 virtual BOOL AddOffsetFromBitmap(DocCoord * pOffset);
00419
00420
00421 virtual BOOL SetFlagsFromBitmap(Layer * pLayer, KernelBitmap * pBitmap, UINT32 nBitmapToRead);
00422
00423
00424 virtual BOOL SetAnimationPropertiesFromLoaded(Spread * pSpread);
00425
00426
00427 static BOOL WrittenHeader;
00428 BOOL RenderInStrips;
00429 BOOL RenderBottomToTop;
00430 BOOL BadExportRender;
00431 static UINT32 OurNumNodes;
00432
00433
00434 static UINT32 SizeOfExport;
00435 UINT32 GetSizeOfExport() { return SizeOfExport; }
00436 void SetSizeOfExport(UINT32 NewVal) { SizeOfExport = NewVal; }
00437
00438 BMP_SIZE GetPixelWidth() const;
00439 BOOL SetPixelWidth(const BMP_SIZE& Width);
00440 BMP_SIZE GetPixelHeight() const;
00441 BOOL SetPixelHeight(const BMP_SIZE& Height);
00442
00443
00444 UINT32 FilterNameID;
00445 UINT32 FilterInfoID;
00446
00447
00448
00449
00450 UINT32 ExportingMsgID;
00451
00452
00453 CCLexFile* InputFile;
00454
00455
00456 static CCLexFile* OutputFile;
00457
00458
00459 KernelBitmap *pNewBitmap;
00460
00461
00462 static GRenderBitmap *ExportRegion;
00463
00464
00465 BOOL BackgroundRedrawState;
00466 BOOL BackgroundRedrawStateSet;
00467
00468
00469 Quality ViewQuality;
00470 BOOL ViewQualitySet;
00471
00472
00473 static KernelBitmap *pExportBitmap;
00474
00475
00476 DocRect ClipRect;
00477
00478
00479 Spread *pSpread;
00480
00481 UINT32 PaletteType;
00482
00483 UINT32 PreviewDither;
00484 UINT32 PreviewPalette;
00485
00486
00487 static LPLOGPALETTE pOptimisedPalette;
00488 static BOOL WeAreGeneratingOptPalette;
00489
00490 LPLOGPALETTE m_pOptimisedPalette2;
00491 static LPLOGPALETTE m_pBrowserPalette;
00492
00493 void SetDepthToRender(const BMP_DEPTH& Depth) { m_RenderDepth = Depth; }
00494 BMP_DEPTH GetRenderDepth() const { return m_RenderDepth; }
00495 BOOL WarnIfIncompatible();
00496
00497
00498
00499 static BOOL s_fZoomOnImport;
00500 static BOOL s_fWarnedZoomOnImport;
00501
00502 private:
00503
00504 UINT32 m_ProgressBarCount;
00505 UINT32 m_TotalProgressBarCount;
00506 Progress* m_pProgress;
00507 String_64 m_ProgressBarMessage;
00508 INT32 m_nBitmapToRead;
00509
00510 BitmapSource* m_pBitmapSource;
00511 ImagemapFilter* GetImagemapFilter();
00512
00513
00514 static DPI m_DefaultExportDPI;
00515 BitmapExportOptions* m_pExportOptions;
00516
00517 BMP_SIZE m_PixelWidth;
00518 BMP_SIZE m_PixelHeight;
00519 BMP_DEPTH m_RenderDepth;
00520 };
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541 inline INT32 GridLock(INT32 Position, INT32 GridSize)
00542 {
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552 BOOL bNegative = FALSE;
00553
00554 if (Position < 0)
00555 {
00556 bNegative = TRUE;
00557 Position = -Position;
00558 }
00559
00560 Position += GridSize / 2;
00561 Position -= Position % GridSize;
00562
00563 if (bNegative)
00564 Position = -Position;
00565
00566 return (Position);
00567 }
00568
00569 #endif