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         EndSlowJob();
00777 
00778     // Everything went ok and we imported the bitmap ok
00779     return TRUE;
00780 }

BOOL TI_GIFFilter::ReadFromFile OILBitmap pOilBitmap  )  [virtual]
 

Actually does the process of reading a bitmap from a file. Inherited classes override this to read in different file formats.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/8/95
Parameters:
pOilBitmap pointer to the oil bitmap data to be filled in [INPUTS]
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 798 of file giffiltr.cpp.

00799 {
00800     ERROR2IF(pOilBitmap == NULL,FALSE,"TI_GIFFilter::ReadFromFile null OilBitmap pointer");
00801     
00802     // Try to import the bitmap as a GIF file.
00803         
00804     CCLexFile* pImportFile = GetImportFile();
00805     ERROR2IF(pImportFile==NULL,FALSE,"TI_GIFFilter::ReadFromFile - No import file");
00806 
00807     UINT32 ImportMsgId = GetImportMsgID();      
00808     String_64 ProgressString(ImportMsgId);
00809     ProgressString = GetImportProgressString(pImportFile, ImportMsgId);
00810 
00811     // Set a default transparent colour
00812     INT32 TransColour = -1;
00813     SetTransColour(TransColour);
00814     INT32 nBitmapToRead = GetBitmapNumber();
00815 
00816     CWxBitmap* pWBitmap = (CWxBitmap*)pOilBitmap;
00817     
00818     LPBITMAPINFO *pInfo = &(pWBitmap->BMInfo);
00819     LPBYTE *pBytes = &(pWBitmap->BMBytes);
00820     // Receives the Bitmap delay/Restore value from the Import.
00821     UINT32 Delay=0;
00822     GIFDisposalMethod Restore = GDM_LEAVE;
00823 
00824     // Blank the offsets just in case
00825     m_LeftOffset = 0;
00826     m_TopOffset = 0;
00827 
00828     // The GIF filter liked it very much and so use it, showing progress bar
00829     if (GIFUtil::ReadFromFile(pImportFile, pInfo, pBytes, &TransColour,nBitmapToRead, &ProgressString, NULL,
00830                               &Delay, &Restore, &m_LeftOffset, &m_TopOffset))
00831     {
00832         // Set the Delay\Restore value of the OILBitmap.
00833         pOilBitmap->SetBitmapAnimDelay(Delay);
00834         pOilBitmap->SetAnimationRestoreType(Restore);
00835 
00836         // Set the offset positions
00837         pOilBitmap->SetLeftOffset(m_LeftOffset);
00838         pOilBitmap->SetTopOffset(m_TopOffset);
00839 
00840         // Pass on the transparent colour that we found in the loading process
00841         // -1 if none found.  
00842         SetTransColour(TransColour);
00843         pOilBitmap->SetTransparencyIndex(TransColour);
00844         if (nBitmapToRead == -1)
00845             SetLastBitmap();
00846         else
00847             SetBitmapNumber(nBitmapToRead);
00848         return TRUE;
00849     }
00850     
00851     return FALSE;
00852 }

BOOL TI_GIFFilter::SaveExportBitmapsToFile CCLexFile pFile,
PathName pPath,
BitmapExportParam pParam,
BOOL  DontShowFileName = FALSE
[virtual]
 

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.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/04/97
Parameters:
pDiskFile - the file to put the exported data into [INPUTS] pPath - the pathname of the file to be exported to pParam - the data to use when exporting the bitmaps DontShowFileName - if set to true then don't show the filename in the progress string
Returns:
TRUE if worked, FALSE if failed.
See also:
GrabFrame Filter::DoExportBitmaps;

Reimplemented from BaseBitmapFilter.

Definition at line 1521 of file giffiltr.cpp.

