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, and ImageMagickFilterXWD.

Definition at line 234 of file imgmgkft.h.

00234 { return _T("mmif"); }

BOOL ImageMagickFilter::HasFlag ImageMagickFlags  f  )  [inline]
 

Definition at line 226 of file imgmgkft.h.

00226 {return (GetCapabilities() & f)!=0;}

INT32 ImageMagickFilter::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:
26/4/96
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 ImageMagick file. 10 => It is a ImageMagick file.

Reimplemented from Filter.

Definition at line 319 of file imgmgkft.cpp.

00321 {
00322     // We need to remember what we thought of this file in our class variable.
00323     // So, set it to a nice default value at the start.
00324     String_256 fextension = Filename.GetType();
00325     fextension.toLower();
00326 
00327     ImageMagickHowCompatible = (fextension == (String_256)GetExtension()) ? GetCompatibility():0;
00328 
00329     // Return the found value to the caller.
00330     return ImageMagickHowCompatible;
00331 }

BOOL ImageMagickFilter::Init void   )  [virtual]
 

Initialise an ImageMagickFilter object.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/4/96
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.

Definition at line 288 of file imgmgkft.cpp.

00289 {
00290     // Get the OILFilter object
00291     pOILFilter = new ImageMagickOILFilter(this, FilterNameID, FilterExtID);
00292     if (pOILFilter==NULL)
00293         return FALSE;
00294 
00295     // Load the description strings
00296     FilterName.Load(FilterNameID);
00297     FilterInfo.Load(FilterInfoID);
00298 
00299     // All ok
00300     return TRUE;
00301 }

void ImageMagickFilter::InvertAlpha LPBITMAPINFO  lpBitmapInfo,
LPBYTE  lpBits
[protected, virtual]
 

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.

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/6/00

Reimplemented from MaskedFilter.

Definition at line 1205 of file imgmgkft.cpp.

01207 {
01208     DIBUtil::InvertAlpha(lpBitmapInfo, lpBits);
01209 }

BOOL ImageMagickFilter::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:
26/4/96
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.

Definition at line 345 of file imgmgkft.cpp.

00346 {
00347     return (Bpp == 1 || Bpp == 4 || Bpp == 8 || Bpp == 24 || Bpp == 32);
00348 }

void ImageMagickFilter::PostGetExportOptions BitmapExportOptions pOptions  )  [virtual]
 

Reimplemented from BaseBitmapFilter.

Definition at line 533 of file imgmgkft.cpp.

00534 {
00535     // should be of this type
00536     ImageMagickExportOptions* pImageMagickOptions = (ImageMagickExportOptions*)pOptions;
00537     ERROR3IF(!pImageMagickOptions->IS_KIND_OF(ImageMagickExportOptions), "pImageMagickOptions isn't");
00538 
00539     // do the baseclass options
00540     MaskedFilter::PostGetExportOptions(pOptions);
00541 
00542     // do the specific to this class options
00543     // Filter type can be changed by the export options dialog box from say 
00544 
00545     s_OutputTransparent = pImageMagickOptions->WantTransparent();
00546     s_OutputInterlaced = pImageMagickOptions->WantInterlaced();
00547     UINT32 Silliness = pImageMagickOptions->WantTransparent() ? 2 : 0;
00548     Silliness |= pImageMagickOptions->WantInterlaced() ? 1 : 0;
00549     if (Silliness >= 0 && Silliness <= 4)
00550     {
00551         Compression = Silliness;
00552         s_FilterType = IMAGEMAGICK;
00553 
00554         if (pImageMagickOptions->WantTransparent() && pImageMagickOptions->GetSelectionType() == SELECTION)
00555             DoingMask = TRUE;
00556     }
00557 }

BOOL ImageMagickFilter::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. 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/7/96
Parameters:
pOilBitmap pointer to the oil bitmap data to be filled in [INPUTS] pFilter - the BaseCamelotFilter which provides functions like progress update 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 374 of file imgmgkft.cpp.

