ImageMagickFilter Class Reference

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

#include <imgmgkft.h>

Inheritance diagram for ImageMagickFilter:

MaskedFilter BaseBitmapFilter BitmapFilter Filter ListItem CCObject SimpleCCObject ImageMagickFilterBMP ImageMagickFilterCUR ImageMagickFilterCUT ImageMagickFilterDCM ImageMagickFilterDCX ImageMagickFilterDIB ImageMagickFilterDNG ImageMagickFilterEPDF ImageMagickFilterEPI ImageMagickFilterEPS ImageMagickFilterEPS2 ImageMagickFilterEPS3 ImageMagickFilterEPSF ImageMagickFilterEPSI ImageMagickFilterEPT ImageMagickFilterFAX ImageMagickFilterFITS ImageMagickFilterICO ImageMagickFilterJNG ImageMagickFilterMIFF ImageMagickFilterMPC ImageMagickFilterOTB ImageMagickFilterP7 ImageMagickFilterPALM ImageMagickFilterPAM ImageMagickFilterPBM ImageMagickFilterPCD ImageMagickFilterPCDS ImageMagickFilterPCL ImageMagickFilterPCX ImageMagickFilterPDB ImageMagickFilterPDF ImageMagickFilterPGM ImageMagickFilterPICT ImageMagickFilterPIX ImageMagickFilterPNM ImageMagickFilterPPM ImageMagickFilterPS ImageMagickFilterPS2 ImageMagickFilterPS3 ImageMagickFilterPSD ImageMagickFilterPTIF ImageMagickFilterPWP ImageMagickFilterRLA ImageMagickFilterRLE ImageMagickFilterSCT ImageMagickFilterSFW ImageMagickFilterSUN ImageMagickFilterSVG ImageMagickFilterTGA ImageMagickFilterTIFF ImageMagickFilterTIM ImageMagickFilterTTF ImageMagickFilterVICAR ImageMagickFilterVIFF ImageMagickFilterWBMP ImageMagickFilterWPG ImageMagickFilterXBM ImageMagickFilterXCF ImageMagickFilterXPM ImageMagickFilterXWD List of all members.

Public Member Functions

 ImageMagickFilter ()
 Constructor for an ImageMagickFilter object. The object should be initialised before use.
virtual ~ImageMagickFilter ()
BOOL Init ()
 Initialise an ImageMagickFilter object.
virtual INT32 HowCompatible (PathName &Filename, ADDR HeaderStart, UINT32 HeaderSize, UINT32 FileSize)
 Determine if this filter can load the specified file.
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. 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)
virtual BOOL IsThisBppOk (UINT32 Bpp)
 Check if this Bitmap filter can cope with saving at this Bpp/Colour depth.
virtual INT32 GetImageMagickCompatibility ()
ImageMagickFlags GetCapabilities ()
BOOL HasFlag (ImageMagickFlags f)
virtual BOOL CanDoTransparency ()
virtual BOOL CanDoInterlace ()
virtual BOOL CanDoAlpha ()
virtual BOOL CanDoImport ()
virtual BOOL CanDoExport ()
virtual wxString GetTag ()
virtual TCHARGetExtension ()
virtual INT32 GetCompatibility ()
virtual BOOL CanDoImportDPI ()
virtual void SetImportDPI (DPI ImportDPI)
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 void PostGetExportOptions (BitmapExportOptions *pOptions)

Static Public Member Functions

static BOOL CheckPath ()
 Determines whether or not ImageMagick is installed. Also registers filter prefs.

Protected Member Functions

virtual void SetCapabilities (ImageMagickFlags f)
virtual void InvertAlpha (LPBITMAPINFO lpBitmapInfo, LPBYTE lpBits)
 Camelot uses a different transparency scheme to the rest of the world, in that 255 is clear, and 0 is opaque. Until the rest of the world catches up, it's necessary to invert the alpha channel to make exported files compatible with other programs.
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 BitmapExportOptionsCreateExportOptions () const
 See BaseBitmapFilter for interface details Notes: Provides a new ImageMagickExportOptions instance.
virtual BOOL GetExportOptions (BitmapExportOptions *pOptions)
 See BaseBitmapFilter for interface details.
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 the optimised palette has been generated but before the export of the bitmap.
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.
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.
BOOL WriteToFile (CCLexFile *, LPBITMAPINFO Info, LPBYTE Bits, String_64 *ProgressString=NULL)
 Write a bitmap in memory straight out as a ImageMagick 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).