01523 {
01524 #if defined(DO_EXPORT) && !defined(EXCLUDE_FROM_XARALX)
01525     ERROR2IF(pFile == NULL || pPath == NULL, FALSE,"NULL Parameters");
01526     ERROR2IF(pParam == NULL,FALSE,"TI_GIFFilter::DoExportBitmaps null BitmapExportParam specified");
01527 
01528     BOOL ok = TRUE;
01529 
01530     // Make sure the Region pointer is NULL for the time being
01531     ExportRegion = NULL;
01532 
01533     ERROR2IF(!pParam->IS_KIND_OF(GIFAnimationExportParam), FALSE, "pParam isn't GIFAnimationExportParam");
01534     GIFAnimationExportParam* pGIFOptions = (GIFAnimationExportParam*)pParam;
01535     UINT32 BitmapCount                  = pGIFOptions->GetBitmapCount();        // Number of bitmaps in animation
01536     KernelBitmap * pBitmap              = NULL;
01537     WEB_PALETTE GlobalLocalPal          = pGIFOptions->GetPalette();            // Global or local palette
01538     PALETTE_COLOURS PaletteColours      = pGIFOptions->GetPaletteCols();        // Browser or Optimised palette
01539     BOOL SaveLocalPalette               = FALSE;                                // Default to global palette
01540     if (GlobalLocalPal == PAL_LOCAL) // && PaletteColours == PAL_OPTIMIZED)
01541         SaveLocalPalette = TRUE;
01542 
01543     Spread * pSpread = Document::GetSelectedSpread();
01544 
01545     LPBITMAPINFO pOldInfo               = NULL;
01546     LPBYTE pOldBytes                    = NULL;
01547     LPBITMAPINFO pDiffInfo              = NULL;
01548     LPBYTE pDiffBytes                   = NULL;
01549     LPBITMAPINFOHEADER pTrueInfoHeader  = NULL;
01550 
01551     // The list of bitmap frames that we need to output as part of the animatation
01552     List BitmapFrameList;
01553     AnimatedGIFImage * pPrevGIFImage = NULL;
01554     for (UINT32 Index = 0; ok && (Index < BitmapCount); Index++)
01555     {
01556         // Get the bitmap pointer
01557         pBitmap = pGIFOptions->GetBitmap(Index);
01558 
01559         LPBITMAPINFO    pInfo   = NULL;
01560         LPBYTE          pBytes  = NULL;
01561         if (pBitmap)
01562         {
01563             pInfo   = pBitmap->GetBitmapInfo();
01564             pBytes  = pBitmap->GetBitmapBits();
01565         }   
01566         if (pBitmap && pInfo && pBytes)
01567         {
01568             // Get the useful information on the bitmap
01569             UINT32          Bpp     = pBitmap->GetBPP();
01570             INT32           TransColour = -1;
01571             if (Bpp <= 8)
01572             {
01573                  pBitmap->GetTransparencyIndex(&TransColour);
01574                  if (TransColour == -1 && pInfo->bmiColors[0].rgbRed == 255 && pInfo->bmiColors[0].rgbGreen == 255 && pInfo->bmiColors[0].rgbBlue == 255)
01575                  {
01576                      TRACEUSER( "SimonK", _T("taking 1st palette entry as transp since it is white\n"));
01577                      TransColour = 0;
01578                  }
01579             }
01580 
01581             // Recover the restore type assigned to the bitmap which we will then use
01582             // unless we override it further down
01583             GIFDisposalMethod FrameRestore = pBitmap->GetAnimationRestoreType();
01584 
01585             // Recover the delay from the bitmap itself
01586             CENTISECONDS FrameDelay = pBitmap->GetDelay();
01587 
01588             // If we are on the first bitmap then note the first bitmap's size as the
01589             // overall size of the animation
01590             if (ok && Index == 0)
01591             {
01592                 // BITMAPINFO  consists of:-
01593                 //      BITMAPINFOHEADER    bmiHeader;
01594                 //      RGBQUAD             bmiColors[1];
01595                 // This is the real bitmap info header giving the overall size of the export
01596                 pTrueInfoHeader = pBitmap->GetBitmapInfoHeader();
01597             }
01598 
01599             // If we have a previous frame then minimise the amount of bitmap which we will output
01600             // by working out the difference between the two frames and making everything else the
01601             // transparent colour.
01602             LPBITMAPINFO pOutputInfo    = pInfo;
01603             LPBYTE pOutputBytes         = pBytes;
01604             UINT32 LeftOffset               = 0;
01605             UINT32 TopOffset                = 0;
01606             
01607             // Recover the offsets from the bitmap itself. Only really useful if we are using
01608             // pre-loaded bitmaps as single items on the layer.
01609             LeftOffset                  = pBitmap->GetLeftOffset();
01610             TopOffset                   = pBitmap->GetTopOffset();
01611 
01612             // If we are in local optimised mode then we cannot diff the bitmaps as we are overlaying
01613             // and so a change in palette could be very bad indeed!
01614             BOOL DiffFailed = FALSE;
01615             if (pOldInfo && pOldBytes && !SaveLocalPalette)
01616             {
01617                 // Pass in the present bitmap and get a new one back
01618                 BOOL FoundBadOverlay = FALSE;
01619 
01620                 if (pSpread->GetSpreadAnimPropertiesParam().GetIsBackGroundTransp() /*pGIFOptions->GetIsBackGroundTransp()*/)
01621                 {
01622                     // with a transparent background every overlay is a bad overlay
01623                     FoundBadOverlay = TRUE;
01624                 }
01625                 else
01626                 {
01627                     ok = DIBUtil::GenerateDifferenceBitmap(pOldInfo, pOldBytes, pInfo, pBytes,
01628                                                        &pDiffInfo, &pDiffBytes,
01629                                                        TransColour, &FoundBadOverlay);
01630                 }
01631                 // If we have found that we cannot overlay the previous frame then
01632                 // set the restore type to put the background back and forget about
01633                 // the diff bitmap.
01634                 // We must change the previous bitmap's restore type so access the previous
01635                 // item in the output list
01636                 if (FoundBadOverlay)
01637                 {
01638                     if (pPrevGIFImage)
01639                         pPrevGIFImage->SetFrameRestore(GDM_BACKTOBACK);
01640                     FrameRestore = GDM_BACKTOBACK;
01641                 }
01642                 else if (ok && pDiffInfo && pDiffBytes)
01643                 {
01644                     // If everything went ok then output the difference bitmap
01645                     pOutputInfo = pDiffInfo;
01646                     pOutputBytes = pDiffBytes;
01647                     
01648                     // Ensure that we have an overlay restore type
01649                     FrameRestore = GDM_LEAVE;
01650                     if (pPrevGIFImage)
01651                         pPrevGIFImage->SetFrameRestore(GDM_LEAVE);
01652                 }
01653                 else
01654                 {
01655                     // Possible loaded an animation and now wanting to output it again
01656                     // Use the left and top offsets in the bitmap
01657                     // These should have been set up in CheckIfSingleBitmap();
01658                     TRACEUSER( "Neville", _T("Something went wrong, outputting whole bitmap\n"));
01659                     DiffFailed = TRUE;
01660                     //LeftOffset = pBitmap->GetLeftOffset();
01661                     //TopOffset = pBitmap->GetTopOffset();
01662                     //FrameRestore = pBitmap->GetAnimationRestoreType();
01663                 }
01664             }
01665             else if (pOldInfo && pOldBytes && pSpread->GetSpreadAnimPropertiesParam().GetIsBackGroundTransp())
01666             {
01667                 // dont overlay transp images have them back to back
01668                 if (pPrevGIFImage)
01669                     pPrevGIFImage->SetFrameRestore(GDM_BACKTOBACK);
01670                 FrameRestore = GDM_BACKTOBACK;
01671             }
01672 
01673 
01674             // Work out if we can shrink the bitmap down in size
01675             // Only do this if we are not on the first bitmap. Internet Explorer screws up
01676             // as it seems to assume that the size of the first frame is the size of the animation
01677             // rather than taking the true animation size.
01678             // This may re-allocate the difference bitmap for us to a new smaller size
01679             // In this case it will return a left and top offset for us to use.
01680             if (ok && pOutputInfo && pOutputBytes && Index != 0 &&
01681                 LeftOffset == 0 && TopOffset == 0 && !DiffFailed)
01682             {
01683                 ok = DIBUtil::GenerateSubRegionBitmap(pOutputInfo, pOutputBytes,
01684                                                       &pDiffInfo, &pDiffBytes, TransColour,
01685                                                       &LeftOffset, &TopOffset);
01686                 if (ok && pDiffInfo && pDiffBytes)
01687                 {
01688                     // If everything went ok then output the sub-region bitmap
01689                     pOutputInfo = pDiffInfo;
01690                     pOutputBytes = pDiffBytes;
01691                 }
01692                 // Otherwise just output the whole bitmap
01693             }
01694 
01695             // Add an item to the list of frames to output
01696             AnimatedGIFImage * pGIFImage = new AnimatedGIFImage(TransColour, FrameRestore, FrameDelay,
01697                                                                 LeftOffset, TopOffset,
01698                                                                 pOutputInfo, pOutputBytes,
01699                                                                 pDiffInfo, pDiffBytes);
01700             if (pGIFImage == NULL)
01701             {
01702                 ok = FALSE;
01703                 break;
01704             }
01705 
01706             BitmapFrameList.AddTail(pGIFImage);
01707             
01708             // Remember this bitmap for later use
01709             pOldInfo = pInfo;
01710             pOldBytes = pBytes;
01711 
01712             pPrevGIFImage = pGIFImage;
01713 
01714             // blank these so as 
01715             pDiffInfo   = NULL;
01716             pDiffBytes  = NULL;
01717         }
01718     }
01719 
01720     if (!ok)
01721     {
01722         ERROR3("Failed to make the output list of GIF images");
01723         // Clean out the list of GIF images that we made ready for exporting
01724         BitmapFrameList.DeleteAll();
01725         return FALSE;
01726     }
01727 
01728     // **** Actually output the data to file
01729     
01730     // Used to open the file up before starting DoExport. But this meant a cancel on the export
01731     // options dialog had filled the file, if it was already present. So now up up here if
01732     // not open already. In the PreviewBitmap case the file will already be open.
01733     if (!pFile->isOpen())
01734     {
01735         if (pFile->IsKindOf(CC_RUNTIME_CLASS(CCDiskFile)))
01736         {
01737             ok = OpenExportFile((CCDiskFile*) pFile, pPath);
01738         }
01739         else
01740         {
01741             TRACEUSER( "JustinF", _T("Tried to open non-CCDiskFile in BaseBitmapFilter::DoExportBitmaps\n"));
01742             ok = FALSE;
01743         }
01744     }
01745 
01746     if (!ok)
01747     {
01748         ERROR3("Failed to open the export file for GIF images");
01749         // Clean out the list of GIF images that we made ready for exporting
01750         BitmapFrameList.DeleteAll();
01751         return FALSE;
01752     }
01753 
01754     // Make a note of the Disk file we are to use
01755     OutputFile = pFile;
01756 
01757     // Recover information on the animation 
01758     const BOOL WantInterlaced               = FALSE;        // We never want interlacing
01759     UINT32 LoopCount                            = pGIFOptions->GetAnimLoop();           // Looping for the animation
01760     const CENTISECONDS AnimationDelay       = pGIFOptions->GetGlobalAnimDelay();    // Delay in CentiSeconds
01761 
01762     // Check that we have an animation size information block
01763     ERROR2IF(pTrueInfoHeader==NULL,FALSE,"TI_GIFFilter::WriteToFile BitmapInfoHeader pointer is null");
01764 
01765     UINT32  Index = 0;
01766     AnimatedGIFImage * pCurrentGIFImage = (AnimatedGIFImage *)BitmapFrameList.GetHead();
01767     while ( ok && pCurrentGIFImage)
01768     {
01769         // Tecover the info from the GIF image item
01770         // This is the real bitmap info header giving the overall size of the export
01771         LPBITMAPINFO pOutputInfo        = pCurrentGIFImage->GetOutputInfo();
01772         LPBYTE pOutputBytes             = pCurrentGIFImage->GetOutputBits();
01773         INT32 TransColour               = pCurrentGIFImage->GetTransColour();
01774         GIFDisposalMethod FrameRestore  = pCurrentGIFImage->GetFrameRestore();
01775         CENTISECONDS FrameDelay         = pCurrentGIFImage->GetFrameDelay();
01776         UINT32 LeftOffset                   = pCurrentGIFImage->GetLeftOffset();
01777         UINT32 TopOffset                    = pCurrentGIFImage->GetTopOffset();
01778 
01779         // BITMAPINFO  consists of:-
01780         //      BITMAPINFOHEADER    bmiHeader;
01781         //      RGBQUAD             bmiColors[1];
01782 
01783         // This is the header for the bitmap that we are actually outputting
01784         LPBITMAPINFOHEADER pInfoHeader = &pOutputInfo->bmiHeader;
01785         ERROR2IF(pInfoHeader==NULL,FALSE,"TI_GIFFilter::WriteToFile BitmapInfoHeader pointer is null");
01786             
01787         LPRGBQUAD pPalette = &(pOutputInfo->bmiColors[0]);
01788         ERROR2IF(pPalette==NULL,FALSE,"TI_GIFFilter::WriteToFile palette pointer is null");
01789 
01790         // If we are on the first bitmap then out the file start information
01791         if (ok && Index == 0)
01792         {
01793             // We force a transparent colour of -1 so the transparent index colour is not changed to white in the global colour table.
01794             ok = DestGIF.OutputGifFileHeader(pFile, pTrueInfoHeader, TRUE, TransColour, NULL, pPalette);
01795             if (!ok)
01796                 break;
01797 
01798             // Shall we output a Loop block ?
01799 
01800             // We only put a loop block in if the loop count is 0, or > 1
01801             // and we subtract 1 from values other than 0, so that the
01802             // loop count represent the number of times the animation
01803             // is 'played' rather than 'repeated' ....
01804             // 
01805             // ie.  0, loop block with value 0.     Repeat forever.
01806             //      1, no loop block.               One shot animation.
01807             //      2, loop block with value 1.     Plays animation 2 times.
01808             //      3, loop block with value 2.     Plays animation 3 times.
01809             //      4, loop block with value 3.     Plays animation 4 times.
01810             //      etc ...
01811             if (LoopCount != 1)
01812             {
01813                 if (LoopCount > 1) LoopCount -= 1;
01814 
01815                 // Output a loop block then ...
01816                 ok = DestGIF.OutputAnimationControl(pFile, LoopCount);
01817                 if (!ok)
01818                     break;
01819             }
01820 
01821             // For now force a restore type of restore background on the first frame 
01822             //AnimationRestore = GDM_BACKTOBACK;
01823         }
01824 
01825         // Actually write the destination bitmap out to the file showing an hourglass
01826         // and/or progress bar as we go. Always show the Exporting message.
01827         // Need to do in one go due to interlacing
01828         if (ok)
01829         {
01830             String_64 ProgressString(ExportingMsgID);
01831             // If the caller has requested it, then supress the filename
01832             // Useful if we are doing Browser preview so that the temp file does not
01833             // get shown.
01834             if (DontShowFileName)
01835                 ProgressString = GetExportProgressString(NULL, ExportingMsgID);
01836             else
01837                 ProgressString = GetExportProgressString(pFile, ExportingMsgID);
01838             BeginSlowJob(100, FALSE, &ProgressString);
01839         
01840             ok = DestGIF.OutputGifImageExtensionHeader( pFile, WantInterlaced,
01841                                                         TransColour,
01842                                                         FrameDelay,
01843                                                         FrameRestore);
01844 
01845             // If we are doing an animation with an optimised palette then we will need to
01846             // save out this palette as a local colour table (the first frame uses the global table)
01847             BOOL OutputLocalColourTable = (SaveLocalPalette && Index != 0);
01848             if (ok)
01849                 ok = DestGIF.OutputGifImageBits(pFile, pOutputBytes,
01850                                                 WantInterlaced, OutputLocalColourTable,
01851                                                 NULL,
01852                                                 pInfoHeader->biWidth, pInfoHeader->biHeight, 
01853                                                 LeftOffset, TopOffset,
01854                                                 pPalette, pInfoHeader->biClrUsed, pInfoHeader->biBitCount);
01855         }
01856 
01857         Index ++;
01858 
01859         // Get the next item in the list
01860         pCurrentGIFImage = (AnimatedGIFImage *)BitmapFrameList.GetNext(pCurrentGIFImage);
01861     }
01862 
01863     // Finish the file off
01864     if (ok)
01865         ok = DestGIF.OutputGifTerminator(pFile);
01866 
01867     // Clean out the list of GIF images that we made ready for exporting
01868     BitmapFrameList.DeleteAll();
01869 
01870     // All done - deallocate dynamic objects, stop the progress display/hourglass
01871     // and return success. (Also closes file. Eh! Does it?).
01872     CleanUpAfterExport();
01873 
01874     return ok;
01875 #endif
01876     return FALSE;
01877 }