00376 {
00377     ERROR2IF(pOilBitmap == NULL,FALSE,"BMPFilter::ReadFromFile null OilBitmap pointer");
00378     ERROR2IF(pFilter == NULL,FALSE,"BMPFilter::ReadFromFile null pFilter pointer");
00379     ERROR2IF(pFile == NULL,FALSE,"BMPFilter::ReadFromFile null pFile pointer");
00380 
00381     // Try to import bitmap as usual binary BMP file.
00382     CWxBitmap* pWBitmap = (CWxBitmap*)pOilBitmap;
00383     
00384     LPBITMAPINFO *pInfo = &(pWBitmap->BMInfo);
00385     LPBYTE *pBytes = &(pWBitmap->BMBytes);
00386 
00387     INT32 TransColour = -1;
00388 
00389     // Read from file,using pFilter for progress bar updates
00390     BOOL ok = ConvertToTempFile(pFile); 
00391     if (ok)
00392         ok = PNGUtil::ReadFromFile(TempFile, pInfo, pBytes, &TransColour, NULL, pFilter);
00393     TidyTempFile();
00394     if (!ok)
00395         return FALSE;
00396 
00397     if(pWBitmap->BMInfo->bmiHeader.biBitCount == 32)
00398     {
00399         // If we`re exporting a 32Bit BMP then we need to make sure that we convert the
00400         // Alpha channel to Transparency! i.e. invert it!
00401         UINT32 BmpSize = pWBitmap->BMInfo->bmiHeader.biSizeImage;
00402         BYTE* Bits = pWBitmap->BMBytes;
00403 
00404         for(UINT32 i = 0; i < BmpSize; i+=4)
00405             Bits[i+3] = ~Bits[i+3];
00406     }
00407 
00408     // Everything went ok and we imported the bitmap ok
00409     SetTransColour(TransColour);
00410     UINT32 Bpp = pWBitmap->GetBPP();
00411     if (TransColour != -1 && Bpp <= 8)
00412         pOilBitmap->SetTransparencyIndex(TransColour);
00413 
00414     SetLastBitmap();        // can only import one bitmap at the moment
00415     return TRUE;
00416 }

BOOL ImageMagickFilter::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:
26/4/96
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 433 of file imgmgkft.cpp.

00434 {
00435     ERROR2IF(pOilBitmap == NULL,FALSE,"ImageMagickFilter::ReadFromFile null OilBitmap pointer");
00436     
00437     // Try to import the bitmap as a ImageMagick file.      
00438     CCLexFile *pImportFile = GetImportFile();
00439     ERROR2IF(pImportFile==NULL,FALSE,"ImageMagickFilter::ReadFromFile - No import file");
00440 
00441     UINT32 ImportMsgId = GetImportMsgID();      
00442     String_64 ProgressString(ImportMsgId);
00443     ProgressString = GetImportProgressString(pImportFile, ImportMsgId);
00444 
00445     CWxBitmap* pWBitmap = (CWxBitmap*)pOilBitmap;
00446     
00447     LPBITMAPINFO *pInfo = &(pWBitmap->BMInfo);
00448     LPBYTE *pBytes = &(pWBitmap->BMBytes);
00449     
00450     INT32 TransColour = -1;
00451 
00452     // The ImageMagick filter liked it very much and so use it, showing progress bar
00453     BOOL ok = ConvertToTempFile(pImportFile); 
00454     if (ok)
00455         ok = PNGUtil::ReadFromFile(TempFile, pInfo, pBytes, &TransColour, &ProgressString);
00456     TidyTempFile();
00457     if (!ok)
00458         return FALSE;
00459 
00460     SetTransColour(TransColour);
00461     UINT32 Bpp = pWBitmap->GetBPP();
00462     if (TransColour != -1 && Bpp <= 8)
00463         pOilBitmap->SetTransparencyIndex(TransColour);
00464 
00465     SetLastBitmap();        // can only import one bitmap at the moment
00466     
00467     return TRUE;
00468 }

virtual void ImageMagickFilter::SetCapabilities ImageMagickFlags  f  )  [inline, protected, virtual]
 

Definition at line 249 of file imgmgkft.h.

00249 {m_Capabilities = f;}

virtual void ImageMagickFilter::SetImportDPI DPI  ImportDPI  )  [inline, virtual]
 

Reimplemented from BaseBitmapFilter.

Definition at line 240 of file imgmgkft.h.

00240 {m_ImportDPI = ImportDPI;}

BOOL ImageMagickFilter::TidyTempFile BOOL  Delete = TRUE  )  [protected, virtual]
 

Closes any temporary file, and potentially removes it.

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 1442 of file imgmgkft.cpp.

