TI_GIFFilter Class Reference

Encapsulates a Windows GIF export and import filter. Derives off the masked filter which provides funcitonality for doing masked bitmap export and import. More...

#include <giffiltr.h>

Inheritance diagram for TI_GIFFilter:

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

Public Member Functions

 TI_GIFFilter ()
 Allows a default GIF type to be remembered for the next export GIF operation. Constructor for an TI_GIFFilter object. The object should be initialised before use.
virtual BOOL Init ()
 Initialise an TI_GIFFilter object.
virtual INT32 HowCompatible (PathName &Filename, ADDR HeaderStart, UINT32 HeaderSize, UINT32 FileSize)
 Determine if this filter can load the specified file.
virtual BOOL IsDefaultDocRequired (const TCHAR *pcszPathName)
 Is called when a TIFF or GIF is opened, to let us say whether we need a default document.
virtual FilterType GetFilterType () const
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. It is also used for extracting previews. 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.
virtual BOOL WriteBitmapToFile (KernelBitmap *pKernelBitmap, BaseCamelotFilter *pFilter, CCLexFile *pFile, INT32 Compression)
 Physically put the bitmap into the disk. Inherited classes override this to write in different file formats. This is used by the native/web format to output the actual bitmap data content of a bitmap definition record. The function can assume that the CCFile is open and ready for writing and must use the functions provided by pFilter to update the progress system.
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.
void AlterPaletteContents (LPLOGPALETTE pPalette)
virtual BOOL IsThisBppOk (UINT32 Bpp)
 Check if this Bitmap filter can cope with saving at this Bpp/Colour depth.
INT32 GetGifCompatibility ()
 Determine if this filter can load the specified file.
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.
virtual BOOL ShouldReuseExistingBitmaps ()
 Determines whether or not to re-use existing bitmap. Animation Import will say no, so that frames that are same still appear more than once.
virtual void PostGetExportOptions (BitmapExportOptions *pOptions)

Protected Member Functions

virtual BitmapImportOptionsCreateImportOptions () const
 Overrides base class to provide GIF specific options.
virtual BitmapExportOptionsCreateExportOptions () const
 Allows derived classes to override this function to provide their own class derived from BitmapExportInfo containing filter specific information.
virtual OutputDIBGetOutputDIB (void)
 Casts the current output DIB to be a generic OutputDIB class. This allows the same code to be re-used in the base class.
virtual UINT32 GetHintType (void)
 Base class sets bad so no hint is set.
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 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 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 WritePreSecondPass (void)
 Called to do any processing required after the first and before the second pass of a two pass export.
virtual BOOL WritePostOptimisedPalette (void)
 Called after an optimised palette has been generated.
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 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 AddOffsetFromBitmap (DocCoord *pOffset)
 When loading in a bitmap, the bitmap definition may conatin 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 uses the class variables that were set up during the GIF loading process to add the offset onto the import position.
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.
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. Assumes that each bitmap has been added to a separate layer and that the referenced bitmap in the layer is set to this loaded bitmap.
virtual BOOL GetDragAndDropTranslation (ImportPosition *pPos, DocRect BoundsRect, Coord *Offset)
 Given an drag'n'drop point (in pPos), calculate the translation necessary to position the imported objects at this position on the spread. It ensures that bounding rectangles smaller than the spread are wholly contained within the spread. i.e. if you drag a file right to the edge of a spread, the translation will move it closer to the centre of the spread so that it is wholly contained within the spread.

Static Protected Member Functions

static BOOL WriteDataToFile (BOOL End, UINT32 Bpp, UINT32 Compression)
 Physically put the bitmap into the disk. NOTE - ONLY COPES WITH End=TRUE currently AtEnd is ignored now and should always be set to TRUE. Unused at present due to static problems when cretaing the 1bpp bitmap.
static BOOL WriteToFile (CCLexFile *File, LPBITMAPINFO Info, LPBYTE Bits, String_64 *ProgressString=NULL)
 Write a bitmap in memory straight out as a GIF to file with no rendering or conversion between different colour depths (apart from 32 to 24) or resolution. Errors on 16-bit builds*** A progress hourglass can be shown if required. This function is used by the save bitmap button on the bitmap gallery. All other bitmap export uses the OutputDIB class instead as this copes with using a render region and converting from 32 to the destination format. (caller should close file).
static BOOL WriteToFile (CCLexFile *File, LPBITMAPINFO Info, LPBYTE Bits, BOOL Interlace, INT32 Transparent, BaseCamelotFilter *pFilter=NULL)
 Write a bitmap in memory straight out as a GIF to file with no rendering or conversion between different colour depths (apart from 32 to 24) or resolution. Errors on 16-bit builds*** A progress hourglass can be shown if required. This function is used by the native/web file format to save a bitmap as a GIF directly into the file. Hence why it needs to be completely different to the version below which is used for extras like saving animated gifs. (caller should close file).