BOOL WriteToFile (CCLexFile *, LPBITMAPINFO Info, LPBYTE Bits, BOOL Interlace, INT32 TransparentColour, BaseCamelotFilter *pFilter=NULL)
 Write a bitmap in memory straight out as a ImageMagick 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 using the BaseCamelotFilter as the controlling influence.
void AlterPaletteContents (LPLOGPALETTE pPalette)
virtual BOOL CreateTempFile ()
 Create an expty temporary file.
virtual BOOL ConvertFromTempFile (CCLexFile *File)
 Process the temporary file by calling ImageMagick.
virtual BOOL ConvertToTempFile (CCLexFile *File)
 Process the passed file into the temp file by calling ImageMagick.
virtual BOOL TidyTempFile (BOOL Delete=TRUE)
 Closes any temporary file, and potentially removes it.

Protected Attributes

ResourceID FilterExtID
INT32 ImageMagickHowCompatible
UINT32 Export2ndStageMsgID
ImageMagickFlags m_Capabilities
DPI m_ImportDPI
CCDiskFileTempFile
wxString TempFileName

Static Protected Attributes

static FilterType s_FilterType = IMAGEMAGICK
static String_256 s_ImageMagickPath = _T( "convert" )
static BOOL s_HaveImageMagick = FALSE
static BOOL s_HaveCheckedPath = FALSE
static BOOL s_DoWarning = TRUE
static BOOL s_Disable = FALSE
static BOOL s_OutputTransparent = FALSE
static BOOL s_OutputInterlaced = FALSE

Private Member Functions

 CC_DECLARE_DYNAMIC (ImageMagickFilter)

Detailed Description

Encapsulates a ImageMagick export 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:
26/4/96

Definition at line 193 of file imgmgkft.h.


Constructor & Destructor Documentation

ImageMagickFilter::ImageMagickFilter  ) 
 

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

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/4/96
See also:
ImageMagickFilter::Init

Definition at line 257 of file imgmgkft.cpp.

00257                                      : MaskedFilter()
00258 {
00259     ExportRegion = NULL;
00260     TempFile = NULL;
00261     m_ImportDPI = 0;
00262 
00263     // Things that the derive class constructor may stamp on
00264     Flags.CanImport     = TRUE;
00265     Flags.CanExport     = TRUE;
00266     FilterID            = FILTERID_IMAGEMAGICK;
00267     FilterNameID        = _R(IDS_IMAGEMAGICK_FILTERNAME);
00268     FilterInfoID        = _R(IDS_IMAGEMAGICK_FILTERINFO);
00269     FilterExtID         = _R(IDS_IMAGEMAGICK_FILTEREXT);
00270     ImportMsgID         = _R(IDS_IMAGEMAGICK_IMPORTMSG);
00271     ExportMsgID         = _R(IDS_IMAGEMAGICK_PREPAREMSG);           // "Preparing ImageMagick file..."
00272     ExportingMsgID      = _R(IDS_IMAGEMAGICK_EXPORTMSG);        // "Exporting ImageMagick file..."
00273     Export2ndStageMsgID = _R(IDS_IMAGEMAGICK_MASKINGMSG);   // "Preparing mask for ImageMagick file..."
00274 }

virtual ImageMagickFilter::~ImageMagickFilter  )  [inline, virtual]
 

Definition at line 200 of file imgmgkft.h.

00200 {if (TempFile) delete (TempFile);}


Member Function Documentation

void ImageMagickFilter::AlterPaletteContents LPLOGPALETTE  pPalette  )  [protected, virtual]
 

Reimplemented from BaseBitmapFilter.

Definition at line 1244 of file imgmgkft.cpp.

01245 {
01246     PORTNOTETRACE("filters","ImageMagickFilter::AlterPaletteContents - do nothing");
01247 //  DestImageMagick.AlterExportPalette( pPalette );
01248 }

virtual BOOL ImageMagickFilter::CanDoAlpha  )  [inline, virtual]
 

Definition at line 231 of file imgmgkft.h.

00231 { return HasFlag(IM_EX_ALPHA); }

virtual BOOL ImageMagickFilter::CanDoExport  )  [inline, virtual]
 

Definition at line 233 of file imgmgkft.h.

00233 { return HasFlag(IM_EXPORT); }

virtual BOOL ImageMagickFilter::CanDoImport  )  [inline, virtual]
 

Definition at line 232 of file imgmgkft.h.

00232 { return HasFlag(IM_IMPORT); }

virtual BOOL ImageMagickFilter::CanDoImportDPI  )  [inline, virtual]
 