01443 {
01444     if (TempFile)
01445     {
01446         delete (TempFile);
01447         TempFile = NULL;
01448     }
01449 
01450     if (!TempFileName.IsEmpty())
01451     {
01452         if (Delete)
01453             ::wxRemoveFile(TempFileName);
01454         TempFileName = wxEmptyString;
01455     }
01456     return TRUE;
01457 }

BOOL ImageMagickFilter::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:
26/4/96
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 781 of file imgmgkft.cpp.

00782 {
00783     ERROR2IF(pKernelBitmap == NULL,FALSE,"ImageMagickFilter::WriteBitmapToFile null bitmap pointer specified");
00784 
00785     // Get a pointer to the actual bitmap so that we can get some details from it.
00786     OILBitmap *pOilBitmap = pKernelBitmap->ActualBitmap;
00787     ERROR2IF(pOilBitmap == NULL,FALSE,"ImageMagickFilter::WriteBitmapToFile null oil bitmap pointer");
00788 
00789     // Now get the pointer to the info header and actual bits data.
00790     // Need to use the actual bitmap pointer
00791     CWxBitmap* pWBitmap = (CWxBitmap*)pOilBitmap;
00792     LPBITMAPINFO pInfo = pWBitmap->BMInfo;
00793     LPBYTE pBytes = pWBitmap->BMBytes;
00794 //  UINT32 Bpp = pWBitmap->GetBPP();
00795 
00796     // Now, save the data out showing the correct progress string
00797     String_64 ProgressString(ExportingMsgID);
00798     BOOL ok = FALSE;
00799 //  BOOL Interlace = TRUE;  // Use interlace or not
00800 //  BOOL Transparency = FALSE;  // Use transparency or not
00801 
00802     if(pInfo->bmiHeader.biBitCount == 32)
00803     {
00804         // If we`re exporting a 32Bit BMP then we need to make sure that we convert the
00805         // Alpha channel to Transparency! i.e. invert it!
00806         UINT32 BmpSize = pInfo->bmiHeader.biSizeImage;
00807 
00808         for(UINT32 i = 0; i < BmpSize; i+=4)
00809             pBytes[i+3] = ~pBytes[i+3];
00810     }
00811 
00812     ok = WriteToFile(OutputFile, pInfo, pBytes, &ProgressString);
00813 
00814     //  This function is used when saving from the bitmap gallery. If we save a 32-bit bitmap as
00815     //  a ImageMagick, then we have to undo the alpha channel reversing that we did above.
00816     //  Failure to do this will change the bitmap displayed in the bitmap gallery.
00817     if(pInfo->bmiHeader.biBitCount == 32)
00818     {
00819         UINT32 BmpSize = pInfo->bmiHeader.biSizeImage;
00820 
00821         for(UINT32 i = 0; i < BmpSize; i+=4)
00822             pBytes[i+3] = ~pBytes[i+3];
00823     }
00824     
00825     return ok;
00826 }

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

Reimplemented from BaseBitmapFilter.

Definition at line 849 of file imgmgkft.cpp.

00851 {
00852     ERROR2IF(pKernelBitmap == NULL,FALSE, "ImageMagickFilter::WriteBitmapToFile null pKernelBitmap");
00853     ERROR2IF(pFilter == NULL,FALSE, "ImageMagickFilter::WriteBitmapToFile null pFilter");
00854     ERROR2IF(pFile == NULL,FALSE, "ImageMagickFilter::WriteBitmapToFile null pFile");
00855 
00856     // Get a pointer to the actual bitmap so that we can get some details from it.
00857     OILBitmap *pOilBitmap = pKernelBitmap->ActualBitmap;
00858     ERROR2IF(pOilBitmap == NULL,FALSE,"ImageMagickFilter::WriteBitmapToFile null oil bitmap pointer");
00859 
00860     // Now get the pointer to the info header and actual bits data.
00861     // Need to use the actual bitmap pointer
00862     CWxBitmap* pWBitmap = (CWxBitmap*)pOilBitmap;
00863     LPBITMAPINFO Info = pWBitmap->BMInfo;
00864     LPBYTE Bytes = pWBitmap->BMBytes;
00865     UINT32 Bpp = pWBitmap->GetBPP();
00866 
00867     // Now, save the data out showing the correct progress string
00868     BOOL ok = FALSE;
00869     BOOL Interlace = FALSE;     // Must not use interlacing as it will screw the progress bar updates
00870 //  BOOL Transparency = FALSE;  // Use transparency or not
00871     INT32 Transparent = -1; // colour or -1 = no transparency
00872     if (Bpp <= 8)
00873         pOilBitmap->GetTransparencyIndex(&Transparent);
00874     
00875     if(Info->bmiHeader.biBitCount == 32)
00876     {
00877         // If we`re exporting a 32Bit BMP then we need to make sure that we convert the
00878         // Alpha channel to Transparency! i.e. invert it!
00879         UINT32 BmpSize = Info->bmiHeader.biSizeImage;
00880 
00881         for(UINT32 i = 0; i < BmpSize; i+=4)
00882             Bytes[i+3] = ~Bytes[i+3];
00883     }
00884     
00885     // Write to file, no header and using pFilter for progress bar updates
00886     ok = WriteToFile(pFile, Info, Bytes, Interlace, Transparent, pFilter);
00887     
00888     return ok;
00889 }