Protected Attributes

INT32 GIFHowCompatible
BOOL m_DoingAnimation
UINT32 m_AnimationFrame
UINT32 Export2ndStageMsgID
UINT32 m_LeftOffset
UINT32 m_TopOffset
GIFDisposalMethod m_PreviousMethod

Static Protected Attributes

static OutputGIF DestGIF
static FilterType s_FilterType = GIF

Private Member Functions

 CC_DECLARE_DYNAMIC (TI_GIFFilter)

Detailed Description

Encapsulates a Windows GIF export and import filter. Derives off the masked filter which provides funcitonality for doing masked bitmap export and import.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/4/95

Definition at line 235 of file giffiltr.h.


Constructor & Destructor Documentation

TI_GIFFilter::TI_GIFFilter  ) 
 

Allows a default GIF type to be remembered for the next export GIF operation. Constructor for an TI_GIFFilter object. The object should be initialised before use.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/4/95
See also:
TI_GIFFilter::Init

Definition at line 621 of file giffiltr.cpp.

00621                            : MaskedFilter()
00622 {
00623     ImportMsgID = _R(IDN_IMPORTMSG_GIF);
00624     Flags.CanImport = TRUE;
00625 #ifndef STANDALONE
00626     Flags.CanExport = TRUE;
00627     Flags.CanExportMultipleImages = TRUE;
00628 #else
00629     Flags.CanExport = FALSE;
00630     Flags.CanExportMultipleImages = FALSE;
00631 #endif
00632     FilterID = FILTERID_TI_GIF;
00633 
00634     ExportMsgID = _R(IDN_EXPORTMSG_GIF);            // "Preparing GIF file..."
00635 
00636     ExportingMsgID = _R(IDN_EXPORTINGMSG_GIF);      // "Exporting GIF file..."
00637 
00638     // Special Mask prepartion stage ID
00639     Export2ndStageMsgID = _R(IDN_MASKINGMSG_GIF);   // "Preparing mask for GIF file..."
00640 
00641     ExportRegion = NULL;
00642 
00643     // Initalise flags
00644     m_DoingAnimation = FALSE;
00645     m_AnimationFrame = 0;
00646     m_LeftOffset = 0;
00647     m_TopOffset = 0;
00648 
00649     m_PreviousMethod = GDM_BACKTOBACK;
00650 }


Member Function Documentation

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

When loading in a bitmap, the bitmap definition may conatin 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 uses the class variables that were set up during the GIF loading process to add the offset onto the import position.

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 from BaseBitmapFilter.

Definition at line 1049 of file giffiltr.cpp.

01050 {
01051     if (pOffset && m_LeftOffset >= 0 && m_TopOffset >= 0)
01052     {
01053         // GIFs have no concept of DPI so assume 96
01054         const UINT32 dpi = 96;
01055         // We have been told how many pixels to offset by so we should just
01056         // multiply by 72000 millipoints per inch and then divide by the pixels per inch or dpi.
01057         MILLIPOINT ExtraOffsetX = (m_LeftOffset * 72000) / dpi;
01058         MILLIPOINT ExtraOffsetY = (m_TopOffset * 72000) / dpi;
01059         // Add these offsets onto the one that is passed in
01060         pOffset->x += ExtraOffsetX;
01061         // Remember, we have been told the offset from the top, so we need to move downwards
01062         pOffset->y -= ExtraOffsetY;
01063     }
01064 
01065     return TRUE;
01066 }

void TI_GIFFilter::AlterPaletteContents LPLOGPALETTE  pPalette  )  [virtual]
 

Reimplemented from BaseBitmapFilter.

Definition at line 2326 of file giffiltr.cpp.

02327 {
02328     DestGIF.AlterExportPalette( pPalette );
02329 }

TI_GIFFilter::CC_DECLARE_DYNAMIC TI_GIFFilter   )  [private]
 

void TI_GIFFilter::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 BaseBitmapFilter.

Reimplemented in MakeBitmapFilter.

Definition at line 1156 of file giffiltr.cpp.