Reimplemented from BaseBitmapFilter.

Definition at line 239 of file imgmgkft.h.

00239 { return HasFlag(IM_IM_DPI); }

virtual BOOL ImageMagickFilter::CanDoInterlace  )  [inline, virtual]
 

Definition at line 230 of file imgmgkft.h.

00230 { return HasFlag(IM_EX_INTERLACE); }

virtual BOOL ImageMagickFilter::CanDoTransparency  )  [inline, virtual]
 

Definition at line 229 of file imgmgkft.h.

00229 { return HasFlag(IM_EX_MASK); }

ImageMagickFilter::CC_DECLARE_DYNAMIC ImageMagickFilter   )  [private]
 

BOOL ImageMagickFilter::CheckPath  )  [static]
 

Determines whether or not ImageMagick is installed. Also registers filter prefs.

Author:
Alex Bligh <alex@alex.org.uk>
Date:
18/07/2006
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
TRUE if ImageMagick is available, else fals Notes: -

Definition at line 1473 of file imgmgkft.cpp.

01474 {
01475     if (s_HaveCheckedPath)
01476         return s_HaveImageMagick;
01477 
01478     s_HaveImageMagick = FALSE;
01479     s_HaveCheckedPath = TRUE;
01480 
01481     BOOL ok = Camelot.DeclareSection(_T("Filters"), 10)
01482             && Camelot.DeclarePref( NULL, _T("ImageMagickDisable"), &ImageMagickFilter::s_Disable, 0, 1 )
01483             && Camelot.DeclarePref( NULL, _T("ImageMagickWarning"), &ImageMagickFilter::s_DoWarning, 0, 1 )
01484             && Camelot.DeclarePref( NULL, _T("ImageMagickPath"), &ImageMagickFilter::s_ImageMagickPath );
01485 
01486     if (!ok || s_Disable)
01487         return s_HaveImageMagick;
01488 
01489     if (s_ImageMagickPath == _T(""))
01490         s_ImageMagickPath = DIP_QUOTE(DEFAULT_IMAGEMAGICK_PATH);
01491 
01492     wxArrayString output;
01493     long /*TYPENOTE: Correct*/ ret=::wxExecute(wxString((const TCHAR *)s_ImageMagickPath)/*+_T(" --version")*/, output, wxEXEC_SYNC | wxEXEC_NODISABLE);
01494     if (!ret && output.GetCount()>0)
01495     {
01496         wxString check = output[0];
01497         wxString version;
01498         if (check.StartsWith(_T("Version: ImageMagick "),&version))
01499         {
01500             wxStringTokenizer tk(version, _T(".: "));
01501             if (tk.CountTokens()>=3)
01502             {
01503                 long /*TYPENOTE: Correct*/ v1,v2,v3=0;
01504                 tk.GetNextToken().ToLong(&v1);
01505                 tk.GetNextToken().ToLong(&v2);
01506                 tk.GetNextToken().ToLong(&v3);
01507                 double version = v1*10000.0+v2*100.0+v3;
01508                 if (version>=060000.0)
01509                 {
01510                     s_HaveImageMagick = TRUE;
01511                     s_DoWarning = TRUE; // warn them again if it ever goes away
01512                 }
01513             }
01514         }
01515     }
01516 
01517     if (!s_HaveImageMagick && s_DoWarning)
01518     {
01519         InformWarning(_R(IDS_WARN_NOIMAGEMAGICK), _R(IDS_OK));
01520         s_DoWarning = FALSE; // disable the warning on subsequent runs
01521     }
01522 
01523     return s_HaveImageMagick;       
01524 }

void ImageMagickFilter::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:
14/5/96
See also:
BaseBitmapFilter::PrepareToExport(); BaseBitmapFilter::CleanUpAfterExport(); Scope: Protected

Reimplemented from BaseBitmapFilter.

Definition at line 574 of file imgmgkft.cpp.

00575 {
00576     // Called right at the end of the export process or when the epxort has been aborted
00577     // Clean up any objects unique to this class.
00578     // Free up any DIBs that we might have left lying around on the export
00579     if (pDestBMInfo && pDestBMBytes)
00580     {
00581         FreeDIB( pDestBMInfo, pDestBMBytes );
00582         pDestBMInfo = NULL;
00583         pDestBMBytes = NULL;    
00584     }
00585 
00586     // the depth we ask GDraw to render is always 32-bit, so we can get transparency
00587     // we have to convert for other formats when writing the actual bytes to the file
00588     SetDepthToRender(32);
00589 
00590     // We haven't written the header yet
00591     WrittenHeader = FALSE;
00592 
00593     // We are a first pass render and not doing the mask, by default
00594     SecondPass = FALSE;
00595     DoingMask = FALSE;
00596 
00597     // Now call the baseclass version to do its stuff
00598     BaseBitmapFilter::CleanUpAfterExport();
00599 }