BOOL TI_GIFFilter::SetAnimationPropertiesFromLoaded Spread pSpread  )  [protected, virtual]
 

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.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/7/97
Parameters:
pSpread the spread that the bitmaps have been put on [INPUTS]
Returns:
TRUE if was ok, FALSE otherwise.

Reimplemented from BaseBitmapFilter.

Definition at line 1086 of file giffiltr.cpp.

01087 {
01088     ERROR2IF(pSpread == NULL,FALSE,"SetAnimationPropertiesFromLoaded pSpread = NULL");
01089     
01090     // Find out about the palettes that the bitmaps have
01091     BOOL SamePalettes       = FALSE;
01092     BOOL OurBrowserPalette  = FALSE;
01093     BOOL AllHaveBitmaps     = FALSE;
01094     BOOL AllWithinCount     = FALSE;
01095     UINT32 PaletteEntries       = 0;
01096     CheckSingleBitmapsOnSpread(pSpread, &SamePalettes, &OurBrowserPalette, &AllHaveBitmaps,
01097                                &AllWithinCount, &PaletteEntries);
01098 
01099     // Grab the present animation properties from the spread
01100     AnimPropertiesParam *pProperties = &pSpread->GetSpreadAnimPropertiesParam();
01101     if (pProperties != NULL)
01102     {
01103         // Make any changes that we require
01104         pProperties->SetDither(XARADITHER_NONE);
01105         
01106         if (SamePalettes && OurBrowserPalette)
01107         {
01108             // Set ourselves a global browser palette
01109             pProperties->SetPaletteCols(PALCOL_BROWSER);
01110             pProperties->SetPalette(PAL_GLOBAL);
01111         }
01112         else if (SamePalettes)
01113         {
01114             // Set ourselves a global optimised palette
01115             pProperties->SetPaletteCols(PALCOL_OPTIMIZED);
01116             pProperties->SetPalette(PAL_GLOBAL);
01117             if (PaletteEntries > 0)
01118                 pProperties->SetNumColsInPalette(PaletteEntries);
01119         }
01120         else
01121         {
01122             // Set ourselves a local optimised palette
01123             pProperties->SetPaletteCols(PALCOL_OPTIMIZED);
01124             pProperties->SetPalette(PAL_LOCAL);
01125             // Ensure that the optimised palette contains
01126             if (PaletteEntries > 0)
01127                 pProperties->SetNumColsInPalette(PaletteEntries);
01128         }
01129 
01130         // Put back the new animation properties
01131         pSpread->SetSpreadAnimPropertiesParam(*pProperties);
01132 
01133         // Tell anybody that is interested about the changes    
01134         BROADCAST_TO_ALL(SpreadMsg(pSpread, SpreadMsg::ANIMATIONPROPERTIESCHANGED));
01135     }
01136 
01137     return TRUE;
01138 }

