BaseBitmapFilter Class Reference

Base class for bitmap filters. (Currently export only). Inherited classes tend to be in the OIL layer. The base class fails on both imports & exports, so you only need to override the half that you implement. More...

#include <bitfilt.h>

Inheritance diagram for BaseBitmapFilter:

BitmapFilter Filter ListItem CCObject SimpleCCObject BasePMFilter BMPFilter JPEGExportFilter JPEGImportFilter MaskedFilter PBMFilter PGMFilter PPMFilter PreviewFilterBMP PreviewFilterJPEG ImageMagickFilter PNGFilter TI_GIFFilter List of all members.

Public Member Functions

 BaseBitmapFilter ()
 Constructor for an BaseBitmapFilter object. The object should be initialised before use. Base class version.
 ~BaseBitmapFilter ()
 Destructor for an BaseBitmapFilter object.
virtual BOOL Init ()
 Declares a preference that allows you to clear memory in delete().
virtual BOOL IsDefaultDocRequired (const TCHAR *pcszPathName)
 Works out if opening a file of this type requires a default document to be loaded. If the file format supplies the document then return FALSE otherwise return TRUE. An example would be opening a bitmap file. This has no document defined in the file format and so we need to laod the default document before importing the bitmap into this file. In this baseclass version return FALSE and hence assume that the filters that need to will override this function to return TRUE.
virtual FilterType GetFilterType () const
BOOL DoImport (SelOperation *Op, CCLexFile *, Document *DestDoc, BOOL AutoChosen=FALSE, ImportPosition *Pos=NULL, KernelBitmap **ppImportedBitmap=NULL, DocCoord *pPosTranslate=NULL, String_256 *=NULL)
 Read bitmap data from a file. This is the same for all bitmap filters; the ImportBitmap() function should be over-ridden for actual bitmap import filters.
virtual BOOL DoExport (Operation *, CCLexFile *, PathName *, Document *, BOOL)
 Exports the current selection as a bitmap, via the virtual fns of the inherited class. Do not override unless really necessary.
virtual BOOL DoExportBitmap (Operation *, CCLexFile *, PathName *, KernelBitmap *)
 Exports the specified bitmap straight out to file with none of the rendering that DoExport does. Uses the virtual fns of the inherited class. Do not override unless really necessary.
virtual BOOL DoExportBitmaps (Operation *, CCLexFile *, PathName *, BitmapExportParam *)
 Exports the bitmaps specified by the BitmapExportParam object to a multi- image capable filter. It works creating a special document containing a single NodeBitmap It then sets this document to use each bitmap in turn and calls DoExport to actually export it.
virtual BOOL DoExportWithOptions (Operation *, CCLexFile *, PathName *, Document *, BitmapExportOptions *, DocRect *=NULL)
 Exports the document by using the export options passed as parameter, rather then invoking an options dialog box to obtain them.
virtual BOOL DoExportBitmapWithOptions (Operation *, CCLexFile *, PathName *, KernelBitmap *, BitmapExportOptions *)
 Exports the specified bitmap straight out to file with none of the rendering that DoExport does. Uses the virtual fns of the inherited class. Do not override unless really necessary. Similar to DoExportBitmap in the base class, but uses the passed options, rather then invoking a dialog to get ones.
virtual BOOL DoExportHelper (Operation *pOp, CCLexFile *pFile, PathName *pPath, Document *pDoc)
 Exports the document by using the export options passed as parameter, rather then invoking an options dialog box to obtain them.
CCLexFileGetImportFile ()
virtual BOOL ImportBitmap (CCLexFile *, KernelBitmap **)
 

BOOL ImportBitmap (CCLexFile *, KernelBitmap **, const UINT32 nBitmapToRead)
 Imports the nBitmapToRead'th bitmap from the given file. This may be used to import a file either via the menu or from the EPS filters.
virtual BOOL ReadFromFile (OILBitmap *pOilBitmap)
 Actually does the process of reading a bitmap from a file. Inherited classes override this to read in different file formats.
virtual BOOL ReadFromFile (OILBitmap *pOilBitmap, BaseCamelotFilter *pFilter, CCLexFile *pFile, BOOL IsCompressed)
 Actually does the process of reading a bitmap from a file. Inherited classes override this to read in different file formats. It is used by the web/native filters to pull out a bitmap definition from inside a bitmap definition record. IsCompressed is only used for BMP/BMPZIP type bitmaps at present. Assumes: pFile has already been opened up for reading pFilter has been set up for reading the data e.g. progress bar.
void SetPreviewBitmap (BOOL)
 Allows you to set the state of this flag. Always set it back to FALSE after the export as the filter hangs around, ready for the next export.
virtual BOOL ExportVisibleLayersOnly ()
 Determines if the filter wants to export only visible layers. In the base bitmap filters class version the default action will be to export only those layers which are visible.
UINT32 GetImportMsgID ()
 Used to get the message id to be used during export. Virtual, so that multi-stage importers can change the message.
virtual UINT32 GetExportMsgID ()
 Used to get the message id to be used during export. Virtual, so that two stage exporters can change the message.
virtual BOOL ShouldReuseExistingBitmaps ()
BOOL SetExportOptions (BitmapExportOptions *pOptions)
 To allow that f!?$g MakeBitmapFilter have its wicked way.