BOOL ImageMagickFilter::ConvertFromTempFile CCLexFile File  )  [protected, virtual]
 

Process the temporary file by calling ImageMagick.

Author:
Alex Bligh <alex@alex.org.uk>
Date:
18/07/2006
Parameters:
file - the CCLexFile for the final file [INPUTS]
None [OUTPUTS]
Returns:
TRUE on success, FALSE on error Notes: -

Definition at line 1301 of file imgmgkft.cpp.

01302 {
01303     PathName OutputPath = File->GetPathName();
01304     ERROR2IF(!OutputPath.IsValid(), FALSE, "ImageMagickFilter::ConvertFromTempFile can only be used on real files");
01305 
01306     ERROR2IF(!TempFile || TempFileName.IsEmpty(), FALSE, "ImageMagickFilter::ConvertFromTempFile has no temporary file to process");
01307     TempFile->close();
01308 
01309     wxChar * cifn;
01310     wxChar * cofn;
01311     wxChar * pcommand=_T("/usr/bin/convert");
01312     wxChar * IMargv[4];
01313 
01314     // get filename in usable form
01315     cifn = camStrdup(wxString(_T("png:"))+TempFileName );
01316     cofn = camStrdup(GetTag()+_T(":")+(const TCHAR *)(OutputPath.GetPath()));
01317 
01318     // Now convert the file
01319     IMargv[0]=pcommand;
01320     IMargv[1]=cifn;
01321     IMargv[2]=cofn;
01322     IMargv[3]=NULL;
01323     long /*TYPENOTE: Correct*/ ret = ::wxExecute((wxChar **)IMargv, wxEXEC_SYNC | wxEXEC_NODISABLE);
01324     
01325     free(cifn);
01326     free(cofn);
01327 
01328     if (ret)
01329     {
01330         TidyTempFile();
01331         ::wxRemoveFile(wxString((const TCHAR *)(OutputPath.GetPath())));
01332         ERROR1(FALSE, _R(IDE_IMAGEMAGICK_ERROR));
01333     }
01334 
01335     TidyTempFile(); // ensures filename zapped so it isn't removed later
01336 
01337     return TRUE;        
01338 }

BOOL ImageMagickFilter::ConvertToTempFile CCLexFile File  )  [protected, virtual]
 

Process the passed file into the temp file by calling ImageMagick.

Author:
Alex Bligh <alex@alex.org.uk>
Date:
18/07/2006
Parameters:
file - the CCLexFile for the source file [INPUTS]
None [OUTPUTS]
Returns:
TRUE on success, FALSE on error Notes: -

Definition at line 1356 of file imgmgkft.cpp.