BOOL TI_GIFFilter::SetFlagsFromBitmap Layer pLayer,
KernelBitmap pBitmap,
UINT32  nBitmapToRead
[protected, virtual]
 

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.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/5/97
Parameters:
pLayer the layer that the bitmap is being put on [INPUTS] pBitmap the bitmap being placed on the layer nBitmapToRead the number of the bitmap in the sequence
Returns:
TRUE if was ok, FALSE otherwise.

Reimplemented from BaseBitmapFilter.

Definition at line 988 of file giffiltr.cpp.

00990 {
00991     if (pBitmap && pLayer)
00992     {
00993         // transfer the disposal method from the bitmap to the layer
00994         GIFDisposalMethod method = pBitmap->GetAnimationRestoreType();
00995         // First frame is always restore background
00996         if (nBitmapToRead == 1)
00997             m_PreviousMethod = GDM_BACKTOBACK;
00998         
00999         // REM use the previous frame's restore method, not this one!
01000         switch (m_PreviousMethod)
01001         {
01002             case GDM_NONE:
01003             case GDM_LEAVE:
01004                 // Always set frame overlay
01005                 pLayer->SetOverlay(TRUE);
01006                 // As we are setting overlay, solid is not required
01007                 pLayer->SetSolid(FALSE);
01008                 // This seems to work but may need some extra clauses....
01009                 //if (nBitmapToRead == 1)
01010                 //  pLayer->SetSolid(TRUE);
01011                 //else
01012                 //  pLayer->SetSolid(FALSE);
01013                 break;
01014             case GDM_PREVIOUS:
01015             case GDM_BACKTOBACK:
01016                 // Always set frame overlay false and solid false
01017                 pLayer->SetOverlay(FALSE);
01018                 pLayer->SetSolid(FALSE);
01019                 break;
01020         }
01021 
01022         // Note the new restore method for the next frame
01023         m_PreviousMethod = method;
01024 
01025         // transfer the delay from the bitmap to the layer
01026         UINT32 delay = pBitmap->GetDelay();
01027         pLayer->SetFrameDelay(delay);
01028     }
01029 
01030     return TRUE;
01031 }