01157 {
01158     // Called right at the end of the export process or when the epxort has been aborted
01159     // Clean up any objects unique to this class.
01160     // Free up any DIBs that we might have left lying around on the export
01161     if (pDestBMInfo && pDestBMBytes)
01162     {
01163         FreeDIB( pDestBMInfo, pDestBMBytes );
01164         pDestBMInfo = NULL;
01165         pDestBMBytes = NULL;    
01166     }
01167 
01168     // reset the filter settings, as the preview export might have messed with them
01169 
01170     // the depth we ask GDraw to render is always 32-bit, so we can get transparency
01171     // we have to convert for other formats when writing the actual bytes to the file
01172     SetDepthToRender(32);
01173 
01174     // We haven't written the header yet
01175     WrittenHeader = FALSE;
01176 
01177     // We are a first pass render and not doing the mask, by default
01178     SecondPass = FALSE;
01179     DoingMask = FALSE;
01180 
01181     // Now call the baseclass version to do its stuff
01182     BaseBitmapFilter::CleanUpAfterExport();
01183 }

BitmapExportOptions * TI_GIFFilter::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 BaseBitmapFilter.

Reimplemented in MakeBitmapFilter.

Definition at line 2497 of file giffiltr.cpp.

02498 {
02499     GIFExportOptions* pGIFOptions = new GIFExportOptions(TI_GIF, &FilterName);
02500 
02501     return (BitmapExportOptions*)pGIFOptions;
02502 }

BitmapImportOptions * TI_GIFFilter::CreateImportOptions  )  const [protected, virtual]
 

Overrides base class to provide GIF specific options.

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

Definition at line 695 of file giffiltr.cpp.

00696 {
00697     GIFImportOptions* pOptions = new GIFImportOptions;
00698     return (BitmapImportOptions*)pOptions;
00699 }

BOOL TI_GIFFilter::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 BaseBitmapFilter.

Reimplemented in MakeBitmapFilter.

Definition at line 1379 of file giffiltr.cpp.

01380 {
01381 #ifndef STANDALONE
01382 
01383     if (GeneratingOptimisedPalette())
01384         return TRUE;        // No need to output anything
01385 
01386         //  Can reset the band number now.
01387     m_BandNumber = 0;
01388 
01389     GIFExportOptions* pGIFOptions = (GIFExportOptions*)GetBitmapExportOptions();
01390     ERROR2IF(pGIFOptions == NULL, FALSE, "NULL Args");
01391     ERROR3IF(!pGIFOptions->IS_KIND_OF(GIFExportOptions), "pGIFOptions isn't");
01392 
01393 TRACEUSER( "Neville", _T("TI_GIFFilter::EndWriteToFile\n"));
01394     // Do the transparency translation just before we write out the data as a GIF.
01395     // This involves doing a 1 bpp export of the same area and using this to work
01396     // out which areas are transparent or not.
01397     // Only do this if the user has requested transparency and we outputting at 8bpp
01398 
01399     if (BadExportRender)
01400     {
01401         // Delete our whitearea bitmap
01402         if (pTempBitmapMask != NULL)
01403             CCFree(pTempBitmapMask);
01404 
01405         pTempBitmapMask = NULL;
01406     }
01407 
01408     BOOL ok = TRUE;
01409     BOOL SaveDataOut = TRUE;
01410     BOOL WantTransparent = pGIFOptions->WantTransparent();
01411     BOOL WantInterlaced = pGIFOptions->WantInterlaced();
01412 
01413     // Save the data out if required. Only if we exported ok.
01414     if (SaveDataOut && !BadExportRender)
01415     {
01416         // Now that we know the transparent index we can output the GIF header
01417         if (ok)
01418         {
01419             // Work out whether we should save as GIF87 or GIF89
01420             // If we are using animation or transparency then save out as GIF89
01421             BOOL Enhanced = m_DoingAnimation || WantTransparent;
01422 
01423             if (m_DoingAnimation)
01424             {
01425                 if (m_AnimationFrame == 0)
01426                 {
01427                     // We force a transparent colour of -1 so the transparent index colour is not changed to white in the global colour table.
01428                     ok = DestGIF.OutputGifFileHeader(OutputFile, Enhanced, -1);
01429                     if (ok)
01430                     {
01431                         // Shall we output a Loop block ?
01432 
01433                         // We only put a loop block in if the loop count is 0, or > 1
01434                         // and we subtract 1 from values other than 0, so that the
01435                         // loop count represent the number of times the animation
01436                         // is 'played' rather than 'repeated' ....
01437                         // 
01438                         // ie.  0, loop block with value 0.     Repeat forever.
01439                         //      1, no loop block.               One shot animation.
01440                         //      2, loop block with value 1.     Plays animation 2 times.
01441                         //      3, loop block with value 2.     Plays animation 3 times.
01442                         //      4, loop block with value 3.     Plays animation 4 times.
01443                         //      etc ...
01444                         UINT32 LoopCount = pGIFOptions->GetAnimationLoopCount();
01445                         if (LoopCount != 1)
01446                         {
01447                             if (LoopCount > 1) LoopCount -= 1;
01448 
01449                             // Output a loop block then ...
01450                             ok = DestGIF.OutputAnimationControl(OutputFile, LoopCount);
01451                         }
01452                     }
01453                 }
01454             }
01455             else
01456             {
01457                 ok = DestGIF.OutputGifFileHeader(OutputFile, Enhanced, pGIFOptions->GetTransparencyIndex());
01458             }
01459         }
01460 
01461         // Actually write the destination bitmap out to the file showing an hourglass
01462         // and/or progress bar as we go. Always show the Exporting message.
01463         // Need to do in one go due to interlacing
01464 
01465         // Andy, 13-12-00: removed progress bar.
01466         // It goes by very quickly compared with the main rendering jobbie.
01467         // Also removed corresponding ContinueSlowJob from OutputGIF::BumpPixel
01468         if (ok)
01469         {
01470             String_64 ProgressString(ExportingMsgID);
01471             ProgressString = GetExportProgressString(OutputFile, ExportingMsgID);
01472             //BeginSlowJob(100, FALSE, &ProgressString);
01473         
01474             if (ok && (WantTransparent || m_DoingAnimation || WantInterlaced))
01475             {
01476                 ok = DestGIF.OutputGifImageExtensionHeader(OutputFile, WantInterlaced,
01477                         pGIFOptions->GetTransparencyIndex(),
01478                         m_DoingAnimation ? pGIFOptions->GetAnimationDelay() : 0,
01479                         m_DoingAnimation ? pGIFOptions->GetAnimationRestore() : 0);
01480             }
01481             // if we are doing an animation with an optimised palette then we will need
01482             // save out this palette as a local colour table (the first frame uses the global table)
01483             BOOL OutputLocalColourTable = (m_DoingAnimation && pOptimisedPalette != NULL && m_AnimationFrame != 0);
01484             if (ok)
01485                 ok = DestGIF.OutputGifImageBits(OutputFile, DestGIF.GetDestBitmapBits(), WantInterlaced, OutputLocalColourTable);
01486 
01487             //EndSlowJob();
01488         }
01489     }
01490 
01491     return ok;
01492 
01493 #else   
01494 
01495     return TRUE;
01496 
01497 #endif
01498 
01499 }

