MakeBitmapFilter Class Reference

Special filter used to convert the selection into a bitmap. More...

#include <makebmp.h>

Inheritance diagram for MakeBitmapFilter:

TI_GIFFilter MaskedFilter BaseBitmapFilter BitmapFilter Filter ListItem CCObject SimpleCCObject GrabFrameFilter List of all members.

Public Member Functions

 MakeBitmapFilter ()
 Constructor for an MakeBitmapFilter object. The object should be initialised before use.
virtual BOOL IsThisBppOk (UINT32 Bpp)
 Check if this Bitmap filter can cope with saving at this Bpp/Colour depth.
virtual UINT32 GetExportMsgID ()
 Used to get the message id to be used during export. Overides the baseclass form of the function so that during the two stage export process it can change the message.
BOOL DoCreateBitmap (Operation *pOp, Document *pDoc, KernelBitmap **ppBitmap)
 Exports the current selection as a bitmap, via the virtual fns of the inherited class.
BOOL InsertBitmapIntoDocument (UndoableOperation *pOp, KernelBitmap *KernelBmp, Document *DestDoc)
 Exports the current selection as a bitmap, via the virtual fns of the inherited class. Cleans up the memory allocated at the end of Exporting or when exporting has been aborted for some reason. Does its cleaning up and then calls the baseclass version to do its stuff, - used when the import process ends, either normally or abnormally. Override if extra things are required. See BaseBitmapFilter for interface detailsUsed to get the message id to be used during export. Overides the baseclass form of the function so that during the two stage export process it can change the message. Physically put the bitmap into the disk. NOTE - ONLY COPES WITH End=TRUE currently Most of the work now is down by WriteDataToFile as this is a static form and there is a similar version in the Accusoft DLL. This can therefore be used to pass work onto the Accusoft DLL, for the cases we don't cope with. End is ignored now and should always be set to TRUE. Cleans up after writing the bitmap data out to a file. Inherited classes override this to write in different file formats. This is slightly different to most other bitmap filters in that it is here that the data actually gets written out to file, after doing the transparency translation, if required. Check if this Bitmap filter can cope with saving at this Bpp/Colour depth. See BaseBitmapFilter for details Notes: Provides a MakeBitmapExportOptions class.

Static Public Member Functions

static BOOL FindCentreInsertionPosition (Spread **Spread, DocCoord *Position)
static BOOL Initialise ()
 Initialise an MakeBitmapFilter object.

Protected Member Functions

virtual BitmapExportOptionsCreateExportOptions () const
 Allows derived classes to override this function to provide their own class derived from BitmapExportInfo containing filter specific information.
virtual BOOL GetExportOptions (BitmapExportOptions *pOptions)
 See BaseBitmapClass for interface details Notes: Initializes GIF specific members Scope: Protected.
virtual void CleanUpAfterExport ()
 Cleans up the memory allocated at the end of Exporting or when exporting has been aborted for some reason. Does its cleaning up and then calls the baseclass version to do its stuff, - used when the import process ends, either normally or abnormally. Override if extra things are required.
virtual BOOL WriteToFile (BOOL End)
 Physically put the bitmap into the disk.
virtual BOOL EndWriteToFile ()
 Cleans up after writing the bitmap data out to a file. Inherited classes override this to write in different file formats. This is slightly different to most other bitmap filters in that it is here that the data actually gets written out to file, after doing the transparency translation, if required.
virtual KernelBitmapGetTheBitmap (BitmapExportOptions *pExportOptions)
 Creates a kernel bitmap from the Export RenderRegion.

Protected Attributes

KernelBitmappTheBitmap

Static Protected Attributes

static FilterType s_FilterType = MAKE_BITMAP_FILTER

Private Member Functions

 CC_DECLARE_DYNAMIC (MakeBitmapFilter)

Detailed Description

Special filter used to convert the selection into a bitmap.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/6/96

Definition at line 185 of file makebmp.h.


Constructor & Destructor Documentation

MakeBitmapFilter::MakeBitmapFilter  ) 
 

Constructor for an MakeBitmapFilter object. The object should be initialised before use.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/6/96
See also:
MakeBitmapFilter::Init

Definition at line 508 of file makebmp.cpp.

00508                                    : TI_GIFFilter ()
00509 {
00510     pTheBitmap = NULL;
00511 }


Member Function Documentation