BOOL TI_GIFFilter::ShouldReuseExistingBitmaps  )  [virtual]
 

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.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/6/96
Returns:
True if this filter should try and reuse existing bitmaps during import

Reimplemented from BaseBitmapFilter.

Definition at line 2463 of file giffiltr.cpp.

02464 {
02465     return (GetBitmapNumber() <= 1);
02466 }

BOOL TI_GIFFilter::WriteBitmapToFile KernelBitmap pKernelBitmap,
double  Dpi
[protected, virtual]
 

Physically put the bitmap into the disk. Inherited classes override this to write in different file formats.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/4/95
Parameters:
Pointer to the bitmap to save. [INPUTS] Dpi of the bitmap to be saved
Returns:
TRUE if worked, FALSE if errored.
See also:
WriteDataToFile(); AccusoftFilters::WriteToFile; AccusoftFilters::WriteDataToFile;

Reimplemented from BaseBitmapFilter.

Definition at line 2000 of file giffiltr.cpp.

02001 {
02002     ERROR2IF(pKernelBitmap == NULL,FALSE,"TI_GIFFilter::WriteBitmapToFile null bitmap pointer specified");
02003 
02004     // Get a pointer to the actual bitmap so that we can get some details from it.
02005     OILBitmap *pOilBitmap = pKernelBitmap->ActualBitmap;
02006     ERROR2IF(pOilBitmap == NULL,FALSE,"TI_GIFFilter::WriteBitmapToFile null oil bitmap pointer");
02007 
02008     // Now get the pointer to the info header and actual bits data.
02009     // Need to use the actual bitmap pointer
02010     CWxBitmap* pWBitmap = (CWxBitmap*)pOilBitmap;
02011     LPBITMAPINFO pInfo = pWBitmap->BMInfo;
02012     LPBYTE pBytes = pWBitmap->BMBytes;
02013 //  UINT32 Bpp = pWBitmap->GetBPP();
02014 
02015     // Now, save the data out showing the correct progress string
02016     String_64 ProgressString(ExportingMsgID);
02017     BOOL ok = FALSE;
02018 
02019     ok = WriteToFile(OutputFile, pInfo, pBytes, &ProgressString);
02020     
02021     return ok;
02022 }

BOOL TI_GIFFilter::WriteBitmapToFile KernelBitmap pKernelBitmap,
BaseCamelotFilter pFilter,
CCLexFile pFile,
INT32  Compression
[virtual]
 

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.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/6/96
Parameters:
pKernelBitmap - Pointer to the bitmap to be exported. [INPUTS] pFilter - Pointer to the BaseCamelot filter which provides progress functions pFile - Pointer to the CCFile class to use for export Compression - used to flag how much compression of the data is required.
Returns:
TRUE if worked, FALSE if errored.
See also:
BitmapListComponent::SaveBitmapDefinition;