BOOL SetUpExportOptions (BitmapExportOptions **ppExportOptions, BOOL OnlyDefaults=FALSE)
 Displays the export options dialog for this bitmap filter. This allows export options to be obtained by somebody else then the filter.
BOOL SetUpExportBitmapOptions (BitmapExportOptions **ppExportOptions, KernelBitmap *pBitmap, BOOL OnlyDefaults=FALSE)
 Displays the export options dialog for this bitmap filter. This allows export options to be obtained by somebody else then the filter.
virtual BOOL IsSecondPassRequired ()
 Determines if the a second rendering pass is required or not.
virtual BOOL GenerateOptimisedPalette (Spread *pSpread, BitmapExportOptions *pOptions, BOOL SnapToBrowserPalette)
 Generates an optimised palette to use during export.
virtual BOOL GenerateOptimisedPalette (Spread *pSpread, UINT32 Depth, double DPI, BOOL SnapToBrowserPalette, UINT32 NumColsInPalette, BOOL UsePrimaryCols)
 Generates an optimised palette to use during export.
virtual BOOL IsFormatLossy () const
 Provides information to the BaseBitmapFilter so that it knows whether or not to provide a BitmapSource to prevent progressive degradation of the bitmap when exported via the new file format. Notes: Derived classes should override this function for their particular implementation.
virtual BitmapSourceCreateBitmapSource (OFFSET Size) const
 The PrepareToImport() function calls this member to create a BitmapSource for lossy file formats. The BaseBitmapFilter implementation returns NULL. Derived classes with lossy formats should override this function to provide a subclassed BitmapSource.
virtual void ExportHTMLTag (PathName *ppthToUse)
virtual BitmapExportOptionsCreateExportOptions () const
 Allows derived classes to override this function to provide their own class derived from BitmapExportOptions containing filter specific information. Notes: This should never be called.
BitmapExportOptionsGetBitmapExportOptions () const
 Support function to obtain BitmapExportOptions.
virtual BOOL GetExportOptions (BitmapExportOptions *pOptions)
 Allows the user to be prompted to get export information which should be set in the given BitmapExportOptions.
virtual void PostGetExportOptions (BitmapExportOptions *pOptions)
virtual BOOL SetUpClippingRectangleForExport (Spread *pSpread, SelectionType Selection)
 Sets up the class variable ClipRect to be the clipping rectangle to be used during export. See Also: PrepareToExport().
virtual BOOL WriteBitmapToFile (KernelBitmap *pKernelBitmap, BaseCamelotFilter *pFilter, CCLexFile *pFile, INT32 Compression)
virtual BOOL SaveExportBitmapsToFile (CCLexFile *pFile, PathName *pPath, BitmapExportParam *pParam, BOOL DontShowFileName=FALSE)
 Exports the bitmaps specified by the BitmapExportParam object to a multi- image capable filter. Each of the bitmaps will be saved to file using the settings specified. This is the baseclass version and so is usually overriden.
virtual BOOL IsThisBppOk (UINT32 Bpp)
 Check if this Bitmap filter can cope with saving at this Bpp/Colour depth.
virtual BOOL ExportRenderNodes (RenderRegion *pRegion, ExportDC *pDC, BOOL VisibleLayersOnly=FALSE, BOOL CheckSelected=FALSE, BOOL ShowProgress=TRUE)
 Actually export the nodes to the given render region showing a progress bar as we go. Assumes everything has been set up by ExportRender. Overrides the baseclass version so that we can render in strips. Ignores the setting of ShowProgress as we must be in charge of the progress bar in this version.
virtual BOOL GetRenderBottomToTop ()
 Find out which way we need to render.
DocRect GetClipRect () const
BOOL ExportImagemap (Operation *, PathName *, Document *)
virtual BOOL CanDoImportDPI ()
virtual void SetImportDPI (DPI ImportDPI)

Static Public Member Functions

static BOOL InitBaseClass ()
 Initialises any static member variables for the base bitmap filter class.
static BOOL GeneratingOptimisedPalette ()
 Find out if we are currently generating an optimised palette or not.
static KernelBitmapGetExportBitmap ()
static DocRect GetSizeOfDrawing (Spread *pSpread=NULL)
 Works out the size of the rectangle encompassing the drawing. Code also used to work out the pixel size in the bitmap export options dialog box.
static DocRect GetSizeOfSpread (Spread *pSpread)
 Works out the size of the rectangle encompassing the spread. Code also used to work out the pixel size in the bitmap export options dialog box.
static BOOL GetSizeOfBitmap (INT32 *PixelWidth, INT32 *PixelHeight)
 Works out the size of the bitmap in the bitmap export options dialog box.
static void CallPixelAlignedFiddle (DocRect *r)
static BOOL GetZoomOnImport ()
static void SetZoomOnImport (BOOL fFlag)
static BOOL GetWarnedZoomOnImport ()
static void SetWarnedZoomOnImport (BOOL fFlag)

Static Public Attributes

static const INT32 MinPelsPerMeter = 1000
static const INT32 MinExportSize = 10
static INT32 m_NumberOfPaletteEntries = 0

Protected Member Functions