01357 {
01358     if (!CreateTempFile())
01359         return FALSE;
01360 
01361     PathName InputPath = File->GetPathName();
01362     ERROR2IF(!InputPath.IsValid(), FALSE, "ImageMagickFilter::ConvertToTempFile can only be used on real files");
01363 
01364     ERROR2IF(!TempFile || TempFileName.IsEmpty(), FALSE, "ImageMagickFilter::ConvertToTempFile has no temporary file to process");
01365     TempFile->close();
01366 
01367     wxChar * cifn;
01368     wxChar * cofn;
01369     wxChar * pcommand=_T("/usr/bin/convert");
01370     wxChar * IMargv[10];
01371     wxChar * cdpi = NULL;
01372 
01373     // get filename in usable form
01374     cifn = camStrdup(GetTag()+_T(":")+(const TCHAR *)(InputPath.GetPath())+_T("[0]"));
01375     cofn = camStrdup(wxString(_T("png:"))+TempFileName );
01376 
01377     INT32 p = 0;
01378 
01379     // Now convert the file
01380     IMargv[p++]=pcommand;
01381     if (CanDoImportDPI())
01382     {
01383         // Always specify a DPI if the filter takes it, but use the screen default DPI if none specified
01384         wxScreenDC dc;
01385         wxSize DefaultDPI=OSRenderRegion::GetFixedDCPPI(dc);
01386         IMargv[p++]=_T("-density");
01387         UINT32  uHorzDpi = UINT32( m_ImportDPI ? m_ImportDPI : DefaultDPI.GetWidth() );
01388         UINT32  uVertDpi = UINT32( m_ImportDPI ? m_ImportDPI : DefaultDPI.GetHeight() );
01389         cdpi = camStrdup( wxString::Format( _T("%dx%d"), uHorzDpi, uVertDpi ) );
01390         IMargv[p++]=cdpi;   
01391     }
01392     IMargv[p++]=cifn;
01393     IMargv[p++]=cofn;
01394     IMargv[p++]=NULL;
01395 
01396 #ifdef AVOID_BROKEN_GDB
01397     ::wxCopyFile(wxString(_T("/tmp/test.png")), TempFileName);
01398 #else
01399     long /*TYPENOTE: Correct*/ ret = ::wxExecute((wxChar **)IMargv, wxEXEC_SYNC | wxEXEC_NODISABLE);
01400 #endif
01401     
01402     free(cifn);
01403     free(cofn);
01404     if (cdpi)
01405     {
01406         free(cdpi);
01407         cdpi = NULL;
01408     }
01409 
01410     if (ret)
01411     {
01412         TidyTempFile();
01413         ERROR1(FALSE, _R(IDE_IMAGEMAGICK_ERROR));
01414     }
01415 
01416     PathName pthFileName=String_256(TempFileName);
01417 
01418     // Reopen the file
01419     if (!(TempFile->open(pthFileName, ios::in | ios::binary)))
01420     {
01421         TidyTempFile();
01422         ERROR1(FALSE, _R(IDE_IMAGEMAGICK_ERROR));
01423     }
01424 
01425     return TRUE;        
01426 }

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

See BaseBitmapFilter for interface details Notes: Provides a new ImageMagickExportOptions instance.

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

Reimplemented from BaseBitmapFilter.

Definition at line 1238 of file imgmgkft.cpp.

01239 {
01240     ImageMagickExportOptions* pImageMagickOptions = new ImageMagickExportOptions(IMAGEMAGICK, &FilterName, FilterNameID);
01241     return (BitmapExportOptions*)pImageMagickOptions;
01242 }

BOOL ImageMagickFilter::CreateTempFile  )  [protected, virtual]
 

Create an expty temporary file.

Author:
Alex Bligh <alex@alex.org.uk>
Date:
18/07/2006
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
TRUE on success, FALSE on error Notes: -

Definition at line 1265 of file imgmgkft.cpp.

01266 {
01267     if (TempFile)
01268         delete TempFile;
01269 
01270     TempFile = new CCDiskFile;
01271     if (!TempFile)
01272         return FALSE;
01273 
01274     wxFile dummyFile; // to prevent deletion race condition
01275     TempFileName = wxFileName::CreateTempFileName(wxEmptyString, &dummyFile);
01276     PathName pthFileName=String_256(TempFileName);
01277     
01278     if (!(TempFile->open(pthFileName, ios::out | ios::trunc | ios::binary)))
01279     {
01280         ::wxRemoveFile(TempFileName);
01281         ERROR1(FALSE, _R(IDE_IMAGEMAGICK_ERROR));
01282     }
01283 
01284     return TRUE;
01285 }

BOOL ImageMagickFilter::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:
14/5/96
Parameters:
- [INPUTS]
Returns:
TRUE if worked, FALSE if failed.

Reimplemented from BaseBitmapFilter.

Definition at line 667 of file imgmgkft.cpp.