BOOL ImageMagickFilter::WriteDataToFile BOOL  End,
UINT32  Bpp,
UINT32  Compression
[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:
14/5/96
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 ImageMagick 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 762 of file imgmgkft.cpp.

00763 {
00764     ERROR2(FALSE,"ImageMagickFilter::WriteDataToFile called when not implemented");
00765 }

BOOL ImageMagickFilter::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:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/7/96
Parameters:
- [INPUTS]
Returns:
FALSE if failed else TRUE
See also:
GIFFilter::WriteFileEnd(void)

Reimplemented from BaseBitmapFilter.

Definition at line 1169 of file imgmgkft.cpp.

01170 {
01171     return TRUE;
01172 }

virtual BOOL ImageMagickFilter::WriteFileHeader void   )  [inline, protected, virtual]
 

To write out the file specific header data.

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

Reimplemented from BaseBitmapFilter.

Definition at line 264 of file imgmgkft.h.

00264 { return TRUE; }

BOOL ImageMagickFilter::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:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/7/96
Parameters:
- [INPUTS]
Returns:
FALSE if failed else TRUE
See also:
GIFFilter::WriteFrame(void)

Reimplemented from BaseBitmapFilter.

Definition at line 1132 of file imgmgkft.cpp.

01133 {
01134     return MaskedFilter::WriteToFile(TRUE);
01135 }

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

To write out any frame specific info after the image.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/7/96
Parameters:
- [INPUTS]
Returns:
FALSE if failed else TRUE
See also:
GIFFilter::WritePostFrame(void)

Reimplemented from BaseBitmapFilter.

Definition at line 1150 of file imgmgkft.cpp.

01151 {
01152     return EndWriteToFile();
01153 }

virtual BOOL ImageMagickFilter::WritePostOptimisedPalette void   )  [inline, protected, virtual]
 

Called after the optimised palette has been generated but before the export of the bitmap.

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

Reimplemented from BaseBitmapFilter.

Definition at line 267 of file imgmgkft.h.

00267 { return TRUE; }

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

To write out any frame specific info before the image.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/7/96
Parameters:
- [INPUTS]
Returns:
FALSE if failed else TRUE
See also:
GIFFilter::WritePreFrame(void)

Reimplemented from BaseBitmapFilter.

Definition at line 1113 of file imgmgkft.cpp.

01114 {
01115     return DestImageMagick.ReStartFile(NULL);
01116 }

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

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

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/7/96
Parameters:
- [INPUTS]
Returns:
FALSE if failed else TRUE
See also:
GIFFilter::WritePreSecondPass(void)

Reimplemented from BaseBitmapFilter.

Definition at line 1187 of file imgmgkft.cpp.

01188 {
01189     return EndWriteToFile();
01190 }

BOOL ImageMagickFilter::WriteToFile CCLexFile File,
LPBITMAPINFO  Info,
LPBYTE  Bits,
BOOL  Interlace,
INT32  TransparentColour,
BaseCamelotFilter pFilter = NULL
[protected]
 

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.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/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 allows interlacing to be turned off or on Transparent if -1 then no transpparent colour, if not -1 then specifies the index number of the transparent colour in the palette 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)
This function is used by the new native/web file format to do a straight save of the data into the file.

(caller should close file)

Returns:
Errors: Calls SetError on FALSE returns. Scope: Static
See also:
AccusoftFilters::WriteToFile; DIBUtil::WriteToFile;