BOOL ExportBitmap (Operation *pOp, CCLexFile *pFile, PathName *pPath, Document *pDoc)
virtual BOOL PrepareToImport ()
 Prepare to import bitmap data using this filter. This sets up the filter to a sensible state for reading.
virtual void CleanUpAfterImport ()
 Cleans up the memory allocated by BaseBitmapFilter::PrepareToImport() - used when the import process ends, either normally or abnormally.
BOOL PrepareBitmapSource ()
 The PrepareToImport() function calls this member to create a BitmapSource for lossy file formats, and a CCLexFile to work with it.
virtual OFFSET GetDataStartOffset () const
 Provides information to the BaseBitmapFilter, so that it knows where to start any required BitmapSource. It will only be useful to derived classes that deal with a lossy file format. Notes: The default implementation returns zero, assuming there is no useless garbage before any actual header. Derived classes should override this for any special case.
virtual BitmapImportOptionsGetImportOptions ()
 To allow a filter to offer the user a choice over what gets imported. Derived BaseBitmapFilter classes should also derive a new BitmapImportOptions class and return a new copy on the heap with the user options in it. BaseBitmapFilter will delete the BitmapImportOptions class when no longer needed. At present used by PhotoCD filter to get image to import.
virtual BOOL ProcessImportOptions ()
 Validates the options returned by GetImportOptions Sets m_pImportOptions if OK Shouldn't really be overridden.
virtual BOOL CreateBitmapName (const CCLexFile *pDiskFile, const KernelBitmap *pBitmap, const UINT32 nBitmapNumber)
 Sets the name of the given bitmap to that of the form "filename - number.ext" or "filename.ext" depending on whether we have assumed there to be more than one image in the imported file. Used by ImportBitmap to supply this name and avoid bizarre file names when re-exporting.
UINT32 GetBitmapNumber () const
 On entry to the filter this member function returns the number of the desired bitmap in the file. Once the import is complete, either SetBitmapNumber is called with an argument of the next bitmap that can be read or SetLastBitmap is called indicating there are no more to read. Scope: protected.
BOOL SetLastBitmap ()
 When the bitmap filter has no more bitmaps to read from its file it should call this member function. Scope: protected.
BOOL SetBitmapNumber (const UINT32 nBitmapToRead)
 Once a filter has read a bitmap it should call this member function with the number of the next bitmap that can be read. If there are none, SetLastBitmap() should be called instead. Scope: protected.
BOOL AreBitmapsToRead () const
 The BaseBitmapFilter uses this to determine whether or not it should try to read another bitmap from the file. Scope: protected.
virtual BOOL IncProgressBarCount (UINT32 n)
 Func to incrementing the progress bar count. If there is a progress bar available, it is updated by this call. Scope: Protected.
void SetTotalProgressBarCount (UINT32 n)
 Func to set total the progress bar count. If there is a progress bar available, it is updated by this call. Scope: Protected.
void ForceBackgroundRedrawOff (DocView *)
 Forces background redraw off in the specified view, so we render all the objects in one pass. Use RestoreBackgroundRedrawState to restore the state.
void RestoreBackgroundRedrawState (DocView *)
 Restores the background redraw state in the specified view, to the state before we called BaseBitmapFilter::ForceBackgroundRedrawOff.
void ForceAntialiasingFull (DocView *)
 Forces Antialiasing to be full in the specified view. Use RestoreViewQuality to restore the quality. Used when generating preview bitmaps, which should always be in full anti- aliasing mode.
void ForceAntialiasingOff (DocView *)
 Forces Antialiasing off in the specified view. Use RestoreViewQuality to restore the quality.
void RestoreViewQuality (DocView *)
 Restores the view quality to the state before we called ForceAntialiasingOff.
virtual BOOL PrepareToExport (Spread *pSpread, UINT32 Depth, double DPI, SelectionType, UINT32 Dither=XARADITHER_ORDERED_GREY)
virtual void CleanUpAfterExport ()
 Cleans up the memory allocated by BaseBitmapFilter::PrepareToImport() - used when the import process ends, either normally or abnormally. Override if extra things are required.
virtual BOOL DoExportDoc (Operation *, CCLexFile *, PathName *, Document *, UINT32, double, const SelectionType &, BOOL UseExistingPalette=FALSE)
virtual UINT32 GetNumReservedColours ()
 Override this to leave spaces in the palette. eg the GIF filter reserves an index for the transparency mask colour.
virtual BOOL WriteToFile (BOOL End)
 Writes out the bitmap to a file. Inherited classes override this to write in different file formats. AtEnd is ignored now and should always be set to TRUE.
virtual BOOL EndWriteToFile ()
 Cleans up after writing the bitmap data out to a file. Inherited classes override this to write in different file formats.
virtual BOOL WriteBitmapToFile (KernelBitmap *pKernelBitmap, double Dpi)
 Physically put the bitmap into the disk. Inherited classes override this to write in different file formats.
virtual BOOL WriteFileHeader (void)
 To write out the file specific header data.
virtual BOOL WritePreFrame (void)
 To write out any frame specific info before the image.
virtual BOOL WritePostOptimisedPalette (void)
 Called after the optimised palette has been generated but before the export of the bitmap.
