[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : alex
Repository : xara
Revision   : 1468
Date       : Tue Jul 18 18:15:54 BST 2006

Changed paths:
   M /Trunk/XaraLX/Kernel/filters.cpp
   M /Trunk/XaraLX/wxOil/imgmgkft.cpp
   M /Trunk/XaraLX/wxOil/imgmgkft.h
   M /Trunk/XaraLX/wxOil/prdlgctl.cpp
   M /Trunk/XaraLX/wxOil/stdwx.h
   M /Trunk/XaraLX/wxOil/xrc/EN/imagemagick-strings.xrc

Basic ImageMagick import/export (only enabled in debug buid right now)


Diff:
Index: Trunk/XaraLX/Kernel/filters.cpp
===================================================================
--- Trunk/XaraLX/Kernel/filters.cpp	(revision 1467)
+++ Trunk/XaraLX/Kernel/filters.cpp	(revision 1468)
@@ -722,7 +722,6 @@
 	}																				\
 																					\
 	FilterList.AddTail(pFilter);
-	
 
 /********************************************************************************************
 
@@ -789,7 +788,10 @@
 
 	ADD_FILTER(PNGFilter)
 #if _DEBUG
-	ADD_FILTER(ImageMagickFilter)
+	if (ImageMagickFilter::CheckPath())
+	{
+		ADD_FILTER(ImageMagickFilter)
+	}
 #endif
 	ADD_FILTER(TI_GIFFilter)
 PORTNOTETRACE("filter","Removed TIFFFilter");
Index: Trunk/XaraLX/wxOil/imgmgkft.cpp
===================================================================
--- Trunk/XaraLX/wxOil/imgmgkft.cpp	(revision 1467)
+++ Trunk/XaraLX/wxOil/imgmgkft.cpp	(revision 1468)
@@ -1,12 +1,12 @@
 // $Id: pngfiltr.cpp 1282 2006-06-09 09:46:49Z alex $
 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
 ================================XARAHEADERSTART===========================
+ 
+               Xara LX, a vector drawing and manipulation program.
+                    Copyright (C) 1993-2006 Xara Group Ltd.
+       Copyright on certain contributions may be held in joint with their
+              respective authors. See AUTHORS file for details.
 
-			Xara LX, a vector drawing and manipulation program.
-					Copyright (C) 1993-2006 Xara Group Ltd.
-	Copyright on certain contributions may be held in joint with their
-			respective authors. See AUTHORS file for details.
-
 LICENSE TO USE AND MODIFY SOFTWARE
 ----------------------------------
 
@@ -71,11 +71,11 @@
 free to do whatever you like with your modifications. However, you may
 (at your option) wish contribute them to Xara's source tree. You can
 find details of how to do this at:
-http://www.xaraxtreme.org/developers/
+  http://www.xaraxtreme.org/developers/
 
 Prior to contributing your modifications, you will need to complete our
 contributor agreement. This can be found at:
-http://www.xaraxtreme.org/developers/contribute/
+  http://www.xaraxtreme.org/developers/contribute/
 
 Please note that Xara will not accept modifications which modify any of
 the text between the start and end of this header (marked
@@ -90,11 +90,11 @@
 service marks of Xara Group Ltd. All rights in these marks are reserved.
 
 
-	Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
-						http://www.xara.com/
+      Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
+                        http://www.xara.com/
 
 =================================XARAHEADEREND============================
-*/
+ */
 
 // A ImageMagick import/export filter 
 
@@ -130,13 +130,28 @@
 
 #define	new	CAM_DEBUG_NEW
 
+// Set the default path from a macro so it can be overridden at compile time
+#ifndef DEFAULT_IMAGEMAGICK_PATH
+	#define DEFAULT_IMAGEMAGICK_PATH "/usr/bin/convert"
+#endif
+
+#define DIP_QUOTE(x) _T(x) 
+
 OutputPNG 	ImageMagickFilter::DestImageMagick;
 FilterType 	ImageMagickFilter::s_FilterType = IMAGEMAGICK;	// Type of filter in use (ImageMagick .. ImageMagick_TRANSINTER)
 
+String_256	ImageMagickFilter::s_ImageMagickPath = DIP_QUOTE(DEFAULT_IMAGEMAGICK_PATH);
+BOOL 		ImageMagickFilter::s_HaveImageMagick = FALSE;
+BOOL		ImageMagickFilter::s_HaveCheckedPath = FALSE;
+BOOL		ImageMagickFilter::s_DoWarning = TRUE;
+BOOL		ImageMagickFilter::s_Disable = FALSE;
+
 #if 1
 
 UINT32 ImageMagickExportOptions::g_CompactedFlagsForDefaults = 0;
 