00668 {
00669     if (GeneratingOptimisedPalette())
00670         return TRUE;        // No need to output anything
00671 
00672     //  Can reset the band number now.
00673     m_BandNumber = 0;
00674 
00675     ImageMagickExportOptions* pImageMagickOptions = (ImageMagickExportOptions*)GetBitmapExportOptions();
00676     ERROR2IF(pImageMagickOptions == NULL, FALSE, "NULL Args");
00677     ERROR3IF(!pImageMagickOptions->IS_KIND_OF(ImageMagickExportOptions), "pImageMagickOptions isn't");
00678 
00679     // Do the transparency translation just before we write out the data as a ImageMagick.
00680     // This involves doing a 1 bpp export of the same area and using this to work
00681     // out which areas are transparent or not.
00682     // Only do this if the user has requested transparency and we outputting at 8bpp
00683     BOOL SaveDataOut = TRUE;
00684 
00685     if (BadExportRender)
00686     {
00687         // Delete our whitearea bitmap
00688         if (pTempBitmapMask != NULL)
00689             CCFree(pTempBitmapMask);
00690 
00691         pTempBitmapMask = NULL;
00692     }
00693 
00694     BOOL ok=FALSE;
00695 
00696     // Save the data out if required. Only if we exported ok.
00697     if (SaveDataOut && !BadExportRender)
00698     {
00699         ok = CreateTempFile();
00700     
00701         if (ok)
00702         {
00703             // Now that we know the transparent index we can output the ImageMagick header
00704             ok = DestImageMagick.OutputPNGHeader(TempFile, NULL, pImageMagickOptions->WantInterlaced(),
00705                                         pImageMagickOptions->GetTransparencyIndex(),
00706                                         pImageMagickOptions->GetDepth() <= 8 ? pImageMagickOptions->GetLogicalPalette() : NULL);
00707         }
00708 
00709         // Actually write the destination bitmap out to the file showing an hourglass
00710         // and/or progress bar as we go. Always show the Exporting message.
00711         // Need to do in one go due to interlacing
00712         if (ok)
00713         {
00714             String_64 ProgressString(ExportingMsgID);
00715             ProgressString = GetExportProgressString(TempFile, ExportingMsgID);
00716             BeginSlowJob(100, FALSE, &ProgressString);
00717             
00718             ok = DestImageMagick.OutputPNGBits(TempFile, DestImageMagick.GetDestBitmapBits());
00719             DestImageMagick.TidyUp();
00720             if (ok)
00721                 ok=ConvertFromTempFile(OutputFile);
00722 
00723             EndSlowJob();
00724         }
00725         else
00726         {
00727             DestImageMagick.TidyUp();
00728         }
00729     }
00730     else
00731     {
00732         DestImageMagick.TidyUp();
00733     }
00734 
00735 
00736     ERROR1IF(!ok, FALSE, _R(IDE_IMAGEMAGICK_ERROR));
00737 
00738     TidyTempFile();
00739     
00740     return TRUE;
00741 }

ImageMagickFlags ImageMagickFilter::GetCapabilities  )  [inline]
 

Definition at line 225 of file imgmgkft.h.

00225 {return m_Capabilities;}

virtual INT32 ImageMagickFilter::GetCompatibility  )  [inline, virtual]
 

Reimplemented in ImageMagickFilterBMP, ImageMagickFilterCUR, ImageMagickFilterCUT, ImageMagickFilterDCM, ImageMagickFilterDCX, ImageMagickFilterDIB, ImageMagickFilterDNG, ImageMagickFilterEPDF, ImageMagickFilterEPI, ImageMagickFilterEPS, ImageMagickFilterEPS2, ImageMagickFilterEPS3, ImageMagickFilterEPSF, ImageMagickFilterEPSI, ImageMagickFilterEPT, ImageMagickFilterFAX, ImageMagickFilterFITS, ImageMagickFilterICO, ImageMagickFilterJNG, ImageMagickFilterMIFF, ImageMagickFilterMPC, ImageMagickFilterOTB, ImageMagickFilterP7, ImageMagickFilterPALM, ImageMagickFilterPAM, ImageMagickFilterPBM, ImageMagickFilterPCD, ImageMagickFilterPCDS, ImageMagickFilterPCL, ImageMagickFilterPCX, ImageMagickFilterPDB, ImageMagickFilterPDF, ImageMagickFilterPGM, ImageMagickFilterPICT, ImageMagickFilterPIX, ImageMagickFilterPNM, ImageMagickFilterPPM, ImageMagickFilterPS, ImageMagickFilterPS2, ImageMagickFilterPS3, ImageMagickFilterPSD, ImageMagickFilterPTIF, ImageMagickFilterPWP, ImageMagickFilterRLA, ImageMagickFilterRLE, ImageMagickFilterSCT, ImageMagickFilterSFW, ImageMagickFilterSUN, ImageMagickFilterSVG, ImageMagickFilterTGA, ImageMagickFilterTIFF, ImageMagickFilterTIM, ImageMagickFilterTTF, ImageMagickFilterVICAR, ImageMagickFilterVIFF, ImageMagickFilterWBMP, ImageMagickFilterWPG, ImageMagickFilterXBM, ImageMagickFilterXCF, ImageMagickFilterXPM, and ImageMagickFilterXWD.

Definition at line 236 of file imgmgkft.h.

00236 { return 10; }

UINT32 ImageMagickFilter::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:
10/07/96
Returns:
The id of the message to put on the progress display whilst exporting.
See also:
DoExport; TI_GIFFilter::GetExportMsgID;