virtual BOOL WritePreSecondPass (void)
 Called before the second pass of a two pass export so the filter can reset itself.
virtual BOOL WriteFrame (void)
 To write out the image itself This base class version actually calls the WriteToFile() function so that derived classes do not have to implement any of the multi-image stuff.
virtual BOOL WritePostFrame (void)
 To write out any frame specific info after the image.
virtual BOOL WriteFileEnd (void)
 To write out the file specific data at the end of the file This base class version calls EndWriteToFile() so that derived classes do not have to implement the multi-image stuff.
virtual void AlterPaletteContents (LPLOGPALETTE pPalette)
LPBITMAPINFO GetBitmapInfo () const
BOOL GetCurrentStripInfo (ADDR *ppBits, BMP_SIZE *pWidth, BMP_SIZE *pHeight, BMP_DEPTH *pDepth) const
CCLexFileGetExportFile () const
 Support function to obtain file to export in WriteBitmapToFile.
virtual BOOL SetExportHint (Document *pDoc)
BOOL InsertBitmapOnNewLayer (SelOperation *pOp, Spread *pSpread, NodeBitmap *pNodeBitmap, Layer **ppNewLayer)
 When loading in multiple bitmaps then each bitmap should be inserted onto a new layer. The first bitmap is inserted as the last child on the active layer. Each subsequent bitmap is loaded onto a new layer after this. The routine returns the new layer so that this can be used next time as the insertion point.
virtual BOOL AddOffsetFromBitmap (DocCoord *pOffset)
 When loading in a bitmap, the bitmap definition may contain an offset. We need to add this to the offset that we are given so that the bitmap is loaded at the correct position. This baseclass version does nothing.
virtual BOOL SetFlagsFromBitmap (Layer *pLayer, KernelBitmap *pBitmap, UINT32 nBitmapToRead)
 When loading in multiple bitmaps and placing them on new layers, we should give the filter an opportunity to set the layer flags from the bitmap. In the case of a GIF filter this would allow it to set the solid and overlay flags. This baseclass version does nothing.
virtual BOOL SetAnimationPropertiesFromLoaded (Spread *pSpread)
 When loading in multiple bitmaps and placing them on new layers, we should give the filter an opportunity after all the bitmaps have been loaded, to go and look at the bitmaps and set the animation properties accordingly. In the case of a GIF filter this would allow it to set the dithering to none and the palette to something closer to what has been loaded. This baseclass version does nothing.
UINT32 GetSizeOfExport ()
void SetSizeOfExport (UINT32 NewVal)
BMP_SIZE GetPixelWidth () const
 Support function to obtain bitmap info.
BOOL SetPixelWidth (const BMP_SIZE &Width)
 Support function to obtain bitmap info See Also: GetExportHeight().
BMP_SIZE GetPixelHeight () const
 Support function to obtain bitmap info.
BOOL SetPixelHeight (const BMP_SIZE &Height)
 Support function to obtain bitmap info See Also: GetExportHeight().
void SetDepthToRender (const BMP_DEPTH &Depth)
BMP_DEPTH GetRenderDepth () const
BOOL WarnIfIncompatible ()
 Checks for things that can't be represented using the current options E.g. non-mix transparencies in Alpha channel bitmap.

Static Protected Member Functions

static LPLOGPALETTE Create8bppPalette ()
 Creates an 8bpp palette used when generating an 8bpp bitmap Centralises common code previously found in BMP, GIF & PNG filters.

Protected Attributes

BOOL IsPreviewBitmap
BitmapImportOptionsm_pImportOptions
BOOL RenderInStrips
BOOL RenderBottomToTop
BOOL BadExportRender
UINT32 FilterNameID
UINT32 FilterInfoID
UINT32 ExportingMsgID
CCLexFileInputFile
KernelBitmappNewBitmap
BOOL BackgroundRedrawState
BOOL BackgroundRedrawStateSet
Quality ViewQuality
BOOL ViewQualitySet
DocRect ClipRect
SpreadpSpread
UINT32 PaletteType
UINT32 PreviewDither
UINT32 PreviewPalette
LPLOGPALETTE m_pOptimisedPalette2

Static Protected Attributes

static BOOL WrittenHeader = FALSE
static UINT32 OurNumNodes = 0
static UINT32 SizeOfExport = 100
static CCLexFileOutputFile = NULL
static GRenderBitmapExportRegion = NULL
static KernelBitmappExportBitmap = NULL
static LPLOGPALETTE pOptimisedPalette = NULL
static BOOL WeAreGeneratingOptPalette = FALSE
static LPLOGPALETTE m_pBrowserPalette = NULL
static BOOL s_fZoomOnImport = 9999
static BOOL s_fWarnedZoomOnImport = 9999

Private Member Functions

 CC_DECLARE_DYNAMIC (BaseBitmapFilter)
ImagemapFilterGetImagemapFilter ()
 Gets a pointer to the imagemap filter.

Private Attributes

UINT32 m_ProgressBarCount
UINT32 m_TotalProgressBarCount
Progressm_pProgress
String_64 m_ProgressBarMessage
INT32 m_nBitmapToRead
BitmapSourcem_pBitmapSource
BitmapExportOptionsm_pExportOptions
BMP_SIZE m_PixelWidth
BMP_SIZE m_PixelHeight
BMP_DEPTH m_RenderDepth