+
+
 /********************************************************************************************
 
 >	static BOOL ImageMagickExportOptions::Declare()
@@ -150,11 +165,11 @@
 ********************************************************************************************/
 BOOL ImageMagickExportOptions::Declare()
 {
-	if (Camelot.DeclareSection(_T("Filters"), 10))
-		Camelot.DeclarePref( NULL, _T("ExportImageMagicktype"), &g_CompactedFlagsForDefaults, 0, 3 );
+	BOOL ok = Camelot.DeclareSection(_T("Filters"), 10)
+			&& Camelot.DeclarePref( NULL, _T("ExportImageMagicktype"), &g_CompactedFlagsForDefaults, 0, 3 );
 
 	// All ok
-	return TRUE;
+	return ok;
 }
 
 /********************************************************************************************
@@ -256,6 +271,9 @@
 ********************************************************************************************/
 BOOL ImageMagickFilter::Init()
 {
+	if (!ImageMagickExportOptions::Declare())
+		return FALSE;
+
 	// Get the OILFilter object
 	pOILFilter = new ImageMagickOILFilter(this);
 	if (pOILFilter==NULL)
@@ -265,9 +283,6 @@
 	FilterName.Load(_R(IDS_IMAGEMAGICK_FILTERNAME));
 	FilterInfo.Load(_R(IDS_IMAGEMAGICK_FILTERINFO));
 
-	if (!ImageMagickExportOptions::Declare())
-		return FALSE;
-
 	// All ok
 	return TRUE;
 }
@@ -1375,7 +1390,12 @@
 	IMargv[1]=cifn;
 	IMargv[2]=cofn;
 	IMargv[3]=NULL;
+
+#ifdef AVOID_BROKEN_GDB
+	::wxCopyFile(wxString(_T("/tmp/test.png")), TempFileName);
+#else
 	long /*TYPENOTE: Correct*/ ret = ::wxExecute((wxChar **)IMargv, wxEXEC_SYNC);
+#endif
 	
 	free(cifn);
 	free(cofn);
@@ -1386,6 +1406,15 @@
 		ERROR1(FALSE, _R(IDE_IMAGEMAGICK_ERROR));
 	}
 
+	PathName pthFileName=String_256(TempFileName);
+
+	// Reopen the file
+	if (!(TempFile->open(pthFileName, ios::in | ios::binary)))
+	{
+		TidyTempFile();
+		ERROR1(FALSE, _R(IDE_IMAGEMAGICK_ERROR));
+	}
+
 	return TRUE;		
 }
 
@@ -1419,3 +1448,70 @@
 	}
 	return TRUE;
 }
+
+/********************************************************************************************
+
+>	static BOOL ImageMagickFilter::CheckPath()
+
+	Author:		Alex Bligh <alex@xxxxxxxxxxx>
+	Created:	18/07/2006
+	Purpose:	Determines whether or not ImageMagick is installed. Also registers filter prefs
+	Inputs:		None
+	Outputs:	None
+	Returns:	TRUE if ImageMagick is available, else fals
+	Notes:		-
+
+********************************************************************************************/
+
+BOOL ImageMagickFilter::CheckPath()
+{
+	if (s_HaveCheckedPath)
+		return s_HaveImageMagick;
+
+	s_HaveImageMagick = FALSE;
+	s_HaveCheckedPath = TRUE;
+
+	BOOL ok = Camelot.DeclareSection(_T("Filters"), 10)
+			&& Camelot.DeclarePref( NULL, _T("ImageMagickDisable"), &ImageMagickFilter::s_Disable, 0, 1 )
+			&& Camelot.DeclarePref( NULL, _T("ImageMagickWarning"), &ImageMagickFilter::s_DoWarning, 0, 1 )
+			&& Camelot.DeclarePref( NULL, _T("ImageMagickPath"), &ImageMagickFilter::s_ImageMagickPath );
+
+	if (!ok || s_Disable)
+		return s_HaveImageMagick;
+
+	if (s_ImageMagickPath == _T(""))
+		s_ImageMagickPath = DIP_QUOTE(DEFAULT_IMAGEMAGICK_PATH);
+
+	wxArrayString output;
+	long /*TYPENOTE: Correct*/ ret=::wxExecute(wxString((const TCHAR *)s_ImageMagickPath)/*+_T(" --version")*/, output);
+	if (!ret && output.GetCount()>0)
+	{
+		wxString check = output[0];
+		wxString version;
+		if (check.StartsWith(_T("Version: ImageMagick "),&version))
+		{
+			wxStringTokenizer tk(version, _T(".: "));
+			if (tk.CountTokens()>=3)
+			{
+				long /*TYPENOTE: Correct*/ v1,v2,v3=0;
+				tk.GetNextToken().ToLong(&v1);
+				tk.GetNextToken().ToLong(&v2);
+				tk.GetNextToken().ToLong(&v3);
+				double version = v1*10000.0+v2*100.0+v3;
+				if (version>=060000.0)
+				{
+					s_HaveImageMagick = TRUE;
+				}
+			}
+		}
+	}
+
+	if (!s_HaveImageMagick && s_DoWarning)
+	{
+		InformWarning(_R(IDS_WARN_NOIMAGEMAGICK), _R(IDS_OK));
+		s_DoWarning = FALSE; // disable the warning on subsequent runs
+	}
+
+	return s_HaveImageMagick;		
+}
+
Index: Trunk/XaraLX/wxOil/prdlgctl.cpp
===================================================================
--- Trunk/XaraLX/wxOil/prdlgctl.cpp	(revision 1467)
+++ Trunk/XaraLX/wxOil/prdlgctl.cpp	(revision 1468)
@@ -135,11 +135,6 @@
 
 #define Swap(a,b)       { (a)^=(b), (b)^=(a), (a)^=(b); }
 