BOOL TI_GIFFilter::GetDragAndDropTranslation ImportPosition pPos,
DocRect  BoundsRect,
Coord Offset
[protected, virtual]
 

Given an drag'n'drop point (in pPos), calculate the translation necessary to position the imported objects at this position on the spread. It ensures that bounding rectangles smaller than the spread are wholly contained within the spread. i.e. if you drag a file right to the edge of a spread, the translation will move it closer to the centre of the spread so that it is wholly contained within the spread.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> based on Tim function
Date:
15/5/97
Parameters:
pSpread - the spread to check against. [INPUTS] BoundsRect - the bounding rectangle to check (in spread coordinates).
Offset - [OUTPUTS]
Returns:
TRUE if the bounding rectangle is smaller than the spread => Offset now contains the translation necessary to position the objects correctly. FALSE if bounding rectangle is bigger than the spread, or pPos was NULL. In either case, a FALSE return results in Offset containing (0,0).
Used by the import filters for drag'n'drop to ensure that after the imported objects are translated to the drop point, they are all still on the spread.
See also:
Filter::DoImport

Reimplemented from Filter.

Definition at line 882 of file giffiltr.cpp.

00884 {
00885     // First check to se if we actually have a drag and drop point.
00886     if (pPos == NULL || pPos->pSpread == NULL)
00887     {
00888         // No - set offset to 0 and return FALSE to indicate we can't cope with this.
00889         Offset->x = 0;
00890         Offset->y = 0;
00891         return FALSE;
00892     }
00893 
00894     // Get the spread's bounding rectangle and convert it to spread coords.
00895     DocRect SpreadRect = pPos->pSpread->GetPasteboardRect();
00896     pPos->pSpread->DocCoordToSpreadCoord(&SpreadRect);
00897 
00898     // Now check that the bounding rectangle is small enough to fit on the spread...
00899     if ((BoundsRect.Width() > SpreadRect.Width()) ||
00900         (BoundsRect.Height() > SpreadRect.Height()))
00901     {
00902         // No - set offset to 0 and return FALSE to indicate we can't cope with this.
00903         Offset->x = 0;
00904         Offset->y = 0;
00905         return FALSE;
00906     }
00907 
00908     // Bounding box should be centred on drop point
00909     // This is the default way of doing it. We actually want the bounding box of the animation
00910     // centered on the drop point with the inidividual frames positioned inside this.
00911     // The x and y offsets are handled latter so we must just position the rectangle to the left
00912     // of the main animations' bounding box
00913     UINT32 GIFWidth = GIFUtil::GetGlobalWidth();
00914     UINT32 GIFHeight = GIFUtil::GetGlobalHeight();
00915     if (GIFWidth > 0 && GIFHeight > 0)
00916     {
00917         // GIFs have no concept of DPI so assume 96
00918         const double dpi = 96.0;
00919         const INT32 PixelSize = (INT32) ((72000.0 / dpi) + 0.5);    // Size of output pixel in millipoints
00920 
00921         // We have been told how many pixels the animation is in size so we should just
00922         // multiply by 72000 millipoints per inch and then divide by the pixels per inch or dpi.
00923         MILLIPOINT AnimationWidth = (INT32) (((GIFWidth * 72000.0) / dpi) + 0.5);
00924         MILLIPOINT AnimationHeight = (INT32) (((GIFHeight * 72000.0) / dpi) + 0.5);
00925         // Add these offsets onto the one that is passed in
00926         DocCoord Centre;
00927         Centre.x = (AnimationWidth) / 2;
00928         Centre.y = (AnimationHeight) / 2;
00929 
00930         // If the height or width is an odd number then we may be positioning on half pixel
00931         // boundaries. So snap to the nearest whole pixel boundary.
00932         Centre.x -= Centre.x % PixelSize;
00933         Centre.y -= Centre.y % PixelSize;
00934 
00935         Offset->x = -Centre.x;
00936         Offset->y = -Centre.y;
00937 
00938         // The bitmaps will now be so that their bottom left hand corner is at the corner
00939         // of the animation. So we need to move it up so that its top left hand corner is
00940         // at the top left of the animation.
00941         Offset->y += AnimationHeight - (BoundsRect.hi.y - BoundsRect.lo.y);
00942     }
00943     else
00944     {
00945         // No - set offset to 0 and return FALSE to indicate we can't cope with this.
00946         Offset->x = 0;
00947         Offset->y = 0;
00948     }
00949 
00950     // Transform the bounding rect to see if it's off the spread.
00951     BoundsRect.Translate(Offset->x, Offset->y);
00952 
00953     // If it's off the spread - limit it to the edge of the spread:
00954 
00955     // (a) Horizontal adjustment
00956     if (BoundsRect.lo.x < SpreadRect.lo.x)
00957         Offset->x += (SpreadRect.lo.x - BoundsRect.lo.x);
00958     else if (BoundsRect.hi.x > SpreadRect.hi.x)
00959         Offset->x -= (BoundsRect.hi.x - SpreadRect.hi.x);
00960 
00961     // (b) Vertical adjustment
00962     if (BoundsRect.lo.y < SpreadRect.lo.y)
00963         Offset->y += (SpreadRect.lo.y - BoundsRect.lo.y);
00964     else if (BoundsRect.hi.y > SpreadRect.hi.y)
00965         Offset->y -= (BoundsRect.hi.y - SpreadRect.hi.y);
00966 
00967     // Whatever happened, we can fit it on the spread.
00968     return TRUE;
00969 }