Definition at line 927 of file imgmgkft.cpp.

00930 {
00931 #ifdef DO_EXPORT
00932     ERROR2IF(File==NULL,FALSE,"ImageMagickFilter::WriteToFile File pointer is null");
00933     ERROR2IF(Info==NULL,FALSE,"ImageMagickFilter::WriteToFile BitmapInfo pointer is null");
00934     ERROR2IF(Bits==NULL,FALSE,"ImageMagickFilter::WriteToFile Bits pointer is null");
00935 
00936     // BITMAPINFO  consists of:-
00937     //      BITMAPINFOHEADER    bmiHeader;
00938     //      RGBQUAD             bmiColors[1];
00939     LPBITMAPINFOHEADER pInfoHeader = &Info->bmiHeader;
00940     ERROR2IF(pInfoHeader==NULL,FALSE,"ImageMagickFilter::WriteToFile BitmapInfoHeader pointer is null");
00941         
00942     LPRGBQUAD pPalette = &(Info->bmiColors[0]);
00943     ERROR2IF(pPalette==NULL,FALSE,"ImageMagickFilter::WriteToFile palette pointer is null");
00944 
00945     // Set up our format type flags.
00946     if(Info->bmiHeader.biBitCount == 32)
00947     {
00948         // If we`re exporting a 32Bit BMP then we need to make sure that we convert the
00949         // Alpha channel to Transparency! i.e. invert it!
00950         UINT32 BmpSize = Info->bmiHeader.biSizeImage;
00951 
00952         for(UINT32 i = 0; i < BmpSize; i+=4)
00953             Bits[i+3] = ~Bits[i+3];
00954     }
00955 
00956     if (CreateTempFile())
00957     {
00958         // Output a ImageMagick header for this file, using the RGBQUAD palette rather than a LOGPALETTE
00959         DestImageMagick.OutputPNGHeader(TempFile, pInfoHeader, Interlace, TransparentColour, NULL, pPalette);
00960     
00961         // Now write out the bitmap data itself.
00962         DestImageMagick.OutputPNGBits(TempFile, Bits, TRUE, pFilter);
00963         // The above has set the OutputFile member variable of DestImageMagick. We desperately need to
00964         // reset this as otherwise the next bitmap export may go wrong as it calls the tidy up
00965         // and so will refer to the deleted CCFile. Oh Er!
00966         DestImageMagick.TidyUp();
00967         ConvertFromTempFile(File);
00968     }
00969     else
00970     {
00971         DestImageMagick.TidyUp();
00972     }
00973 
00974     TidyTempFile();
00975 
00976     // er, we seem to have finished OK so say so
00977     return TRUE;
00978 #else
00979     return FALSE;
00980 #endif
00981 }

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

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

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/4/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 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 1013 of file imgmgkft.cpp.