Reimplemented from BaseBitmapFilter.

Definition at line 614 of file imgmgkft.cpp.

00615 {
00616     if (GeneratingOptimisedPalette())
00617         return _R(IDS_GENOPTPALMSGID);              // "Generating optimised palette..."
00618 
00619     ImageMagickExportOptions* pImageMagickOptions = (ImageMagickExportOptions*)GetBitmapExportOptions();
00620     ERROR2IF(pImageMagickOptions == NULL, FALSE, "NULL Args");
00621     ERROR3IF(!pImageMagickOptions->IS_KIND_OF(ImageMagickExportOptions), "pImageMagickOptions isn't");
00622 
00623     // If we are exporting with transparency on and on first pass use the masking message
00624     // otherwise use the exporting message.
00625     if (pImageMagickOptions->GetSelectionType() == SELECTION && pImageMagickOptions->WantTransparent())
00626     {
00627         // Special 4 stage rendering operation
00628         // - Render selected objects to white background
00629         // - Render mask 1bpp
00630         // - Render all objects
00631         // - Save data out to disk
00632         if (!SecondPass)
00633             return Export2ndStageMsgID;         // "Preparing mask for ImageMagick file..."
00634         else
00635             return Filter::GetExportMsgID();    // "Preparing ImageMagick file..."
00636     }
00637     else
00638     {
00639         // Special 3 stage rendering operation
00640         // - Render objects to white background
00641         // - Render mask 1bpp
00642         // - Save data out to disk
00643         if (DoingMask)
00644             return Export2ndStageMsgID;         // "Preparing mask for ImageMagick file..."
00645         else
00646             return Filter::GetExportMsgID();    // "Preparing ImageMagick file..."
00647     }
00648 
00649     return ExportingMsgID;
00650 }

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

See BaseBitmapFilter for interface details.

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

Reimplemented from BaseBitmapFilter.

Definition at line 479 of file imgmgkft.cpp.

00480 {
00481     ERROR2IF(pOptions == NULL, FALSE, "NULL Args");
00482 
00483     ImageMagickExportOptions* pImageMagickOptions = (ImageMagickExportOptions*)pOptions;
00484     ERROR3IF(!pImageMagickOptions->IS_KIND_OF(ImageMagickExportOptions), "pImageMagickOptions isn't");
00485 
00486     // the depth we ask GDraw to render is always 32-bit, so we can get transparency
00487     // we have to convert for other formats when writing the actual bytes to the file
00488     SetDepthToRender(32);
00489 
00490     // We haven't written the header yet
00491     WrittenHeader = FALSE;
00492 
00493     // We are a first pass render and not doing the mask, by default
00494     SecondPass = FALSE;
00495     DoingMask = FALSE;
00496 
00497     // Determine the filter type currently in use in Accusoft format
00498     s_FilterType = IMAGEMAGICK;
00499     pImageMagickOptions->SetFilterType(IMAGEMAGICK);
00500 
00501     BOOL Ok = FALSE;
00502 
00503     OpDescriptor* pOpDes = OpDescriptor::FindOpDescriptor(OPTOKEN_GIFTABDLG);
00504     if (pOpDes != NULL)
00505     {
00506         // set up the data for the export options dialog
00507         OpParam Param((void *)pOptions, (void *)this);
00508 
00509         // invoke the dialog
00510         pOpDes->Invoke(&Param);
00511 
00512         // SMFIX
00513         // we have brought the dlg up so get the options from the dlg as the graphic type may have changed
00514         pOptions = BmapPrevDlg::m_pExportOptions;
00515 
00516         // check for valid options
00517         //  This may get messed up, so have to use the second line below.
00518         Ok = BmapPrevDlg::m_bClickedOnExport;
00519     }
00520     else
00521     {   
00522         ERROR3("Unable to find OPTOKEN_BMAPPREVDLG");
00523     } 
00524 
00525     // Return with the ok/cancel state used on the dialog box
00526     return Ok;
00527 }

virtual TCHAR* ImageMagickFilter::GetExtension  )  [inline, virtual]
 