UINT32 TI_GIFFilter::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 BaseBitmapFilter.

Reimplemented in GrabFrameFilter, and MakeBitmapFilter.

Definition at line 1326 of file giffiltr.cpp.

01327 {
01328     if (GeneratingOptimisedPalette())
01329         return _R(IDS_GENOPTPALMSGID);              // "Generating optimised palette..."
01330 
01331     GIFExportOptions* pGIFOptions = (GIFExportOptions*)GetBitmapExportOptions();
01332     ERROR2IF(pGIFOptions == NULL, FALSE, "NULL Args");
01333     ERROR3IF(!pGIFOptions->IS_KIND_OF(GIFExportOptions), "pGIFOptions isn't");
01334     
01335     // If we are exporting with transparency on and on first pass use the masking message
01336     // otherwise use the exporting message.
01337     if (pGIFOptions->GetSelectionType() == SELECTION && pGIFOptions->WantTransparent())
01338     {
01339         // Special 4 stage rendering operation
01340         // - Render selected objects to white background
01341         // - Render mask 1bpp
01342         // - Render all objects
01343         // - Save data out to disk
01344         if (!SecondPass)
01345             return Export2ndStageMsgID;         // "Preparing mask for GIF file..."
01346         else
01347             return Filter::GetExportMsgID();    // "Preparing GIF file..."
01348     }
01349     else
01350     {
01351         // Special 3 stage rendering operation
01352         // - Render objects to white background
01353         // - Render mask 1bpp
01354         // - Save data out to disk
01355         if (DoingMask)
01356             return Export2ndStageMsgID;         // "Preparing mask for GIF file..."
01357         else
01358             return Filter::GetExportMsgID();    // "Preparing GIF file..."
01359     }
01360 }

BOOL TI_GIFFilter::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 BaseBitmapFilter.