Reimplemented from BaseBitmapFilter.

Definition at line 2048 of file giffiltr.cpp.

02050 {
02051     ERROR2IF(pKernelBitmap == NULL,FALSE, "TI_GIFFilter::WriteBitmapToFile null pKernelBitmap");
02052     ERROR2IF(pFilter == NULL,FALSE, "TI_GIFFilter::WriteBitmapToFile null pFilter");
02053     ERROR2IF(pFile == NULL,FALSE, "TI_GIFFilter::WriteBitmapToFile null pFile");
02054 
02055     // Get a pointer to the actual bitmap so that we can get some details from it.
02056     OILBitmap *pOilBitmap = pKernelBitmap->ActualBitmap;
02057     ERROR2IF(pOilBitmap == NULL,FALSE,"TI_GIFFilter::WriteBitmapToFile null oil bitmap pointer");
02058 
02059     // Now get the pointer to the info header and actual bits data.
02060     // Need to use the actual bitmap pointer
02061     CWxBitmap* pWBitmap = (CWxBitmap*)pOilBitmap;
02062     LPBITMAPINFO Info = pWBitmap->BMInfo;
02063     LPBYTE Bytes = pWBitmap->BMBytes;
02064     UINT32 Bpp = pWBitmap->GetBPP();
02065 
02066     // Now, save the data out showing the correct progress string
02067     BOOL ok = FALSE;
02068     // We must output with no interlacing and no transparency as otherwise things like
02069     // the progress bar update will be screwed, so force the filter type to be simple.
02070     s_FilterType = TI_GIF;
02071 
02072     BOOL Interlace = FALSE; // Don't use interlacing by default
02073     INT32 Transparent = -1; // colour or -1 = no transparency
02074     if (Bpp <= 8)
02075         pOilBitmap->GetTransparencyIndex(&Transparent);
02076 
02077     // Write to file, using pFilter for progress bar updates
02078     ok = WriteToFile(pFile, Info, Bytes, Interlace, Transparent, pFilter);
02079     
02080     return ok;
02081 }

BOOL TI_GIFFilter::WriteDataToFile BOOL  End,
UINT32  Bpp,
UINT32  Compression
[static, protected]
 

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.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/4/95
Parameters:
End - TRUE if this is the last block of the file. [INPUTS] Bpp - output depth in terms of bits per pixel Compression - usually True if compression required, False otherwise In the GIF case this is used to pass in the transparency and interlace state.
Returns:
TRUE if worked, FALSE if errored.
See also:
WriteToFile(); AccusoftFilters::WriteToFile; AccusoftFilters::WriteDataToFile;

Definition at line 1899 of file giffiltr.cpp.

01900 {
01901     ERROR2(FALSE,"TI_GIFFilter::WriteDataToFile called when not implemented");
01902     return FALSE;
01903 }

BOOL TI_GIFFilter::WriteFileEnd void   )  [protected, virtual]
 

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.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/6/96
Parameters:
- [INPUTS]
Returns:
FALSE if failed else TRUE

Reimplemented from BaseBitmapFilter.

Definition at line 2410 of file giffiltr.cpp.

02411 {
02412     /*BOOL ok =*/ DestGIF.OutputGifTerminator(OutputFile);
02413     return DestGIF.TidyUp();
02414 }

BOOL TI_GIFFilter::WriteFileHeader void   )  [protected, virtual]
 

To write out the file specific header data.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/6/96
Parameters:
- [INPUTS]
Returns:
FALSE if failed else TRUE

Reimplemented from BaseBitmapFilter.

Definition at line 2340 of file giffiltr.cpp.

02341 {
02342     m_AnimationFrame = 0;
02343     return(TRUE);   
02344 }

BOOL TI_GIFFilter::WriteFrame void   )  [protected, virtual]
 

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.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/6/96
Parameters:
- [INPUTS]
Returns:
FALSE if failed else TRUE

Reimplemented from BaseBitmapFilter.

Definition at line 2373 of file giffiltr.cpp.

02374 {
02375     return MaskedFilter::WriteToFile ( TRUE );
02376 }

BOOL TI_GIFFilter::WritePostFrame void   )  [protected, virtual]
 

To write out any frame specific info after the image.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/6/96
Parameters:
- [INPUTS]
Returns:
FALSE if failed else TRUE

Reimplemented from BaseBitmapFilter.

Definition at line 2388 of file giffiltr.cpp.

02389 {
02390     BOOL ok = EndWriteToFile();
02391 
02392     if (m_DoingAnimation)
02393         m_AnimationFrame++;
02394 
02395     return ok;
02396 }

BOOL TI_GIFFilter::WritePostOptimisedPalette void   )  [protected, virtual]
 

Called after an optimised palette has been generated.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/6/96
Parameters:
- [INPUTS]
Returns:
FALSE if failed else TRUE

Reimplemented from BaseBitmapFilter.

Definition at line 2443 of file giffiltr.cpp.

02444 {
02445     if (m_AnimationFrame > 0)
02446         return DestGIF.ReStartFile(pOptimisedPalette);
02447     else
02448         return TRUE;
02449 }

BOOL TI_GIFFilter::WritePreFrame void   )  [protected, virtual]
 

To write out any frame specific info before the image.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/6/96
Parameters:
- [INPUTS]
Returns:
FALSE if failed else TRUE

Reimplemented from BaseBitmapFilter.

Definition at line 2356 of file giffiltr.cpp.

02357 {
02358     return DestGIF.ReStartFile(NULL);
02359 }