MakeBitmapFilter::CC_DECLARE_DYNAMIC MakeBitmapFilter   )  [private]
 

virtual void MakeBitmapFilter::CleanUpAfterExport  )  [protected, virtual]
 

Cleans up the memory allocated at the end of Exporting or when exporting has been aborted for some reason. Does its cleaning up and then calls the baseclass version to do its stuff, - used when the import process ends, either normally or abnormally. Override if extra things are required.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/9/95
See also:
BaseBitmapFilter::PrepareToExport(); BaseBitmapFilter::CleanUpAfterExport(); Scope: Protected

Reimplemented from TI_GIFFilter.

virtual BitmapExportOptions* MakeBitmapFilter::CreateExportOptions  )  const [protected, virtual]
 

Allows derived classes to override this function to provide their own class derived from BitmapExportInfo containing filter specific information.

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

Reimplemented from TI_GIFFilter.

BOOL MakeBitmapFilter::DoCreateBitmap Operation pOp,
Document pDoc,
KernelBitmap **  ppBitmap
 

Exports the current selection as a bitmap, via the virtual fns of the inherited class.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/6/96
Returns:
TRUE if worked, FALSE if failed.
See also:
GetExportOptions; PrepareToExport; ExportRenderNodes; CleanUpAfterExport;

Definition at line 552 of file makebmp.cpp.