Reimplemented in GrabFrameFilter, MakeBitmapFilter, and PreviewFilterGIF.

Definition at line 1196 of file giffiltr.cpp.

01197 {
01198 
01199 //[MD]
01200 
01201 #ifndef STANDALONE
01202     ERROR2IF(pOptions == NULL, FALSE, "NULL Args");
01203 
01204     GIFExportOptions* pGIFOptions = (GIFExportOptions*)pOptions;
01205     ERROR3IF(!pGIFOptions->IS_KIND_OF(GIFExportOptions), "pGIFOptions isn't");
01206 
01207     // the depth we ask GDraw to render is always 32-bit, so we can get transparency
01208     // we have to convert for other formats when writing the actual bytes to the file
01209     SetDepthToRender(32);
01210 
01211     // We haven't written the header yet
01212     WrittenHeader = FALSE;
01213 
01214     // We are a first pass render and not doing the mask, by default
01215     SecondPass = FALSE;
01216     DoingMask = FALSE;
01217 
01218     // Default will range from 0 to 4 types which correspond to the combinations of
01219     // on/off interlaced and on/off transparent
01220     
01221     // Determine the filter type currently in use in Accusoft format
01222     s_FilterType = (pGIFOptions->GetSelectionType() == SOMEBITMAPS) ? TI_GIF_ANIM : TI_GIF;
01223     pGIFOptions->SetFilterType(s_FilterType);
01224     m_DoingAnimation = (pGIFOptions->GetSelectionType() == SOMEBITMAPS);
01225     
01226     // This is ok as we are using a modal dialog box    
01227     BOOL Ok = FALSE;
01228     
01229     if (s_FilterType == TI_GIF)
01230     {
01231         OpDescriptor* pOpDes = OpDescriptor::FindOpDescriptor(OPTOKEN_GIFTABDLG);
01232         if (pOpDes != NULL)
01233         {
01234             // set up the data for the export options dialog
01235             OpParam Param((void *)pOptions, (void *)this);
01236 
01237             // invoke the dialog
01238             pOpDes->Invoke(&Param);
01239 
01240             // SMFIX
01241             // we have brought the dlg up so get the options from the dlg as the graphic type may have changed
01242             pOptions = BmapPrevDlg::m_pExportOptions;
01243 
01244             // check for valid options
01245             //  This may get messed up, so have to use the second line below.
01246             Ok = BmapPrevDlg::m_bClickedOnExport;
01247         }
01248         else
01249         {   
01250             ERROR3("Unable to find OPTOKEN_BMAPPREVDLG");
01251         } 
01252     }
01253     else
01254     {
01255 #ifndef EXCLUDE_FROM_XARALX
01256         // invoke the dialog
01257         Ok = BmpPrefsDlg::InvokeDialog( pOptions);
01258 #endif
01259     }
01260 
01261     // Return with the ok/cancel state used on the dialog box
01262     return Ok;
01263 
01264 #else
01265     return FALSE;
01266 #endif
01267 }

virtual FilterType TI_GIFFilter::GetFilterType  )  const [inline, virtual]
 

Reimplemented from BaseBitmapFilter.

Definition at line 249 of file giffiltr.h.

00249 { return TI_GIF; }

INT32 TI_GIFFilter::GetGifCompatibility  ) 
 

Determine if this filter can load the specified file.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/4/95
Parameters:
- [INPUTS]
Returns:
The value we found in the HowCompatible call. 0 => Not a GIF file. 10 => It is a GIF file.

Definition at line 1980 of file giffiltr.cpp.

01981 {
01982     return GIFHowCompatible;
01983 }

UINT32 TI_GIFFilter::GetHintType void   )  [protected, virtual]
 

Base class sets bad so no hint is set.

Author:
Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/07/97

Reimplemented from MaskedFilter.

Definition at line 2515 of file giffiltr.cpp.

02516 {
02517     return(HINTTYPE_GIF);
02518 }

OutputDIB * TI_GIFFilter::GetOutputDIB void   )  [protected, virtual]
 

Casts the current output DIB to be a generic OutputDIB class. This allows the same code to be re-used in the base class.

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/6/00 Returns OutputDIB* - A pointer to DestGIF.

Reimplemented from MaskedFilter.

Definition at line 2480 of file giffiltr.cpp.

02481 {
02482     // Perform an upcast to allow the pointer to be used in a generic manner.
02483     return static_cast<OutputDIB*> ( &DestGIF );
02484 }

INT32 TI_GIFFilter::HowCompatible PathName Filename,
ADDR  HeaderStart,
UINT32  HeaderSize,
UINT32  FileSize
[virtual]
 