01015 {
01016 #ifdef DO_EXPORT
01017 
01018     ERROR2IF(File==NULL,FALSE,"ImageMagickFilter::WriteToFile File pointer is null");
01019     ERROR2IF(Info==NULL,FALSE,"ImageMagickFilter::WriteToFile BitmapInfo pointer is null");
01020     ERROR2IF(Bits==NULL,FALSE,"ImageMagickFilter::WriteToFile Bits pointer is null");
01021 
01022     // If the caller has specified a string then assume they require a progress bar
01023     // Start it up.
01024     if (ProgressString != NULL)
01025         BeginSlowJob(100, FALSE, ProgressString);
01026 
01027     // BITMAPINFO  consists of:-
01028     //      BITMAPINFOHEADER    bmiHeader;
01029     //      RGBQUAD             bmiColors[1];
01030     LPBITMAPINFOHEADER pInfoHeader = &Info->bmiHeader;
01031     ERROR2IF(pInfoHeader==NULL,FALSE,"ImageMagickFilter::WriteToFile BitmapInfoHeader pointer is null");
01032         
01033     LPRGBQUAD pPalette = &(Info->bmiColors[0]);
01034     ERROR2IF(pPalette==NULL,FALSE,"ImageMagickFilter::WriteToFile palette pointer is null");
01035 
01036     // Set up our format type flags.
01037     INT32 Transparent = -1; // colour or -1 = no transparency
01038     BOOL Interlace = s_OutputInterlaced;    // Use interlace or not
01039     BOOL WantTransparent = s_OutputTransparent;
01040 
01041     if (WantTransparent)
01042     {
01043         // We want to try and output the transparency if possible ...
01044 
01045         // Scan through the palette, and try and find an index with
01046         // the transparency flag set
01047 
01048         INT32 cols = Info->bmiHeader.biClrUsed;
01049         // If we have zero colours on a bitmap which is 8bpp or less then this is bad.
01050         // This should be translated as the maximum number of colours allowed
01051         if (Info->bmiHeader.biBitCount <= 8 && cols == 0)
01052             cols = 1 << Info->bmiHeader.biBitCount;
01053 
01054         for (INT32 i = 0; i < cols; i++)
01055         {
01056             if (Info->bmiColors[i].rgbReserved == 0xFF)
01057             {
01058                 Transparent = i;
01059                 TRACEUSER( "Neville", _T("ImageMagick output with transp index of %d\n"),Transparent);
01060                 break;
01061             }       
01062         }   
01063     }
01064 
01065     BOOL ok = CreateTempFile();
01066 
01067     if (ok)
01068     {
01069         // Output the ImageMagick data
01070         // Output a ImageMagick header for this file, using the RGBQUAD palette rather than a LOGPALETTE
01071         if (Transparent == -1)
01072             ok = DestImageMagick.OutputPNGHeader(TempFile, pInfoHeader, Interlace, -1, NULL, pPalette);
01073         else
01074             ok = DestImageMagick.OutputPNGHeader(TempFile, pInfoHeader, Interlace, Transparent, NULL, pPalette);
01075     }
01076 
01077     // Now write out the bitmap data itself.
01078     if (ok)
01079         ok = DestImageMagick.OutputPNGBits(TempFile, Bits, TRUE);
01080 
01081     // Tidy up here anyway
01082     DestImageMagick.TidyUp();
01083 
01084     // process it
01085     if (ok)
01086         ok = ConvertFromTempFile(File);
01087 
01088     // If started, then stop then progress bar
01089     if (ProgressString != NULL)
01090         EndSlowJob();
01091 
01092     TidyTempFile();
01093 
01094     ERROR1IF(!ok, FALSE, _R(IDE_IMAGEMAGICK_ERROR));
01095 
01096     // er, we seem to have finished OK so say so
01097     return TRUE;
01098 #endif
01099 }


Member Data Documentation

UINT32 ImageMagickFilter::Export2ndStageMsgID [protected]
 

Definition at line 304 of file imgmgkft.h.

ResourceID ImageMagickFilter::FilterExtID [protected]
 

Definition at line 296 of file imgmgkft.h.

INT32 ImageMagickFilter::ImageMagickHowCompatible [protected]
 

Definition at line 299 of file imgmgkft.h.

ImageMagickFlags ImageMagickFilter::m_Capabilities [protected]
 

Definition at line 306 of file imgmgkft.h.

DPI ImageMagickFilter::m_ImportDPI [protected]
 

Definition at line 307 of file imgmgkft.h.

BOOL ImageMagickFilter::s_Disable = FALSE [static, protected]
 

Definition at line 316 of file imgmgkft.h.

BOOL ImageMagickFilter::s_DoWarning = TRUE [static, protected]
 

Definition at line 315 of file imgmgkft.h.

FilterType ImageMagickFilter::s_FilterType = IMAGEMAGICK [static, protected]
 

Definition at line 301 of file imgmgkft.h.

BOOL ImageMagickFilter::s_HaveCheckedPath = FALSE [static, protected]
 

Definition at line 314 of file imgmgkft.h.

BOOL ImageMagickFilter::s_HaveImageMagick = FALSE [static, protected]
 

Definition at line 313 of file imgmgkft.h.

String_256 ImageMagickFilter::s_ImageMagickPath = _T( "convert" ) [static, protected]
 

Definition at line 312 of file imgmgkft.h.

BOOL ImageMagickFilter::s_OutputInterlaced = FALSE [static, protected]
 

Definition at line 320 of file imgmgkft.h.

BOOL ImageMagickFilter::s_OutputTransparent = FALSE [static, protected]
 

Definition at line 319 of file imgmgkft.h.

CCDiskFile* ImageMagickFilter::TempFile [protected]
 

Definition at line 309 of file imgmgkft.h.

wxString ImageMagickFilter::TempFileName [protected]
 

Definition at line 310 of file imgmgkft.h.


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