Static Private Attributes

static DPI m_DefaultExportDPI = 96.0

Detailed Description

Base class for bitmap filters. (Currently export only). Inherited classes tend to be in the OIL layer. The base class fails on both imports & exports, so you only need to override the half that you implement.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/8/94

Definition at line 164 of file bitfilt.h.


Constructor & Destructor Documentation

BaseBitmapFilter::BaseBitmapFilter  ) 
 

Constructor for an BaseBitmapFilter object. The object should be initialised before use. Base class version.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/6/94
See also:
BaseBitmapFilter::Init

Definition at line 219 of file bitfilt.cpp.

00220 {
00221     OutputFile = NULL;
00222     ExportRegion = NULL;
00223     pNewBitmap = NULL;
00224     InputFile = NULL;
00225     BackgroundRedrawState = FALSE;
00226     BackgroundRedrawStateSet = FALSE;
00227     ViewQualitySet = FALSE;
00228     IsPreviewBitmap = FALSE;
00229     pExportBitmap = NULL;
00230     pSpread = NULL;
00231     m_pImportOptions    = NULL;
00232     m_pExportOptions    = NULL;
00233     pOptimisedPalette = NULL;
00234 
00235     WrittenHeader       = FALSE;// Have we done the first strip yet
00236     RenderInStrips  = TRUE; // Should we render in strips or not
00237     RenderBottomToTop = TRUE;   // control over which way we render
00238     BadExportRender = FALSE;// whether the export rendering has gone ok or not
00239     
00240     SizeOfExport        = 100;  // defined progress bar size.
00241     OurNumNodes     = 0;    // our copy of the number of nodes being exported
00242 
00243     PaletteType     = PAL_OPTIMISED;
00244 
00245     //Should these lines be in or out - Martin 14/04/97
00246     PreviewDither   = XARADITHER_ERROR_DIFFUSION;
00247     PreviewPalette  = PAL_OPTIMISED;
00248                
00249     WeAreGeneratingOptPalette = FALSE;
00250     ClipRect.MakeEmpty();
00251 
00252     m_pOptimisedPalette2 = NULL;
00253     m_pExportOptions = NULL;
00254 }

BaseBitmapFilter::~BaseBitmapFilter  ) 
 

Destructor for an BaseBitmapFilter object.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/6/94

Definition at line 268 of file bitfilt.cpp.

00269 {
00270     //  Clear up some dynamically allocated memory
00271     if (m_pOptimisedPalette2)
00272     {
00273         CCFree(m_pOptimisedPalette2);
00274         m_pOptimisedPalette2 = 0;
00275     }
00276 
00277     if (m_pBrowserPalette)
00278     {
00279         CCFree(m_pBrowserPalette);
00280         m_pBrowserPalette = 0;
00281     }
00282 
00283     delete m_pImportOptions;
00284     m_pImportOptions = 0;
00285 
00286 //  delete m_pExportOptions;
00287     m_pExportOptions = 0;
00288 }


Member Function Documentation

BOOL BaseBitmapFilter::AddOffsetFromBitmap DocCoord pOffset  )  [protected, virtual]
 

When loading in a bitmap, the bitmap definition may contain an offset. We need to add this to the offset that we are given so that the bitmap is loaded at the correct position. This baseclass version does nothing.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/5/97
Parameters:
pOffset the present offset in the bitmap [INPUTS]
Returns:
TRUE if was ok, FALSE otherwise.

Reimplemented in TI_GIFFilter.

Definition at line 1246 of file bitfilt.cpp.

01247 {
01248     // Do nothing
01249     return TRUE;
01250 }

void BaseBitmapFilter::AlterPaletteContents LPLOGPALETTE  pPalette  )  [protected, virtual]
 

Reimplemented in BMPFilter, TI_GIFFilter, ImageMagickFilter, and PNGFilter.

Definition at line 4500 of file bitfilt.cpp.

04501 {
04502     return;
04503 }

BOOL BaseBitmapFilter::AreBitmapsToRead  )  const [protected]
 

The BaseBitmapFilter uses this to determine whether or not it should try to read another bitmap from the file. Scope: protected.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/06/96
Parameters:
- [INPUTS]
Returns:
TRUE if there are bitmaps in the set OK FALSE otherwise
See also:
GetBitmapNumber(), SetBitmapNumber(), SetLastBitmap()

Definition at line 1634 of file bitfilt.cpp.

01635 {
01636     return (m_nBitmapToRead != -1);
01637 }

void BaseBitmapFilter::CallPixelAlignedFiddle DocRect r  )  [static]
 

Definition at line 5180 of file bitfilt.cpp.

05181 {
05182     PixelAlignedFiddle( r );
05183 }

virtual BOOL BaseBitmapFilter::CanDoImportDPI  )  [inline, virtual]
 

Reimplemented in ImageMagickFilter.

Definition at line 308 of file bitfilt.h.

00308 { return FALSE; }

BaseBitmapFilter::CC_DECLARE_DYNAMIC BaseBitmapFilter   )  [private]
 

void BaseBitmapFilter::CleanUpAfterExport  )  [protected, virtual]
 