-// This should be in stdwx.h
-#if wxUSE_LIBGNOMEPRINT
-#include <wx/gtk/gnome/gprint.h>
-#endif
-
 PORTNOTE("printing", "Disabled message map stuff")
 #ifndef EXCLUDE_FROM_XARALX
 //---------------------------------
Index: Trunk/XaraLX/wxOil/xrc/EN/imagemagick-strings.xrc
===================================================================
--- Trunk/XaraLX/wxOil/xrc/EN/imagemagick-strings.xrc	(revision 1467)
+++ Trunk/XaraLX/wxOil/xrc/EN/imagemagick-strings.xrc	(revision 1468)
@@ -58,6 +58,12 @@
                                         <label>ImageMagick failed to convert the file</label>
                                 </object>
                         </object>
+                        <object class="sizeritem">
+                                <flag>wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE</flag>
+                                <object class="wxStaticText" name="IDS_WARN_NOIMAGEMAGICK">
+                                        <label>Xara LX cannot find ImageMagick version 6.0.0 or above. Various bitmap filters will be disabled. To install ImageMagick, either use the package manager supplied with your distribution, or visit http://www.imagemagic.org/</label>
+                                </object>
+                        </object>
 		</object>
         </object>
 </resource>
Index: Trunk/XaraLX/wxOil/imgmgkft.h
===================================================================
--- Trunk/XaraLX/wxOil/imgmgkft.h	(revision 1467)
+++ Trunk/XaraLX/wxOil/imgmgkft.h	(revision 1468)
@@ -1,12 +1,12 @@
 // $Id: pngfiltr.h 809 2006-04-13 11:28:42Z phil $
 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
 ================================XARAHEADERSTART===========================
+ 
+               Xara LX, a vector drawing and manipulation program.
+                    Copyright (C) 1993-2006 Xara Group Ltd.
+       Copyright on certain contributions may be held in joint with their
+              respective authors. See AUTHORS file for details.
 
-			Xara LX, a vector drawing and manipulation program.
-					Copyright (C) 1993-2006 Xara Group Ltd.
-	Copyright on certain contributions may be held in joint with their
-			respective authors. See AUTHORS file for details.
-
 LICENSE TO USE AND MODIFY SOFTWARE
 ----------------------------------
 
@@ -71,11 +71,11 @@
 free to do whatever you like with your modifications. However, you may
 (at your option) wish contribute them to Xara's source tree. You can
 find details of how to do this at:
-http://www.xaraxtreme.org/developers/
+  http://www.xaraxtreme.org/developers/
 
 Prior to contributing your modifications, you will need to complete our
 contributor agreement. This can be found at:
-http://www.xaraxtreme.org/developers/contribute/
+  http://www.xaraxtreme.org/developers/contribute/
 
 Please note that Xara will not accept modifications which modify any of
 the text between the start and end of this header (marked
@@ -90,11 +90,11 @@
 service marks of Xara Group Ltd. All rights in these marks are reserved.
 
 
-	Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
-						http://www.xara.com/
+      Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
+                        http://www.xara.com/
 
 =================================XARAHEADEREND============================
-*/
+ */
 //
 
 #ifndef INC_IMGMGKFT_H
@@ -188,6 +188,8 @@
 	virtual UINT32 GetExportMsgID();
 	virtual void PostGetExportOptions(BitmapExportOptions* pOptions);
 
+	static BOOL CheckPath();
+
 protected:
 
 	// Invert the alpha channel.
@@ -245,6 +247,12 @@
 
 	CCDiskFile * TempFile;
 	wxString TempFileName;
+
+	static String_256	s_ImageMagickPath;
+	static BOOL s_HaveImageMagick;
+	static BOOL s_HaveCheckedPath;
+	static BOOL s_DoWarning;
+	static BOOL s_Disable;
 };
 
 #endif // INC_ImageMagickFILTR
Index: Trunk/XaraLX/wxOil/stdwx.h
===================================================================
--- Trunk/XaraLX/wxOil/stdwx.h	(revision 1467)
+++ Trunk/XaraLX/wxOil/stdwx.h	(revision 1468)
@@ -129,6 +129,7 @@
 #include <wx/splash.h>
 #include <wx/stdpaths.h>
 #include <wx/sysopt.h>
+#include <wx/tokenzr.h>
 #include <wx/tooltip.h>
 #include <wx/treectrl.h>
 #include <wx/wxchar.h>
@@ -149,8 +150,10 @@
 #if wxUSE_TOOLBOOK
 #include <wx/toolbook.h>
 #endif
+#if wxUSE_LIBGNOMEPRINT
+#include <wx/gtk/gnome/gprint.h>
+#endif
 
-
 // Now platform dependent stuff
 // FreeBSD does not provide backtrace()
 #if !defined(__WXMAC__) && !defined(__FreeBSD__)


Xara