BOOL TI_GIFFilter::WritePreSecondPass void   )  [protected, virtual]
 

Called to do any processing required after the first and before the second pass of a two pass export.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/6/96
Parameters:
- [INPUTS]
Returns:
FALSE if failed else TRUE

Reimplemented from BaseBitmapFilter.

Definition at line 2427 of file giffiltr.cpp.

02428 {
02429     return EndWriteToFile();
02430 }

BOOL TI_GIFFilter::WriteToFile CCLexFile File,
LPBITMAPINFO  Info,
LPBYTE  Bits,
BOOL  Interlace,
INT32  Transparent,
BaseCamelotFilter pFilter = NULL
[static, protected]
 

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).

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/7/96
Parameters:
File An opened CCFile that can be written to. It should be positioned at the [INPUTS] start. Caller is responsible for closing it. The file needs to be in Binary mode. Info BITMAPINFO structure for the dib. Bits The bitmap data itself Interlace True if want interlacing, false otherwise Transparent -1 if no transparent colour required, 0 to maximum palette entry to specify the transparent palette entry pFilter is an alternative way of handling the progress bar, assume the progress bar has been start and just call the IncProgressBarCount in BaseCamelotFilter to do the progress bar update. Defaults to NULL i.e. no progress bar.
- [OUTPUTS]
Returns:
TRUE if worked, FALSE if failed (error will be set accordingly but not reported)

Errors: Calls SetError on FALSE returns. Scope: Static

See also:
AccusoftFilters::WriteToFile; DIBUtil::WriteToFile;

Definition at line 2142 of file giffiltr.cpp.

02145 {
02146     ERROR2IF(File==NULL,FALSE,"TI_GIFFilter::WriteToFile File pointer is null");
02147     ERROR2IF(Info==NULL,FALSE,"TI_GIFFilter::WriteToFile BitmapInfo pointer is null");
02148     ERROR2IF(Bits==NULL,FALSE,"TI_GIFFilter::WriteToFile Bits pointer is null");
02149 
02150     // BITMAPINFO  consists of:-
02151     //      BITMAPINFOHEADER    bmiHeader;
02152     //      RGBQUAD             bmiColors[1];
02153     LPBITMAPINFOHEADER pInfoHeader = &Info->bmiHeader;
02154     ERROR2IF(pInfoHeader==NULL,FALSE,"TI_GIFFilter::WriteToFile BitmapInfoHeader pointer is null");
02155         
02156     LPRGBQUAD pPalette = &(Info->bmiColors[0]);
02157     ERROR2IF(pPalette==NULL,FALSE,"TI_GIFFilter::WriteToFile palette pointer is null");
02158 
02159     // Output the GIF data
02160     BOOL ok = TRUE;
02161     if (Transparent == -1)
02162         ok = DestGIF.OutputGifFileHeader(File, pInfoHeader, FALSE, -1, NULL, pPalette);
02163     else
02164         ok = DestGIF.OutputGifFileHeader(File, pInfoHeader, TRUE, Transparent, NULL, pPalette);
02165     if (ok && Transparent != -1)
02166         ok = DestGIF.OutputGifImageExtensionHeader(File, Interlace, Transparent, 0, 0);
02167     if (ok)
02168         ok = DestGIF.OutputGifImageBits(File, Bits, Interlace, FALSE, pFilter);
02169     
02170     if (ok)
02171         ok = DestGIF.OutputGifTerminator(File);
02172 
02173     DestGIF.TidyUp();
02174     
02175     return ok;
02176 }

BOOL TI_GIFFilter::WriteToFile CCLexFile File,
LPBITMAPINFO  Info,
LPBYTE  Bits,
String_64 ProgressString = NULL
[static, protected]
 

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).

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/4/95
Parameters:
File An opened CCFile that can be written to. It should be positioned at the [INPUTS] start. Caller is responsible for closing it. The file needs to be in Binary mode. Info BITMAPINFO structure for the dib. Bits The bitmap data itself ProgressString allows the user to specify whether they require a progress hourglass or not. If NULL then none is shown, otherwise an progress bar is shown using the text supplied. Defaults to NULL i.e. no progress bar.
- [OUTPUTS]
Returns:
TRUE if worked, FALSE if failed (error will be set accordingly but not reported)

Errors: Calls SetError on FALSE returns. Scope: Static

See also:
AccusoftFilters::WriteToFile; DIBUtil::WriteToFile;

Definition at line 2209 of file giffiltr.cpp.