00553 {
00554     ERROR3IF(ppBitmap == NULL, "NULL bitmap pointer passed to MakeBitmapFilter::DoCreateBitmap");
00555     if (ppBitmap == NULL)
00556         return FALSE;
00557 
00558     pTheBitmap = NULL;
00559     *ppBitmap = NULL;
00560 
00561     // Set the bitmap pointer to null just in case, usually only used by DoExportBitmap
00562     pExportBitmap = NULL;
00563 
00564     // Get pointer to the spread to export.
00565 PORTNOTE("spread", "Multi-spread warning!")
00566     pSpread = GetFirstSpread(pDoc);
00567 
00568     // remember the document in the class variable
00569     TheDocument = pDoc;
00570 
00571     // We must now check if there is a selection present so that we can set up whether the
00572     // user gets the choice of exporting the selection, drawing or spread if there is a 
00573     // selection present OR just a choice between the spread or drawing if no selection is
00574     // present.
00575     // If have a caret selected in a text story then the selection will be almost zero so trap
00576     // this case as well. 
00577     RangeControl rg = GetApplication()->FindSelection()->GetRangeControlFlags();
00578     rg.PromoteToParent = TRUE;
00579     GetApplication()->FindSelection()->Range::SetRangeControl(rg);
00580     SelRange Rng(*(GetApplication()->FindSelection()));
00581 
00582     // now, run through the selection selecting all nodes under all compound nodes
00583     // if we don't do this then all compound nodes aren't rendered correctly with transparent
00584     // bitmaps
00585     Node * pNode = Rng.FindFirst(FALSE);
00586 
00587     while (pNode)
00588     {
00589         pNode->SetSelected(FALSE);
00590         pNode->SetSelected(TRUE);
00591         pNode = Rng.FindNext(pNode, FALSE);
00592     }
00593 
00594     rg.PromoteToParent = FALSE;
00595     GetApplication()->FindSelection()->Range::SetRangeControl(rg);
00596     GetApplication()->UpdateSelection();
00597 
00598     DocRect ClipRect = GetApplication()->FindSelection()->GetBoundingRect();
00599     SelectionType Selection = DRAWING;
00600     if ( ClipRect.IsEmpty() || ClipRect.Width() < MinExportSize ||
00601          ClipRect.Height() < MinExportSize)
00602         Selection = DRAWING;        // no selection present, so choose drawing by default
00603     else
00604         Selection = SELECTION;      // selection present, so choose this by default
00605 
00606     if (Selection != SELECTION)
00607     {
00608         BOOL UseDrawingBounds = TRUE;
00609         
00610         SelRange* pSel = GetApplication()->FindSelection();
00611         if (pSel && pSel->Count()==1)
00612         {
00613             // Only one thing selected ... Is it the Text Caret per chance ?
00614             Node* pSelNode = pSel->FindFirst();
00615             if (pSelNode && pSelNode->IsAVisibleTextNode())
00616             {
00617                 VisibleTextNode* pTextNode = (VisibleTextNode*)pSelNode;
00618                 if (pTextNode->IsACaret())
00619                 {
00620                     // Aha! It's the Caret that's selected.
00621                     // We'll use the bounds of the parent text line instead then ...
00622                     Node* pTextLine = pTextNode->FindParent();
00623                     ERROR3IF(!IS_A(pTextLine, TextLine), "Caret doesn't have a parent text line in DoCreateBitmap");
00624                     
00625                     // Get the bounds of the text line
00626                     ClipRect = ((TextLine*)pTextLine)->GetBoundingRect();               
00627 
00628                     Selection = SELECTION;
00629                     UseDrawingBounds = FALSE;
00630                 }               
00631             }
00632         }
00633 
00634         if (UseDrawingBounds)
00635         {
00636             // Work out the size of the rectangle encompassing the drawing (visible layers only)
00637             ClipRect = GetSizeOfDrawing(pSpread);
00638         }
00639     }
00640 
00641     // Create somewhere to put the user options and fill them up
00642     MakeBitmapExportOptions* pMakeBmpExportOptions = (MakeBitmapExportOptions*)CreateExportOptions();
00643     if (pMakeBmpExportOptions == NULL)
00644     {
00645         Error::SetError(_R(IDS_OUT_OF_MEMORY));
00646         return FALSE;
00647     }
00648 
00649     pMakeBmpExportOptions->RetrieveDefaults();
00650     pMakeBmpExportOptions->SetDepth(32); // create bmp copies shoulda always default to being 32 bit
00651     pMakeBmpExportOptions->SetSelectionType(Selection);
00652 
00653     // Set the BaseBitmapFilter member so we can use base class functionality - blurghh
00654     SetExportOptions(pMakeBmpExportOptions);
00655 
00656     BOOL ok = GetExportOptions( (BitmapExportOptions*)pMakeBmpExportOptions );
00657 
00658     BOOL IsAnimation = BmapPrevDlg::m_pExportOptions == NULL;
00659     BaseBitmapFilter * pNewFilter = this;
00660     BitmapExportOptions * pExportOptions = BmapPrevDlg::m_pExportOptions;
00661     if (!IsAnimation)
00662     {
00663         pNewFilter = pExportOptions->FindBitmapFilterForTheseExportOptions();
00664         // from the exporting point of view we should always have been using png options
00665         // set them to the png options for the export part
00666         if (pNewFilter)
00667             pNewFilter->SetExportOptions(pExportOptions);
00668         // gets the real export options that the prevdlg has set up for us
00669         BmapPrevDlg::m_pExportOptions = NULL; // take responsibility for this data
00670     }
00671     else
00672     {
00673         // the animation export didn't bring up the dlg so never set BmapPrevDlg::m_pExportOptions
00674         // so continue with these options
00675         pExportOptions = (BitmapExportOptions*)pMakeBmpExportOptions;
00676     }
00677 
00678     SetExportOptions(pExportOptions);
00679     
00680 
00681     if (!ok)
00682     {
00683         SetExportOptions(NULL); // deletes the filter ptr and nulls it
00684         delete pExportOptions;
00685         return FALSE;                                   // if cancelled
00686     }
00687 
00688 
00690 
00691     pExportOptions->MarkValid();
00692     SetDepthToRender(pExportOptions->GetDepth());
00693 
00694     // Set up device context and render region for this export.
00695     // This will show a progress hourglass for the objects being rendered
00696     // THis will now also write the data out to file via our ExportRenderNodes function
00697     if (!PrepareToExport(pSpread, pExportOptions->GetDepth(), pExportOptions->GetDPI(), 
00698                             pExportOptions->GetSelectionType(), pExportOptions->GetDither()))
00699     {
00700         pNewFilter->SetExportOptions(NULL);
00701         SetExportOptions(NULL);
00702         delete pExportOptions;
00703         CleanUpAfterExport();
00704         return FALSE;
00705     }
00706 
00707     RenderInStrips = FALSE;
00708     
00709     if (!ExportRender(ExportRegion))
00710     {
00711         pNewFilter->SetExportOptions(NULL); // deletes the filter ptr and nulls it
00712         SetExportOptions(NULL);
00713         delete pExportOptions;
00714         CleanUpAfterExport();
00715         return FALSE;
00716     }
00717 
00718     // Now get the converted 32Bit BMP
00719     pTheBitmap = GetTheBitmap(pExportOptions);
00720 
00721     // if we`ve got a transparency index AND we`ve got a 32 Bit Render region with alpha channel info
00722     // then we can quickly do
00723     if(pExportOptions->GetDepth() <= 8 && pExportOptions->GetTransparencyIndex() != -1 && pTheBitmap)
00724     {
00725         // What we do now is to go throught the bitmap setting the relavent pixels to transparent
00726         // depending on the alpha channel info held in the 32 bit version.
00727         if(!ApplyTransparentColoursToBitmap(pTheBitmap,pExportOptions))
00728         {
00729             pNewFilter->SetExportOptions(NULL); // deletes the filter ptr and nulls it
00730             return FALSE;
00731         }
00732 
00733         // Now make sure the bitmap knows that it has a transparent colour!
00734         pTheBitmap->SetTransparencyIndex(pExportOptions->GetTransparencyIndex());
00735     }
00736 
00737     // Set pointer to the bitmap we have created
00738     *ppBitmap = pTheBitmap;
00739 
00740     pNewFilter->SetExportOptions(NULL); // deletes the filter ptr and nulls it
00741     SetExportOptions(NULL);
00742     delete pExportOptions;
00743     CleanUpAfterExport();
00744 
00745     return *ppBitmap != NULL;
00746 
00748 }