Cleans up the memory allocated by BaseBitmapFilter::PrepareToImport() - used when the import process ends, either normally or abnormally. Override if extra things are required.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/6/94
See also:
BaseBitmapFilter::PrepareToImport; BaseBitmapFilter::DoImport Scope: Private

Reimplemented in JPEGExportFilter, MakeBitmapFilter, BMPFilter, TI_GIFFilter, ImageMagickFilter, and PNGFilter.

Definition at line 2342 of file bitfilt.cpp.

02343 {
02344 #ifdef DO_EXPORT
02345     // Get rid of our dynamic objects
02346     if (OutputFile)
02347     {
02348         OutputFile = NULL;
02349     }
02350 
02351     DocView *View = DocView::GetCurrent();
02352     if (View)
02353     {
02354         if( ViewQualitySet )
02355         {
02356             //  Only need to do this if the view quality has been set but not restored.
02357             RestoreViewQuality(View);
02358         }
02359     }
02360 
02361     if (ExportRegion)
02362     {
02363         // If we have create the export region then delete it
02364         delete ExportRegion;
02365         ExportRegion = NULL;
02366 
02367         // Must try and set our background rendering state back to the default 
02368         DocView *View = DocView::GetCurrent();
02369         if (View)
02370         {
02371             // Force background back to its entry state
02372             RestoreBackgroundRedrawState(View);
02373         }
02374     }
02375 
02376     if (pOptimisedPalette)
02377     {
02378         CCFree( pOptimisedPalette );
02379         pOptimisedPalette = NULL;
02380     }
02381 
02382 #endif
02383 }

void BaseBitmapFilter::CleanUpAfterImport  )  [protected, virtual]
 

Cleans up the memory allocated by BaseBitmapFilter::PrepareToImport() - used when the import process ends, either normally or abnormally.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/6/94
See also:
BaseBitmapFilter::PrepareToImport; BaseBitmapFilter::DoImport Scope: Private

Definition at line 579 of file bitfilt.cpp.

00580 {
00581     TheDocument = NULL;
00582     
00583     //WEBSTER-Martin-02/01/97
00584 #ifndef WEBSTER
00585 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00586     // Reset the filter type used by the Accusoft filters so that it can cache the
00587     // filter type correctly and so only call the Accusoft DLL on the first filter
00588     // rather than on all filters. 
00589 
00590     AccusoftFilters::ResetFilterType();
00591 
00592 #endif
00593 #endif //WEBSTER
00594 }

LPLOGPALETTE BaseBitmapFilter::Create8bppPalette  )  [static, protected]
 

Creates an 8bpp palette used when generating an 8bpp bitmap Centralises common code previously found in BMP, GIF & PNG filters.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/2/97
Returns:
A pointer to a 8bpp palette
The palette returned is created using CCMalloc(). The caller should use CCFree() to discard the returned palette object when no longer needed.

Introduced for WEBSTER - markn 8/2/97. Made static so that the Accusoft filter can use it Notes:

Definition at line 4826 of file bitfilt.cpp.

