#include <frameops.h>
Inheritance diagram for GrabFrameFilter:
Public Types | |
enum | GRABMODE { GRABMODE_PREVIEW, GRABMODE_FOROUTPUT } |
Public Member Functions | |
GrabFrameFilter () | |
Constructor for an GrabFrameFilter object. The object should be initialised before use. | |
~GrabFrameFilter () | |
Destructor for an GrabFrameFilter object. | |
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. | |
virtual BOOL | ExportSelectionOnly (BOOL MaskedRender=FALSE) |
Determines if the filter wants to export only selected items. In the base bitmap filters class version the default action will be to export all objects by default. | |
virtual BOOL | IsSecondPassRequired () |
Determines if the a second rendering pass is required or not. | |
virtual BOOL | DoExportBitmaps (Operation *pOp, CCLexFile *pFile, PathName *pPath, BitmapExportParam *pParam, BOOL DontShowFileName=FALSE) |
Exports the bitmaps specified by the BitmapExportParam object to a multi- image capable filter. | |
virtual BOOL | GenerateOptimisedPalette (Spread *pSpread, UINT32 Depth, double DPI, BOOL SnapToBrowserPalette, UINT32 NumColsInPalette, BOOL UsePrimaryCols) |
Generates an optimised palette to use during export We override the baseclass form so that we generate one optimised palette for all frames if we are in global optimised mode. Otherwise, we can just call the base class version. | |
Layer * | GetLayerBeingCaptured () |
BOOL | SetLayerBeingCaptured (Layer *pNewLayer) |
This remembers the layer that is being captured. It sets the member variable up to the specified layer. | |
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 | SetupExportOptions (BitmapExportOptions *pOptions, Spread *pCurrentSpread) |
This is just a public interface on the normal filter's GetExportOptions which is protected. It also ensures that the pSpread is set up. | |
virtual MakeBitmapExportOptions * | MakeExportOptions () |
virtual MakeBitmapExportOptions * | GetCurrentExportOptions () |
virtual MakeBitmapExportOptions * | GetCurrentExportOptionsCopy () |
LPLOGPALETTE | GetGlobalOptimisedPalette () |
void | SetGlobalOptimisedPalette (LPLOGPALETTE pOptimisedPalette) |
Sets up a new optimised palette ready to be applied to all frames in the animation. Should be used with care. At present, only used if we discover that all frames contain compatible bitmaps that have the same palette on them. | |
virtual UINT32 | GetExportMsgID () |
Used to get the message id to be used during export. Virtual, so that two stage exporters can change the message. | |
void | SetGrabMode (GRABMODE newmode) |
Protected Member Functions | |
virtual BOOL | GetExportOptions (BitmapExportOptions *pOptions) |
See BaseBitmapFilter for interface details. | |
virtual KernelBitmap * | GetTheBitmap () |
Creates a kernel bitmap from the Export RenderRegion Overrides the baseclass version as that uses MakeKernelBitmap which does check to see if the OIL bitmap pointers are the same but does not check that the contents are the same. This means we end up with duplicated versions. This is bad. We use TryAndUseExistingBitmap which does this extra check. This is ok in the Creat bitmap copy case as this is the only way to generate duplicate frames. | |
Protected Attributes | |
GRABMODE | m_GrabMode |
Private Member Functions | |
CC_DECLARE_DYNAMIC (GrabFrameFilter) | |
Private Attributes | |
Layer * | m_pLayer |
LPLOGPALETTE | m_pOptimisedPalette |
MakeBitmapExportOptions * | m_pMkBmpOptions |
MakeBitmapExportOptions * | m_pCopyMkBmpOptions |
Definition at line 441 of file frameops.h.
|
Definition at line 494 of file frameops.h. 00494 { GRABMODE_PREVIEW, GRABMODE_FOROUTPUT };
|
|
Constructor for an GrabFrameFilter object. The object should be initialised before use.
Definition at line 3562 of file frameops.cpp. 03563 { 03564 pTheBitmap = NULL; 03565 m_pLayer = NULL; 03566 m_pOptimisedPalette = NULL; 03567 m_pMkBmpOptions = NULL; 03568 m_pCopyMkBmpOptions = NULL; 03569 m_GrabMode = GRABMODE_FOROUTPUT; 03570 03571 // Override this to say something more useful 03572 ExportingMsgID = _R(IDS_EXPORTINGANIMATEDGIF); // "Exporting animated GIF file..." 03573 }
|
|
Destructor for an GrabFrameFilter object.
Definition at line 3584 of file frameops.cpp. 03585 { 03586 if (m_pOptimisedPalette != NULL) 03587 { 03588 CCFree(m_pOptimisedPalette); 03589 m_pOptimisedPalette = NULL; 03590 } 03591 if (m_pCopyMkBmpOptions != NULL) 03592 { 03593 delete m_pCopyMkBmpOptions; 03594 m_pCopyMkBmpOptions = NULL; 03595 } 03596 }
|
|
|
|
Exports the bitmaps specified by the BitmapExportParam object to a multi- image capable filter.
Definition at line 4077 of file frameops.cpp. 04079 { 04080 #ifdef DO_EXPORT 04081 ERROR2IF(pOp == NULL || pFile == NULL || pPath == NULL, FALSE,"NULL Parameters"); 04082 ERROR2IF(pParam == NULL,FALSE,"GrabFrameFilter::DoExportBitmaps null BitmapExportParam specified"); 04083 04084 // We could just call the function direct but this may give us some more functionality 04085 // in the long term 04086 return SaveExportBitmapsToFile(pFile, pPath, pParam, DontShowFileName); 04087 #endif 04088 return FALSE; 04089 }
|
|
Determines if the filter wants to export only selected items. In the base bitmap filters class version the default action will be to export all objects by default.
Reimplemented from MaskedFilter. Definition at line 4024 of file frameops.cpp. 04025 { 04026 // We always export all the objects 04027 return FALSE; 04028 }
|
|
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.
Reimplemented from BaseBitmapFilter. Definition at line 3969 of file frameops.cpp. 03970 { 03971 #ifdef DO_EXPORT 03972 MaskedFilterExportOptions* pMaskedOptions = (MaskedFilterExportOptions*)GetBitmapExportOptions(); 03973 ERROR2IF(pMaskedOptions == NULL, FALSE, "NULL Args"); 03974 ERROR3IF(!pMaskedOptions->IS_KIND_OF(MaskedFilterExportOptions), "pMaskedOptions isn't"); 03975 03976 ERROR2IF(pSpread == NULL, FALSE,"GrabFrameFilter::VisibleLayersOnly no spread to export"); 03977 03978 // We always want to export oONLY the visible layers. 03979 // When we are exporting in transparent mode and making up the mask, we must go and set the 03980 // page background layer to be invisible 03981 // We are just taking the oppurtunity that this call gives us to fix up the page background 03982 // layer to be invisible 03983 if (pMaskedOptions->WantTransparent() && !SecondPass && !GeneratingOptimisedPalette()) 03984 { 03985 // Masking operation 03986 // If we find a page background layer then make sure it is invisible 03987 Layer * pLayer = pSpread->FindFirstPageBackgroundLayer(); 03988 if (pLayer) 03989 pLayer->SetVisible(FALSE); 03990 } 03991 else 03992 { 03993 // Normal export operation 03994 // If we find a page background layer then make sure it is visible 03995 Layer * pLayer = pSpread->FindFirstPageBackgroundLayer(); 03996 if (pLayer) 03997 pLayer->SetVisible(TRUE); 03998 } 03999 04000 // only include all layer that are visible in this bitmap export 04001 return TRUE; 04002 #else 04003 // only include all layer that are visible in this bitmap export 04004 return TRUE; 04005 #endif 04006 }
|
|
Generates an optimised palette to use during export We override the baseclass form so that we generate one optimised palette for all frames if we are in global optimised mode. Otherwise, we can just call the base class version.
Reimplemented from BaseBitmapFilter. Definition at line 3624 of file frameops.cpp. 03627 { 03628 03629 // SMFIX it will pick a valid palette as it goes along 03630 // optimal palettes are no longer created in this manner 03631 // sjk 03632 03633 return TRUE; 03634 }
|
|
Definition at line 477 of file frameops.h. 00477 { return m_pMkBmpOptions; }
|
|
Definition at line 478 of file frameops.h. 00478 { return m_pCopyMkBmpOptions; }
|
|
Used to get the message id to be used during export. Virtual, so that two stage exporters can change the message.
Reimplemented from MakeBitmapFilter. Definition at line 4131 of file frameops.cpp. 04132 { 04133 // Always return this message regardless of the stage that we are on 04134 return _R(IDS_GENERATINGFRAMES); // "Generating animation frames..." 04135 }
|
|
See BaseBitmapFilter for interface details.
Reimplemented from MakeBitmapFilter. Definition at line 3719 of file frameops.cpp. 03720 { 03721 ERROR2IF(pOptions == NULL, FALSE, "pOptions NULL"); 03722 ERROR3IF(!pOptions->IS_KIND_OF(MakeBitmapExportOptions), "pOptions isn't of type MakeBitmapExportOptions"); 03723 03724 m_pMkBmpOptions = (MakeBitmapExportOptions*) pOptions; 03725 03726 // Determine the filter type currently in use in Accusoft format 03727 s_FilterType = MAKE_BITMAP_FILTER; 03728 03729 // Force the selection type to be DRAWING as this should render all visible objects 03730 m_pMkBmpOptions->SetSelectionType(DRAWING); 03731 03732 m_pMkBmpOptions->SetDPI(96.0); 03733 03734 if (m_GrabMode == GRABMODE_PREVIEW) 03735 { 03736 // We want a 24bbp bitmap to pass to Gavin's code but using 32bbp to 03737 // store each pixel (ie the 4 channel of each pixel is waste). This 03738 // should do the trick. 03739 m_pMkBmpOptions->SetDepth(24); 03740 } 03741 else 03742 { 03743 // Force the depth to be 8bpp 03744 m_pMkBmpOptions->SetDepth(8); 03745 } 03746 03747 // Force the interlacing off 03748 m_pMkBmpOptions->SetMakeInterlaced(FALSE); 03749 03750 // Force the transparency to on. 03751 //m_pMkBmpOptions->SetMakeTransparent(TRUE); 03752 03753 // recover the relevant animation options from the spread 03754 if (pSpread) 03755 { 03756 DWORD Loop = 0; 03757 DWORD GlobalDelay = 10; 03758 DITHER Dither = XARADITHER_ORDERED_GREY; 03759 WEB_PALETTE WebPalette = PAL_GLOBAL; 03760 PALETTE_COLOURS ColoursPalette = PALCOL_BROWSER; 03761 DWORD NumColsInPalette = 255; 03762 BOOL UseSystemColours = FALSE; 03763 // Ask the spread for its version of these values 03764 pSpread->GetSpreadAnimPropertiesParam(&Loop, &GlobalDelay, &Dither, &WebPalette, 03765 &ColoursPalette, &NumColsInPalette, &UseSystemColours, NULL); 03766 03767 // set to use background transp if it is set in the animation properties dlg 03768 m_pMkBmpOptions->SetBackgroundTransparency(pSpread->GetSpreadAnimPropertiesParam().GetIsBackGroundTransp()); 03769 03770 // Ensure the dependent options are set correctly 03771 // There are 20 colours in the system palette 03772 switch (ColoursPalette) 03773 { 03774 case PALCOL_STANDARD: 03775 case PALCOL_BROWSER: 03776 // Fixed browser palette 03777 // SMFIX we want a browser palette 03778 m_pMkBmpOptions->SetToUseBrowserPalette(TRUE); 03779 m_pMkBmpOptions->CreateValidBrowserPalette(TRUE); 03780 // set this as the palette being used in output dib 03781 AlterPaletteContents(m_pMkBmpOptions->GetLogicalPalette()); 03782 break; 03783 03784 case PALCOL_OPTIMIZED: 03785 // Optimised, so take the user's chosen number of required colours 03786 // Check if local or globally optimised 03787 /* if (WebPalette == PAL_GLOBAL) 03788 TRACEUSER( "SimonK", _T("PAL_GLOBALOPTIMISED\n")); 03789 else 03790 TRACEUSER( "SimonK", _T("PAL_OPTIMISED\n")); 03791 */ //m_pMkBmpOptions->SetNumColsInPalette(NumColsInPalette); 03792 // store the number of user defined colours in the options 03793 m_pMkBmpOptions->SetNumberOfUserRequestedColours(NumColsInPalette); 03794 // In optimised mode we cannot have ordered dithering as it 03795 // must have a known palette. So switch the dithering to error 03796 // diffusion. 03797 if (Dither == XARADITHER_ORDERED_GREY) 03798 Dither = XARADITHER_ERROR_DIFFUSION; 03799 03800 // Set up whether we save system colours or not 03801 //m_pMkBmpOptions->SetUseSystemColours(UseSystemColours); 03802 //m_pMkBmpOptions->SetToUseSystemPalette(UseSystemColours); 03803 break; 03804 default: 03805 ERROR3("Bad ColoursPalette option"); 03806 break; 03807 } 03808 03809 switch (WebPalette) 03810 { 03811 case PAL_GLOBAL: 03812 // If global set then must be browser palette selected 03813 //TRACEUSER( "SimonK", _T("PAL_GLOBAL\n")); 03814 // ColoursPalette = PALCOL_BROWSER; 03815 // use the global palette here 03816 if (GetGlobalOptimisedPalette()) 03817 { 03818 m_pMkBmpOptions->CreateValidPalette(GetGlobalOptimisedPalette(), 03819 m_pMkBmpOptions->IsBackgroundTransparent() ? 0 : -1); 03820 // set this as the palette being used in output dib 03821 AlterPaletteContents(m_pMkBmpOptions->GetLogicalPalette()); 03822 } 03823 break; 03824 case PAL_LOCAL: 03825 // If local palette selected then must be optimised as 03826 // no point saving out a global palette 03827 //TRACEUSER( "SimonK", _T("PAL_LOCAL\n")); 03828 // ColoursPalette = PALCOL_OPTIMIZED; 03829 // SMFIX 03830 // if we are the first frame generate a new valid palette 03831 // we could use that as a first guess at a global palette 03832 // but we do know that if we do not have a global palette we 03833 // should be getting a different palette for each frame 03834 m_pMkBmpOptions->InvalidatePalette(); 03835 break; 03836 default: 03837 ERROR3("Bad WebPalette option"); 03838 break; 03839 } 03840 03841 // Set up the dithering that we are going to use 03842 m_pMkBmpOptions->SetDither(Dither); 03843 } 03844 03845 03846 // We have all the options that we require so don't ask the user for anything 03847 03848 // Take a copy of these options for latter use (Browser Preview) 03849 if (m_pCopyMkBmpOptions == NULL) 03850 { 03851 m_pCopyMkBmpOptions = (MakeBitmapExportOptions *)m_pMkBmpOptions->MakeCopy(); 03852 // don't complain about null as only required by browser preview at present 03853 } 03854 03855 // All ok 03856 return TRUE; 03857 }
|
|
Definition at line 480 of file frameops.h. 00480 { return m_pOptimisedPalette; }
|
|
Definition at line 467 of file frameops.h. 00467 { return m_pLayer; }
|
|
Creates a kernel bitmap from the Export RenderRegion Overrides the baseclass version as that uses MakeKernelBitmap which does check to see if the OIL bitmap pointers are the same but does not check that the contents are the same. This means we end up with duplicated versions. This is bad. We use TryAndUseExistingBitmap which does this extra check. This is ok in the Creat bitmap copy case as this is the only way to generate duplicate frames.
Definition at line 3906 of file frameops.cpp. 03907 { 03908 // Extract a copy of the bitmap from the RenderRegion 03909 // We need to generate new bitmaps as we delete them and also name them ourselves. 03910 BOOL LookForDuplicates = FALSE; 03911 OILBitmap* pOilBitmap = ExportRegion->ExtractBitmapCopy(pOptimisedPalette, pDestBMInfo, pDestBMBytes, 03912 TransColour, LookForDuplicates); 03913 03914 if (pOilBitmap == NULL) 03915 { 03916 CleanUpAfterExport(); 03917 return NULL; 03918 } 03919 03920 if (m_pLayer) 03921 { 03922 // Make the bitmap name the layer name 03923 String_256 Name = m_pLayer->GetLayerID(); 03924 pOilBitmap->SetName(Name); 03925 03926 // Copy across the delay from the layer 03927 DWORD delay = m_pLayer->GetFrameDelay(); 03928 pOilBitmap->SetBitmapAnimDelay(delay); 03929 03930 // As all these frames are complete, we output them using 03931 // a replace background restore type. 03932 // It is only later that we may do some trickery on them so that 03933 // we can overlay them. 03934 pOilBitmap->SetAnimationRestoreType(GDM_BACKTOBACK); 03935 03936 // The exception is if the frame is solid in which case we invariably 03937 // want that one to overlay 03938 //if (m_pLayer->IsSolid()) 03939 // pOilBitmap->SetAnimationRestoreType(GDM_LEAVE); 03940 //else 03941 } 03942 03943 // Make a kernel bitmap from the oily one 03944 // The class variable pDocument should be holding the document required 03945 // Must check it as TryAndUseExistingBitmap does not! 03946 // ERROR2IF(TheDocument == NULL,NULL,"GrabFrameFilter::GetTheBitmap null document") 03947 // BOOL IsNew = TRUE; 03948 // return KernelBitmap::TryAndUseExistingBitmap(pOilBitmap, TheDocument, &IsNew); 03949 return KernelBitmap::MakeKernelBitmap(pOilBitmap, TheDocument); 03950 }
|
|
Determines if the a second rendering pass is required or not.
Reimplemented from BaseBitmapFilter. Definition at line 4042 of file frameops.cpp. 04043 { 04044 #ifdef DO_EXPORT 04045 MaskedFilterExportOptions* pMaskedOptions = (MaskedFilterExportOptions*)GetBitmapExportOptions(); 04046 ERROR2IF(pMaskedOptions == NULL, FALSE, "NULL Args"); 04047 ERROR3IF(!pMaskedOptions->IS_KIND_OF(MaskedFilterExportOptions), "pMaskedOptions isn't"); 04048 04049 // Only require a second pass if wanting transparency 04050 if (pMaskedOptions->WantTransparent()) 04051 return TRUE; 04052 else 04053 return FALSE; 04054 #else 04055 return FALSE; 04056 #endif 04057 }
|
|
Definition at line 475 of file frameops.h. 00475 { return (MakeBitmapExportOptions*)CreateExportOptions(); }
|
|
Sets up a new optimised palette ready to be applied to all frames in the animation. Should be used with care. At present, only used if we discover that all frames contain compatible bitmaps that have the same palette on them.
Definition at line 4107 of file frameops.cpp. 04108 { 04109 if (m_pOptimisedPalette != NULL) 04110 { 04111 CCFree(m_pOptimisedPalette); 04112 m_pOptimisedPalette = NULL; 04113 } 04114 04115 m_pOptimisedPalette = pOptimisedPalette; 04116 }
|
|
Definition at line 495 of file frameops.h. 00495 { m_GrabMode = newmode; }
|
|
This remembers the layer that is being captured. It sets the member variable up to the specified layer.
Definition at line 3648 of file frameops.cpp.
|
|
Sets up the class variable ClipRect to be the clipping rectangle to be used during export. See Also: PrepareToExport(). > virtual BOOL GrabFrameFilter::SetUpClippingRectangleForExport(Spread *pSpread, SelectionType Selection)
Reimplemented from BaseBitmapFilter. Definition at line 3670 of file frameops.cpp. 03671 { 03672 ERROR2IF(pSpread == NULL,FALSE,"SetUpClippingRectangleForExport Bad spread"); 03673 03674 // Make an empty rect to start with in the class variable 03675 ClipRect.MakeEmpty(); 03676 03677 // Walk through all the frame layers and work out the bounding boxes of each 03678 Layer* pCurrentLayer = pSpread->FindFirstFrameLayer(); 03679 Layer* pNextLayer = NULL; 03680 while (pCurrentLayer != NULL) 03681 { 03682 pNextLayer = pCurrentLayer->FindNextFrameLayer(); 03683 // Double check that it is a suitable frame layer and check it is not hidden 03684 if (pCurrentLayer->IsPseudoFrame()) 03685 { 03686 // Cannot include a simple hidden check as the purpose of hidden frames is to 03687 // act as backgrounds for the animation. Could check for hidden and solid but 03688 // would also need to check for an overlay onto the hidden frame 03689 if ( 03690 (!pCurrentLayer->IsHiddenFrame()) || 03691 (pCurrentLayer->IsHiddenFrame() && pCurrentLayer->IsSolid()) || 03692 (pCurrentLayer->IsHiddenFrame() && pNextLayer && pNextLayer->IsOverlay()) 03693 ) 03694 { 03695 // Get the bounding rect for this layer 03696 DocRect LayerRect = pCurrentLayer->GetBoundingRect(); 03697 // Add this to our clipping rectangle 03698 ClipRect = ClipRect.Union(LayerRect); 03699 } 03700 } 03701 03702 // Move to the next bitmap in the animation 03703 pCurrentLayer = pNextLayer; 03704 } 03705 03706 return TRUE; 03707 }
|
|
This is just a public interface on the normal filter's GetExportOptions which is protected. It also ensures that the pSpread is set up.
Definition at line 3871 of file frameops.cpp. 03872 { 03873 // Ensure that the spread pointer is set up 03874 // If we haven't actually grabbed any frames then it will be NULL 03875 pSpread = pCurrentSpread; 03876 // Set up those export options 03877 return GetExportOptions(pOptions); 03878 }
|
|
Definition at line 499 of file frameops.h. |
|
Definition at line 521 of file frameops.h. |
|
Definition at line 512 of file frameops.h. |
|
Definition at line 519 of file frameops.h. |
|
Definition at line 516 of file frameops.h. |