Determine if this filter can load the specified file.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/4/95
Parameters:
Filename - name of the file. [INPUTS] HeaderStart - Address of the first few bytes of the file. HeaderSize - the number of bytes in the header pointed to by FileStart. FileSize - the size of the whole file, in bytes.
Returns:
0 => Not a GIF file. 10 => It is a GIF file.

Reimplemented from Filter.

Definition at line 1923 of file giffiltr.cpp.

01924 {
01925 TRACEUSER( "Neville", _T("TI_GIFFilter::HowCompatible"));   
01926     // We need to remember what we thought of this file in our class variable.
01927     // So, set it to a nice default value at the start.
01928     GIFHowCompatible = 0;
01929 
01930     // Check that we've got enough data to do our check
01931     // This is really sizeof(GIFINFOHEADER) but this returns 14 instead of 13
01932     // as it rounds to the nearest word boundary
01933     const size_t GIFHeaderSize = sizeof(char)* 6 + sizeof(WORD) * 2 + sizeof(BYTE) * 3;
01934     if (HeaderSize < GIFHeaderSize)
01935     {
01936         // Not enough data - ignore this file.
01937         return 0;
01938     }
01939 
01940     // Check the header for the "GIF" signature.
01941     LPGIFINFOHEADER pHeader = (LPGIFINFOHEADER) HeaderStart;
01942 
01943     if (
01944         ( strncmp( pHeader->giName, "GIF89a", 6 ) == 0 ) ||
01945         ( strncmp( pHeader->giName, "GIF87a", 6 ) == 0 )
01946        )
01947     {
01948         // the other fields in the GIFINFOHEADER don't really hold any useful information
01949         // and really finding GIF87a/89a should be good enough to determine that there is
01950         // a high chance that this is a GIF file.
01951 
01952         // Remember what we thought in our class variable.
01953         GIFHowCompatible = 10;
01954     }
01955     else
01956     {
01957         // No GIF signature - we don't want this file.
01958         GIFHowCompatible = 0;
01959     }
01960                 
01961 TRACEUSER( "Neville", _T("TI_GIFFilter::HowCompatible returning = %d\n"),GIFHowCompatible);
01962     // Return the found value to the caller.
01963     return GIFHowCompatible;
01964 }

BOOL TI_GIFFilter::Init void   )  [virtual]
 

Initialise an TI_GIFFilter object.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/4/95
Returns:
TRUE if the filter was initialised ok, FALSE otherwise.

Errors: Will fail if not enough memory to initialise.

See also:
EPSStack

Reimplemented from MaskedFilter.

Reimplemented in PreviewFilterGIF.

Definition at line 665 of file giffiltr.cpp.

00666 {
00667     // Get the OILFilter object
00668     pOILFilter = new GIFOILFilter(this);
00669     if (pOILFilter==NULL)
00670         return FALSE;
00671 
00672     // Load the description strings
00673     FilterName.Load(_R(IDN_FILTERNAME_GIF));
00674     FilterInfo.Load(_R(IDN_GIF_FILTERINFO));
00675 
00676     if (!GIFExportOptions::Declare())
00677     {
00678         return FALSE;
00679     }
00680 
00681     // All ok
00682     return TRUE;
00683 }

BOOL TI_GIFFilter::IsDefaultDocRequired const TCHAR pcszPathName  )  [virtual]
 

Is called when a TIFF or GIF is opened, to let us say whether we need a default document.

> virtual BOOL TI_GIFFilter::IsDefaultDocRequired(const TCHAR* pcszPathName);

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/11/97
We need to open GIFs into the Animated template (in case they're animated). We do this as follows: we tell the Document system that the next template to use is the animation template. Then we return TRUE so that this template is loaded.

Not very elegant, but it works.

Reimplemented from BaseBitmapFilter.

Definition at line 2537 of file giffiltr.cpp.

02538 {
02539     //Tell the system to use the default animation template
02540     CCamDoc::SetNextTemplateToUse( CTemplateManager::GetDefaultAnimationTemplate() );
02541 
02542     return TRUE;
02543 }

BOOL TI_GIFFilter::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 BaseBitmapFilter.

Reimplemented in MakeBitmapFilter.

Definition at line 2097 of file giffiltr.cpp.

02098 {
02099     // Webster - RanbirR
02100     // Animated GIF's do not support 24 colour bitmaps.
02101     // However, allow this format here, since we later convert to 8 Bpp.
02102             
02103     return (Bpp == 24 || Bpp == 8 || Bpp == 4 || Bpp == 1);
02104 }

void TI_GIFFilter::PostGetExportOptions BitmapExportOptions pOptions  )  [virtual]
 

Reimplemented from BaseBitmapFilter.

Definition at line 1274 of file giffiltr.cpp.