02211 {
02212     ERROR2IF(File==NULL,FALSE,"TI_GIFFilter::WriteToFile File pointer is null");
02213     ERROR2IF(Info==NULL,FALSE,"TI_GIFFilter::WriteToFile BitmapInfo pointer is null");
02214     ERROR2IF(Bits==NULL,FALSE,"TI_GIFFilter::WriteToFile Bits pointer is null");
02215 
02216     // If the caller has specified a string then assume they require a progress bar
02217     // Start it up.
02218     if (ProgressString != NULL)
02219         BeginSlowJob(100, FALSE, ProgressString);
02220 
02221     // BITMAPINFO  consists of:-
02222     //      BITMAPINFOHEADER    bmiHeader;
02223     //      RGBQUAD             bmiColors[1];
02224     LPBITMAPINFOHEADER pInfoHeader = &Info->bmiHeader;
02225     ERROR2IF(pInfoHeader==NULL,FALSE,"TI_GIFFilter::WriteToFile BitmapInfoHeader pointer is null");
02226         
02227     LPRGBQUAD pPalette = &(Info->bmiColors[0]);
02228     ERROR2IF(pPalette==NULL,FALSE,"TI_GIFFilter::WriteToFile palette pointer is null");
02229 
02230     // Set up our format type flags.
02231     BOOL Interlace = TRUE;  // Use interlace or not
02232     INT32 Transparent = -1; // colour or -1 = no transparency
02233     BOOL MakeTransparent = FALSE;
02234 
02235     switch (s_FilterType)
02236     {
02237         default:
02238         case TI_GIF:
02239             Interlace       = FALSE;
02240             MakeTransparent = FALSE;
02241             break;
02242         case TI_GIF_INTERLACED:
02243             Interlace       = TRUE;
02244             MakeTransparent = FALSE;
02245             break;
02246         case TI_GIF_TRANSPARENT:
02247             Interlace       = FALSE;
02248             MakeTransparent = TRUE;
02249             break;
02250         case TI_GIF_TRANSINTER:
02251             Interlace       = TRUE;
02252             MakeTransparent = TRUE;
02253             break;
02254     }
02255 TRACEUSER( "Neville", _T("TI_GIFFilter::WriteToFile FilterType = %d\n"),s_FilterType);
02256 TRACEUSER( "Neville", _T("TI_GIFFilter::WriteToFile Interlace = %d\n"),Interlace);
02257 TRACEUSER( "Neville", _T("TI_GIFFilter::WriteToFile Transparent = %d\n"),Transparent);
02258 
02259     if (MakeTransparent)
02260     {
02261         // We want to try and output the transparency if possible ...
02262 
02263         // Scan through the palette, and try and find an index with
02264         // the transparency flag set
02265 
02266         Transparent = -1;   // -1 = no transparency
02267         INT32 cols = Info->bmiHeader.biClrUsed;
02268         // If we have zero colours on a bitmap which is 8bpp or less then this is bad.
02269         // This should be translated as the maximum number of colours allowed
02270         if (Info->bmiHeader.biBitCount <= 8 && cols == 0)
02271             cols = 1 << Info->bmiHeader.biBitCount;
02272 
02273         for (INT32 i = 0; i < cols; i++)
02274         {
02275             if (Info->bmiColors[i].rgbReserved == 0xFF)
02276             {
02277                 Transparent = i;
02278                 TRACEUSER( "Neville", _T("GIF output with transp index of %d\n"),Transparent);
02279                 break;
02280             }       
02281         }   
02282 
02283         // WEBSTER - markn 5/2/97
02284         // If we were unable to find the transparent colour, don't save out a transparent image
02285         if (Transparent == -1)
02286             MakeTransparent = FALSE;
02287     }
02288 
02289 TRACEUSER( "Neville", _T("TI_GIFFilter::WriteToFile FilterType = %d\n"),s_FilterType);
02290 TRACEUSER( "Neville", _T("TI_GIFFilter::WriteToFile Interlace = %d\n"),Interlace);
02291 TRACEUSER( "Neville", _T("TI_GIFFilter::WriteToFile Transparent = %d\n"),Transparent);
02292 
02293     // Output the GIF data
02294     BOOL ok = TRUE;
02295     // WEBSTER - markn 5/2/97
02296     // Bug fix - passes the transparent colour index to OutputGifImageExtensionHeader() instead of TRUE
02297     // and also the 'if' statements use the 'MakeTransparent' flag
02298     if (!MakeTransparent)
02299         ok = DestGIF.OutputGifFileHeader(File, pInfoHeader, FALSE, -1, NULL, pPalette);
02300     else
02301     {
02302                 ok = DestGIF.OutputGifFileHeader(File, pInfoHeader, TRUE, Transparent, NULL, pPalette);
02303         if (ok) ok = DestGIF.OutputGifImageExtensionHeader(File, Interlace, Transparent, 0, 0);
02304     }
02305 
02306 //  if (Transparent == -1)
02307 //      ok = DestGIF.OutputGifFileHeader(File, pInfoHeader, FALSE, -1, NULL, pPalette);
02308 //  else
02309 //      ok = DestGIF.OutputGifFileHeader(File, pInfoHeader, TRUE, Transparent, NULL, pPalette);
02310 //  if (ok && Transparent)
02311 //      ok = DestGIF.OutputGifImageExtensionHeader(File, Interlace, TRUE, 0, 0);
02312 
02313     if (ok)
02314         ok = DestGIF.OutputGifImageBits(File, Bits, Interlace, FALSE);
02315     
02316     DestGIF.TidyUp();
02317     
02318     // If started, then stop then progress bar
02319     if (ProgressString != NULL)
02320         EndSlowJob();
02321 
02322     return ok;
02323 }


Member Data Documentation

OutputGIF TI_GIFFilter::DestGIF [static, protected]
 

Definition at line 315 of file giffiltr.h.

UINT32 TI_GIFFilter::Export2ndStageMsgID [protected]
 

Definition at line 326 of file giffiltr.h.

INT32 TI_GIFFilter::GIFHowCompatible [protected]
 

Definition at line 318 of file giffiltr.h.

UINT32 TI_GIFFilter::m_AnimationFrame [protected]
 

Definition at line 323 of file giffiltr.h.

BOOL TI_GIFFilter::m_DoingAnimation [protected]
 

Definition at line 322 of file giffiltr.h.

UINT32 TI_GIFFilter::m_LeftOffset [protected]
 

Definition at line 329 of file giffiltr.h.

GIFDisposalMethod TI_GIFFilter::m_PreviousMethod [protected]
 

Definition at line 347 of file giffiltr.h.

UINT32 TI_GIFFilter::m_TopOffset [protected]
 

Definition at line 330 of file giffiltr.h.

FilterType TI_GIFFilter::s_FilterType = GIF [static, protected]
 

Reimplemented in MakeBitmapFilter.

Definition at line 320 of file giffiltr.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:01:55 2007 for Camelot by  doxygen 1.4.4