04827 {
04828     /*
04829     LPLOGPALETTE lpPalette = NULL;
04830     GDrawContext *GDC = GRenderRegion::GetDrawContext();
04831     if (GDC != NULL)
04832     {
04833         // This should return a palette plus tell it what dithering we require
04834         // 0 = dither, not 0 for no dithering.
04835         LPLOGPALETTE lpGavPalette = GDC->SelectPalette( 0 );
04836 
04837         if (lpGavPalette != NULL)
04838         {
04839             const size_t TotalPal = sizeof(LOGPALETTE) + ( sizeof(PALETTEENTRY) * 256 );
04840             lpPalette = (LPLOGPALETTE)CCMalloc( TotalPal );
04841             if (lpPalette != NULL)
04842             {
04843                 // Take a copy of that palette
04844                 memcpy( lpPalette, lpGavPalette, TotalPal );
04845 
04846                 // Always make 'browser' palette instead of 'standard' palette
04847                 // - Harrison 8/10/97
04848                 PaletteManager::MakePaletteBrowserCompatible(lpPalette,TRUE);
04849             }
04850         }
04851     }
04852 
04853     ERROR3IF(lpPalette == NULL, "Didnt get a palette");
04854 
04855     //  The section of code below is used when the user has deleted 1 or more colours, and then
04856     //  clicked on 'Preview'.
04857     //  Have to change the palette here before it is used to decide which palette colours
04858     //  match each pixel in the image.
04859     if( ( BmapPrevDlg::GetNumberOfDeletedColours() ) && ( BmapPrevDlg::m_bUseExistingPalette ) )
04860     {
04861         BOOL Deleted = FALSE;
04862         INT32 NewIndex = -1;
04863         INT32 Popularity = 0;
04864 
04865         //  Go through the palette in BmapPrevDlg.
04866         for( INT32 PaletteIndex = 0; PaletteIndex < ( lpPalette->palNumEntries ); PaletteIndex++ )
04867         {
04868             //  Has this colour been deleted by the user?
04869             Deleted = BmapPrevDlg::IsThisColourDeleted( PaletteIndex );
04870             if( Deleted )
04871             {
04872                 //  If this colour has been deleted, then we need to get its
04873                 //  original palette order.
04874                 NewIndex = BmapPrevDlg::GetOriginalPaletteOrder( PaletteIndex );
04875                 //  Set flags to 255 to tell the system that this colour is not
04876                 //  to be used in generating the exported image.
04877                 lpPalette->palPalEntry[NewIndex].peFlags = 255;
04878             }
04879             else
04880             {
04881                 //  Not deleted, but is the popularity of this colour = 0?
04882                 Popularity = BmapPrevDlg::GetPopularityValueForColour( PaletteIndex );
04883                 if( Popularity <= 0 )
04884                 {
04885                     NewIndex = BmapPrevDlg::GetOriginalPaletteOrder( PaletteIndex );
04886                     lpPalette->palPalEntry[NewIndex].peFlags = 255;
04887                 }
04888             }
04889         }
04890     }
04891 
04892     ExtendedPalette LockedColoursInformation;
04893     if( BmapPrevDlg::GotLockedColours() && lpPalette)
04894     {
04895         //  Copy all the locked colours information over.
04896         LockedColoursInformation = BmapPrevDlg::m_LockedColoursPalette;
04897         
04898         ExtendedPalette LockedColoursInformation2 = BmapPrevDlg::m_LockedColoursPalette2;
04899 
04900         //  Go through all the locked colours that we have
04901         for( INT32 i = 0; i < LockedColoursInformation.NumberOfColours; i++ )
04902         {
04903             //  Make sure that we are not exceeding the number of colours in the current palette.
04904             if( i >= ( lpPalette->palNumEntries ) )
04905                 continue;
04906 
04907             //  We want to find the nearest colour in the current palette to this locked colour.
04908             double SmallestDistance = 0.0;
04909             BOOL FirstDistanceCalc = TRUE;
04910             INT32 ClosestColourIndex = 0;
04911 
04912             //  Some variables needed below
04913             INT32 Red1, Green1, Blue1;
04914             INT32 Red2, Green2, Blue2;
04915             double RedDistance, GreenDistance, BlueDistance;
04916             double Distance;            
04917 
04918             INT32 LockedIndex = LockedColoursInformation.Data[ i ].ExtraInformation;
04919             Red1    = LockedColoursInformation2.Data[ LockedIndex ].Red;
04920             Green1  = LockedColoursInformation2.Data[ LockedIndex ].Green;
04921             Blue1   = LockedColoursInformation2.Data[ LockedIndex ].Blue;
04922 
04923             //  Go through all the colours in the current palette.
04924             for( INT32 j = 0; j < lpPalette->palNumEntries; j++ )
04925             {
04926                 //  The components of the palette colour we are looking at.
04927                 Red2    = lpPalette->palPalEntry[j].peRed;
04928                 Green2  = lpPalette->palPalEntry[j].peGreen;
04929                 Blue2   = lpPalette->palPalEntry[j].peBlue;
04930 
04931                 //  Calculate the distance between each of the colour components
04932                 //  ( Actually the square of this value - this does not matter since we
04933                 //  are not interested in the absolute values, only relative ones ).
04934                 RedDistance   = pow( double( Red1 - Red2 ), 2 );
04935                 GreenDistance = pow( double( Green1 - Green2 ), 2 );
04936                 BlueDistance  = pow( double( Blue1 - Blue2 ), 2 );
04937 
04938                 //  The overall distance.
04939                 Distance = ( INT32 )( RedDistance + GreenDistance + BlueDistance );
04940 
04941                 if( FirstDistanceCalc )
04942                 {
04943                     // First time around, so 'Distance' must be closest yet
04944                     // However, there may be an occasion where this colour is already being used by one of 
04945                     // the existing locked colours. In this case, we just want to completely ignore this
04946                     // colour, and carry on with the next loop
04947                     BOOL BeingUsed = FALSE;
04948                     for( INT32 Index = 0; Index < i; Index++ )
04949                     {
04950                         if( LockedColoursInformation.Data[ Index ].ExtraInformation == j )
04951                             BeingUsed = TRUE;
04952                     }
04953                     //  If it is being used, don't do anything.
04954                     if( !BeingUsed )
04955                     {
04956                         FirstDistanceCalc   = FALSE;
04957                         SmallestDistance    = Distance;
04958                         ClosestColourIndex  = j;
04959                     }
04960                 }
04961                 else if( Distance <= SmallestDistance )
04962                 {
04963                     //  Smallest distance so far?  if so remember the distance & index
04964                     //  Do this only if this index is not being used by another locked colour
04965                     //  already. To do this, have to look through the currently assigned locked
04966                     //  colour indices. If this index is being used, then just do nothing.
04967                     BOOL BeingUsed = FALSE;
04968                     for( INT32 Index = 0; Index < i; Index++ )
04969                     {
04970                         if( LockedColoursInformation.Data[ Index ].ExtraInformation == j )
04971                             BeingUsed = TRUE;
04972                     }
04973                     if( !BeingUsed )
04974                     {
04975                         SmallestDistance    = Distance;
04976                         ClosestColourIndex  = j;
04977                     }
04978                 }
04979             }
04980 
04981             //  Put the colour index into the locked colour palette
04982             INT32 Information = LockedColoursInformation.Data[ i ].ExtraInformation;
04983 
04984             //  Update the palette which holds the original values of the locked colours.
04985             INT32 r = BmapPrevDlg::m_LockedColoursPalette2.Data[ ClosestColourIndex ].Red;
04986             INT32 g = BmapPrevDlg::m_LockedColoursPalette2.Data[ ClosestColourIndex ].Green;
04987             INT32 b = BmapPrevDlg::m_LockedColoursPalette2.Data[ ClosestColourIndex ].Blue;
04988 
04989             BmapPrevDlg::m_LockedColoursPalette2.Data[ ClosestColourIndex ].Red = 
04990                 BmapPrevDlg::m_LockedColoursPalette2.Data[ Information ].Red;
04991             BmapPrevDlg::m_LockedColoursPalette2.Data[ ClosestColourIndex ].Green = 
04992                 BmapPrevDlg::m_LockedColoursPalette2.Data[ Information ].Green;
04993             BmapPrevDlg::m_LockedColoursPalette2.Data[ ClosestColourIndex ].Blue = 
04994                 BmapPrevDlg::m_LockedColoursPalette2.Data[ Information ].Blue;
04995 
04996             BmapPrevDlg::m_LockedColoursPalette2.Data[ Information ].Red = r;
04997             BmapPrevDlg::m_LockedColoursPalette2.Data[ Information ].Green = g;
04998             BmapPrevDlg::m_LockedColoursPalette2.Data[ Information ].Blue = b;
04999 
05000             BmapPrevDlg::m_LockedColoursPalette.Data[ i ].ExtraInformation = ClosestColourIndex;
05001             LockedColoursInformation = BmapPrevDlg::m_LockedColoursPalette;
05002         }
05003     }
05004 
05005     return lpPalette;
05006     */
05007     return NULL;
05008 }