virtual BOOL MakeBitmapFilter::EndWriteToFile void   )  [protected, virtual]
 

Cleans up after writing the bitmap data out to a file. Inherited classes override this to write in different file formats. This is slightly different to most other bitmap filters in that it is here that the data actually gets written out to file, after doing the transparency translation, if required.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/5/95
Parameters:
- [INPUTS]
Returns:
TRUE if worked, FALSE if failed.

Reimplemented from TI_GIFFilter.

static BOOL MakeBitmapFilter::FindCentreInsertionPosition Spread **  Spread,
DocCoord Position
[static]
 

virtual UINT32 MakeBitmapFilter::GetExportMsgID  )  [virtual]
 

Used to get the message id to be used during export. Overides the baseclass form of the function so that during the two stage export process it can change the message.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/09/95
Returns:
The id of the message to put on the progress display whilst exporting.
See also:
DoExport;

Reimplemented from TI_GIFFilter.

Reimplemented in GrabFrameFilter.

virtual BOOL MakeBitmapFilter::GetExportOptions BitmapExportOptions pOptions  )  [protected, virtual]
 

See BaseBitmapClass for interface details Notes: Initializes GIF specific members Scope: Protected.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/10/96

Reimplemented from TI_GIFFilter.

Reimplemented in GrabFrameFilter.

KernelBitmap * MakeBitmapFilter::GetTheBitmap BitmapExportOptions pExportOptions  )  [protected, virtual]
 

Creates a kernel bitmap from the Export RenderRegion.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/6/96
Returns:
Ptr to the bitmap, or NULL if error

Definition at line 760 of file makebmp.cpp.

00761 {
00762     // SMFIX dont use member vars of the class to store stuff like the palette
00763     // take all the info from the export options ptr
00764     OILBitmap* pOilBitmap = ExportRegion->ExtractBitmapCopy ( pExportOptions->GetLogicalPalette(), pDestBMInfo,
00765                                                               pDestBMBytes, pExportOptions->GetTransparencyIndex());
00766     if (pOilBitmap == NULL)
00767     {
00768         CleanUpAfterExport ();
00769         return NULL;
00770     }
00771 
00772     // Err... Lets make sure that the DPI is set up correctly form the options!
00773     LPBITMAPINFOHEADER pInfoHeader = pOilBitmap->GetBitmapInfoHeader();
00774     if(pInfoHeader)
00775     {
00776         INT32 NewPPM = (INT32)((10000.0 * pExportOptions->GetDPI()) / 254.0);
00777         pInfoHeader->biXPelsPerMeter = NewPPM;
00778         pInfoHeader->biYPelsPerMeter = NewPPM;
00779     }
00780 
00781     // Make a kernel bitmap from the oily one
00782     return KernelBitmap::MakeKernelBitmap ( pOilBitmap );
00783 }

BOOL MakeBitmapFilter::Initialise  )  [static]
 

Initialise an MakeBitmapFilter object.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/6/96
Returns:
TRUE if the filter was initialised ok, FALSE otherwise.

Errors: Will fail if not enough memory to initialise.

See also:
EPSStack

Definition at line 525 of file makebmp.cpp.