Reimplemented in ImageMagickFilterBMP, ImageMagickFilterCUR, ImageMagickFilterCUT, ImageMagickFilterDCM, ImageMagickFilterDCX, ImageMagickFilterDIB, ImageMagickFilterDNG, ImageMagickFilterEPDF, ImageMagickFilterEPI, ImageMagickFilterEPS, ImageMagickFilterEPS2, ImageMagickFilterEPS3, ImageMagickFilterEPSF, ImageMagickFilterEPSI, ImageMagickFilterEPT, ImageMagickFilterFAX, ImageMagickFilterFITS, ImageMagickFilterICO, ImageMagickFilterJNG, ImageMagickFilterMIFF, ImageMagickFilterMPC, ImageMagickFilterOTB, ImageMagickFilterP7, ImageMagickFilterPALM, ImageMagickFilterPAM, ImageMagickFilterPBM, ImageMagickFilterPCD, ImageMagickFilterPCDS, ImageMagickFilterPCL, ImageMagickFilterPCX, ImageMagickFilterPDB, ImageMagickFilterPDF, ImageMagickFilterPGM, ImageMagickFilterPICT, ImageMagickFilterPIX, ImageMagickFilterPNM, ImageMagickFilterPPM, ImageMagickFilterPS, ImageMagickFilterPS2, ImageMagickFilterPS3, ImageMagickFilterPSD, ImageMagickFilterPTIF, ImageMagickFilterPWP, ImageMagickFilterRLA, ImageMagickFilterRLE, ImageMagickFilterSCT, ImageMagickFilterSFW, ImageMagickFilterSUN, ImageMagickFilterSVG, ImageMagickFilterTGA, ImageMagickFilterTIFF, ImageMagickFilterTIM, ImageMagickFilterTTF, ImageMagickFilterVICAR, ImageMagickFilterVIFF, ImageMagickFilterWBMP, ImageMagickFilterWPG, ImageMagickFilterXBM, ImageMagickFilterXCF, ImageMagickFilterXPM, and ImageMagickFilterXWD.

Definition at line 235 of file imgmgkft.h.

00235 { return _T("mmif"); }

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

Reimplemented from BaseBitmapFilter.

Definition at line 206 of file imgmgkft.h.

00206 { return IMAGEMAGICK; }

virtual INT32 ImageMagickFilter::GetImageMagickCompatibility  )  [inline, virtual]
 

Definition at line 223 of file imgmgkft.h.

00223 { return ImageMagickHowCompatible; }

OutputDIB * ImageMagickFilter::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 DestImageMagick.

Reimplemented from MaskedFilter.

Definition at line 1222 of file imgmgkft.cpp.

01223 {
01224     // Perform an upcast to allow the pointer to be used in a generic manner.
01225     return static_cast<OutputDIB*> ( &DestImageMagick );
01226 }

virtual wxString ImageMagickFilter::GetTag  )  [inline, virtual]
 

Reimplemented in ImageMagickFilterBMP, ImageMagickFilterCUR, ImageMagickFilterCUT, ImageMagickFilterDCM, ImageMagickFilterDCX, ImageMagickFilterDIB, ImageMagickFilterDNG, ImageMagickFilterEPDF, ImageMagickFilterEPI, ImageMagickFilterEPS, ImageMagickFilterEPS2, ImageMagickFilterEPS3, ImageMagickFilterEPSF, ImageMagickFilterEPSI, ImageMagickFilterEPT, ImageMagickFilterFAX, ImageMagickFilterFITS, ImageMagickFilterICO, ImageMagickFilterJNG, ImageMagickFilterMIFF, ImageMagickFilterMPC, ImageMagickFilterOTB, ImageMagickFilterP7, ImageMagickFilterPALM, ImageMagickFilterPAM, ImageMagickFilterPBM, ImageMagickFilterPCD, ImageMagickFilterPCDS, ImageMagickFilterPCL, ImageMagickFilterPCX, ImageMagickFilterPDB, ImageMagickFilterPDF, ImageMagickFilterPGM, ImageMagickFilterPICT, ImageMagickFilterPIX, ImageMagickFilterPNM, ImageMagickFilterPPM, ImageMagickFilterPS, ImageMagickFilterPS2, ImageMagickFilterPS3, ImageMagickFilterPSD, ImageMagickFilterPTIF, ImageMagickFilterPWP, ImageMagickFilterRLA, ImageMagickFilterRLE, ImageMagickFilterSCT, ImageMagickFilterSFW, ImageMagickFilterSUN, ImageMagickFilterSVG, ImageMagickFilterTGA, ImageMagickFilterTIFF, ImageMagickFilterTIM, ImageMagickFilterTTF, ImageMagickFilterVICAR, ImageMagickFilterVIFF, ImageMagickFilterWBMP, ImageMagickFilterWPG, ImageMagickFilterXBM, ImageMagickFilterXCF, ImageMagickFilterXPM