#include <giffiltr.h>
Inheritance diagram for TI_GIFFilter:

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 BitmapImportOptions * | CreateImportOptions () const |
| Overrides base class to provide GIF specific options. | |
| virtual BitmapExportOptions * | CreateExportOptions () const |
| Allows derived classes to override this function to provide their own class derived from BitmapExportInfo containing filter specific information. | |
| virtual OutputDIB * | GetOutputDIB (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) | |
Definition at line 235 of file giffiltr.h.
|
|
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.
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 }
|
|
|
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.
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 }
|
|
|
Reimplemented from BaseBitmapFilter. Definition at line 2326 of file giffiltr.cpp. 02327 { 02328 DestGIF.AlterExportPalette( pPalette ); 02329 }
|
|
|
|
|
|
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.
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 }
|
|
|
Allows derived classes to override this function to provide their own class derived from BitmapExportInfo containing filter specific information.
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 }
|
|
|
Overrides base class to provide GIF specific options.
Definition at line 695 of file giffiltr.cpp. 00696 { 00697 GIFImportOptions* pOptions = new GIFImportOptions; 00698 return (BitmapImportOptions*)pOptions; 00699 }
|
|
|
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.
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 }
|
|
||||||||||||||||
|
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.
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 }
|
|
|
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.
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 }
|
|
|
See BaseBitmapClass for interface details Notes: Initializes GIF specific members Scope: Protected.
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 }
|
|
|
Reimplemented from BaseBitmapFilter. Definition at line 249 of file giffiltr.h. 00249 { return TI_GIF; }
|
|
|
Determine if this filter can load the specified file.
Definition at line 1980 of file giffiltr.cpp. 01981 { 01982 return GIFHowCompatible; 01983 }
|
|
|
Base class sets bad so no hint is set.
Reimplemented from MaskedFilter. Definition at line 2515 of file giffiltr.cpp. 02516 { 02517 return(HINTTYPE_GIF); 02518 }
|
|
|
Casts the current output DIB to be a generic OutputDIB class. This allows the same code to be re-used in the base class.
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 }
|
|
||||||||||||||||||||
|
Determine if this filter can load the specified 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 }
|
|
|
Initialise an TI_GIFFilter object.
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 }
|
|
|
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);
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 }
|
|
|
Check if this Bitmap filter can cope with saving at this Bpp/Colour depth.
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 }
|
|
|
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 }
|
|
||||||||||||||||||||
|
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.
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 |