00526 {
00527     if (!MakeBitmapExportOptions::Declare())
00528         return FALSE;
00529 
00530     if (Camelot.DeclareSection("Filters", 10))
00531     {
00532         Camelot.DeclarePref( NULL, "DoTwoColourRounding", 
00533                              &GRenderOptPalette::DoTwoColourRoundingToPrimary, FALSE, TRUE );
00534     }
00535 
00536     // All ok
00537     return TRUE;
00538 }

BOOL MakeBitmapFilter::InsertBitmapIntoDocument UndoableOperation pOp,
KernelBitmap KernelBmp,
Document DestDoc
 

Exports the current selection as a bitmap, via the virtual fns of the inherited class. Cleans up the memory allocated at the end of Exporting or when exporting has been aborted for some reason. Does its cleaning up and then calls the baseclass version to do its stuff, - used when the import process ends, either normally or abnormally. Override if extra things are required. See BaseBitmapFilter for interface detailsUsed to get the message id to be used during export. Overides the baseclass form of the function so that during the two stage export process it can change the message. Physically put the bitmap into the disk. NOTE - ONLY COPES WITH End=TRUE currently Most of the work now is down by WriteDataToFile as this is a static form and there is a similar version in the Accusoft DLL. This can therefore be used to pass work onto the Accusoft DLL, for the cases we don't cope with. End is ignored now and should always be set to TRUE. Cleans up after writing the bitmap data out to a file. Inherited classes override this to write in different file formats. This is slightly different to most other bitmap filters in that it is here that the data actually gets written out to file, after doing the transparency translation, if required. Check if this Bitmap filter can cope with saving at this Bpp/Colour depth. See BaseBitmapFilter for details Notes: Provides a MakeBitmapExportOptions class.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/6/96
Returns:
TRUE if worked, FALSE if failed.
See also:
GetExportOptions; PrepareToExport; ExportRenderNodes; CleanUpAfterExport;
Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/6/96
See also:
BaseBitmapFilter::PrepareToExport(); BaseBitmapFilter::CleanUpAfterExport(); Scope: Protected
Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/11/96
Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/6/96
Returns:
The id of the message to put on the progress display whilst exporting.
See also:
DoExport;
Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/6/96
Parameters:
End is TRUE if this is the last block of the file. [INPUTS]
Returns:
TRUE if worked, FALSE if errored.
See also:
WriteDataToFile(); AccusoftFilters::WriteToFile; AccusoftFilters::WriteDataToFile;
Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/6/96
Parameters:
- [INPUTS]
Returns:
TRUE if worked, FALSE if failed.
Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/6/96
Parameters:
Bpp or Colour depth. [INPUTS]
Returns:
TRUE if this filter can cope with this colour depth, FALSE otherwise.
See also:
OpConvertToBitmap::DoWithParam;
Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/10/96

Definition at line 797 of file makebmp.cpp.

virtual BOOL MakeBitmapFilter::IsThisBppOk UINT32  Bpp  )  [virtual]
 

Check if this Bitmap filter can cope with saving at this Bpp/Colour depth.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/4/95
Parameters:
Bpp or Colour depth. [INPUTS]
Returns:
TRUE if this filter can cope with this colour depth, FALSE otherwise.
See also:
OpMenuExport::DoWithParam;

Reimplemented from TI_GIFFilter.

virtual BOOL MakeBitmapFilter::WriteToFile BOOL  End  )  [protected, virtual]
 

Physically put the bitmap into the disk.

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com> (From Neville's code.)
Date:
27/6/00 (Originally 24/4/95.)
Returns:
TRUE - The export was successful. FALSE - An error occured.
Most of the work now is down by WriteDataToFile as this is a static form and there is a similar version in the Accusoft DLL. This can therefore be used to pass work onto the Accusoft DLL, for the cases we don't cope with.

This function was originally duplicated in the TI_GIFFilter, and PNG_Filter, but have now been rolled into a single function. This makes maintenance easier, and should reduce code size.

Reimplemented from MaskedFilter.


Member Data Documentation

KernelBitmap* MakeBitmapFilter::pTheBitmap [protected]
 

Definition at line 214 of file makebmp.h.

FilterType MakeBitmapFilter::s_FilterType = MAKE_BITMAP_FILTER [static, protected]
 

Reimplemented from TI_GIFFilter.

Definition at line 215 of file makebmp.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:56:06 2007 for Camelot by  doxygen 1.4.4