]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/magick.c
Fix CLUT interpolation method
[imagemagick] / MagickCore / magick.c
index 766441aed70dd8330c5de57c770f89a0a47aba04..0b6772b60ecb4918fd8a08aac4e24ce198fe9b76 100644 (file)
@@ -18,7 +18,7 @@
 %                             November 1998                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
@@ -665,24 +665,7 @@ MagickExport char **GetMagickList(const char *pattern,
 */
 MagickExport int GetMagickPrecision(void)
 {
-#define MagickPrecision  6
-
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
-  if (SetMagickPrecision(0) == 0)
-    {
-      char
-        *limit;
-
-      (void) SetMagickPrecision(MagickPrecision);
-      limit=GetEnvironmentValue("MAGICK_PRECISION");
-      if (limit == (char *) NULL)
-        limit=GetPolicyValue("precision");
-      if (limit != (char *) NULL)
-        {
-          (void) SetMagickPrecision(StringToInteger(limit));
-          limit=DestroyString(limit);
-        }
-    }
   return(SetMagickPrecision(0));
 }
 \f
@@ -1521,7 +1504,13 @@ MagickExport MagickInfo *SetMagickInfo(const char *name)
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  SetMagickPrecision() sets the maximum number of significant digits to be
-%  printed and returns it.
+%  printed.
+%
+%  An input argument of 0 returns the current precision setting.
+%
+%  A negative value forces the precision to reset to a default value according
+%  to the environment variable "MAGICK_PRECISION", the current 'policy'
+%  configuration setting, or the default value of '6', in that order.
 %
 %  The format of the SetMagickPrecision method is:
 %
@@ -1534,12 +1523,32 @@ MagickExport MagickInfo *SetMagickInfo(const char *name)
 */
 MagickExport int SetMagickPrecision(const int precision)
 {
+#define MagickPrecision  6
+
   static int
     magick_precision = 0;
 
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
-  if (precision != 0)
+  if (precision > 0)
     magick_precision=precision;
+  if ((precision < 0) || (magick_precision == 0))
+    {
+      char
+        *limit;
+
+      /*
+        Precision reset, or it has not been set yet
+      */
+      magick_precision = MagickPrecision;
+      limit=GetEnvironmentValue("MAGICK_PRECISION");
+      if (limit == (char *) NULL)
+        limit=GetPolicyValue("precision");
+      if (limit != (char *) NULL)
+        {
+          magick_precision=StringToInteger(limit);
+          limit=DestroyString(limit);
+        }
+    }
   return(magick_precision);
 }
 \f