BOOL BaseBitmapFilter::CreateBitmapName const CCLexFile pDiskFile,
const KernelBitmap pBitmap,
const UINT32  nBitmapNumber
[protected, virtual]
 

Sets the name of the given bitmap to that of the form "filename - number.ext" or "filename.ext" depending on whether we have assumed there to be more than one image in the imported file. Used by ImportBitmap to supply this name and avoid bizarre file names when re-exporting.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/06/96
Parameters:
pDiskFile : file from which the bitmap was extracted [INPUTS] pBitmap : the bitmap itself nBitmapNumber : the number of the bitmap in the file
- [OUTPUTS]
Returns:
TRUE if name set OK, FALSE if failed.

Errors: ERROR2 for invalid arguments ERROR3 if pDiskFile is not a kind of CCDiskFile Notes: Suppose we should really set the names after when we know that there actually are multiple bitmaps

Definition at line 1469 of file bitfilt.cpp.

01471 {
01472     ERROR2IF(pDiskFile == NULL, FALSE, "pDiskFile - invalid");
01473     ERROR2IF(pBitmap == NULL, FALSE, "pBitmap - invalid");
01474 
01475     PathName Path = pDiskFile->GetPathName();
01476     if (!Path.IsValid())
01477     {
01478         TRACE( _T("Invalid file path in BaseBitmapFilter::CreateBitmapName\n") );
01479         return FALSE;
01480     }
01481 
01482     String_256 Str;
01483     if ((nBitmapNumber > 1) || AreBitmapsToRead())
01484     {
01485         // give it a number ?
01486         String_256 shortName = Path.GetFileName(FALSE); // without extension
01487         String_16 index;
01488         Convert::LongToString(INT32(nBitmapNumber), &index);
01489         Str.MakeMsg(_R(IDS_BITMAP_NAME), (TCHAR*)shortName, (TCHAR*)index);
01490         Path.SetFileName(Str);
01491     }
01492     Str = Path.GetFileName(TRUE);   // with extension
01493     pBitmap->ActualBitmap->SetName(Str);
01494     return TRUE;
01495 }

BitmapSource * BaseBitmapFilter::CreateBitmapSource OFFSET  Size  )  const [virtual]
 

The PrepareToImport() function calls this member to create a BitmapSource for lossy file formats. The BaseBitmapFilter implementation returns NULL. Derived classes with lossy formats should override this function to provide a subclassed BitmapSource.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/08/96
Parameters:
Size,: The required size of the BitmapSource [INPUTS]
Returns:
A pointer to a new BitmapSource
See also:
IsFormatLossy() Scope: protected

Reimplemented in JPEGImportFilter.

Definition at line 464 of file bitfilt.cpp.

00465 {
00466     return NULL;
00467 }

BitmapExportOptions * BaseBitmapFilter::CreateExportOptions  )  const [virtual]
 

Allows derived classes to override this function to provide their own class derived from BitmapExportOptions containing filter specific information. Notes: This should never be called.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/10/96
Returns:
A pointer to a new BitmapExportOptions class

Reimplemented in JPEGExportFilter, MakeBitmapFilter, BMPFilter, TI_GIFFilter, ImageMagickFilter, and PNGFilter.

Definition at line 4797 of file bitfilt.cpp.

04798 {
04799     TRACE( _T("BaseBitmapFilter::CreateExportOptions() called\n"));
04800 
04801     BitmapExportOptions* pOptions = new BitmapExportOptions(_R(IDD_EXPORTBMPOPTS), FilterType(FilterID), &FilterName);