01275 {
01276     // should be of this type
01277     GIFExportOptions* pGIFOptions = (GIFExportOptions*)pOptions;
01278     ERROR3IF(!pGIFOptions->IS_KIND_OF(GIFExportOptions), "pGIFOptions isn't");
01279 
01280     // do the baseclass options
01281     MaskedFilter::PostGetExportOptions(pOptions);
01282 
01283     // do the specific to this class options
01284     SetDepthToRender(pGIFOptions->GetDepth());
01285 
01286     m_DoingAnimation = (pGIFOptions->GetSelectionType() == SOMEBITMAPS);
01287 
01288     // Filter type can be changed by the export options dialog box from say 
01289     // TI_GIF to TI_GIF_INTERLACED
01290     UINT32 Silliness = pGIFOptions->WantTransparent() ? 2 : 0;
01291     Silliness |= pGIFOptions->WantInterlaced() ? 1 : 0;
01292     if (Silliness >= 0 && Silliness < 4)
01293     {
01294         Compression = Silliness;
01295         // Compression ranges from 0 .. 3 so map this onto our filter types
01296 //      FilterID = Silliness + TI_GIF;
01297         switch (Silliness)
01298         {
01299         case 0: s_FilterType = TI_GIF; break;
01300         case 1: s_FilterType = TI_GIF_INTERLACED; break;
01301         case 2: s_FilterType = TI_GIF_TRANSPARENT; break;
01302         case 3: s_FilterType = TI_GIF_TRANSINTER; break;
01303         case 4: s_FilterType = TI_GIF_ANIM; break;
01304         }
01305 
01306         if (pGIFOptions->WantTransparent() && pGIFOptions->GetSelectionType() == SELECTION)
01307             DoingMask = TRUE;
01308     }
01309 }

BOOL TI_GIFFilter::ReadFromFile OILBitmap pOilBitmap,
BaseCamelotFilter pFilter,
CCLexFile pFile,
BOOL  IsCompressed
[virtual]
 

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. It is also used for extracting previews. 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.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/6/96
Parameters:
pOilBitmap pointer to the oil bitmap data to be filled in [INPUTS] pFilter - the BaseCamelotFilter which provides functions like progress update (not used at the moment 20/01/97) pFile - the CCFile class to use to read the data from IsCompressed - Flag to say the bitmap is compressed or not.
Will have filled in BMInfo pointer to the bitmap header to fill in [OUTPUTS] BMBytes pointer to the bitmap data to fill in
Returns:
TRUE if worked, FALSE if failed.

Reimplemented from BaseBitmapFilter.

Definition at line 732 of file giffiltr.cpp.

00734 {
00735     ERROR2IF(pOilBitmap == NULL,FALSE,"TI_GIFFilter::ReadFromFile null OilBitmap pointer");
00736     // no pFilter means we don't get a progress WEBSTER-Martin-20/01/97
00737     // as we are calling this from BaseFileDialog::GetPreviewBitmapFromFile we don't have
00738     // a BaseCamelotFilter. However GIFUtil::ReadImage expects a 100% progress bar.
00739     // ERROR2IF(pFilter == NULL,FALSE,"TI_GIFFilter::ReadFromFile null pFilter pointer");
00740     ERROR2IF(pFile == NULL,FALSE,"TI_GIFFilter::ReadFromFile null pFile pointer");
00741 
00742     if (!pFilter)
00743         BeginSlowJob(-1);   // GIFUtil::ReadImage expects a progress bar.
00744 
00745     // Try to import bitmap as usual binary BMP file.
00746     CWxBitmap* pWBitmap = (CWxBitmap*) pOilBitmap;
00747     
00748     LPBITMAPINFO *pInfo = &(pWBitmap->BMInfo);
00749     LPBYTE *pBytes = &(pWBitmap->BMBytes);
00750 
00751     // Set a default transparent colour
00752     INT32 TransColour = -1;
00753     SetTransColour(TransColour);
00754 
00755     // Blank the offsets just in case
00756     m_LeftOffset = 0;
00757     m_TopOffset = 0;
00758 
00759     // Read from file, no header and using pFilter for progress bar updates
00760     // 20/01/97 In fact pFilter is not used so NULL ptr ok
00761     if (!GIFUtil::ReadFromFile(pFile, pInfo, pBytes, &TransColour, NULL, pFilter))
00762     {
00763         if (!pFilter)
00764             EndSlowJob();
00765         return FALSE;
00766     }
00767 
00768     SetTransColour(TransColour);
00769     UINT32 Bpp = pWBitmap->GetBPP();
00770     if (TransColour != -1 && Bpp <= 8)
00771         pOilBitmap->SetTransparencyIndex(TransColour);
00772 
00773     SetLastBitmap();        // can only import one bitmap at the moment
00774 
00775     if (!pFilter)
00776