]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Wed, 31 Mar 2010 02:06:45 +0000 (02:06 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Wed, 31 Mar 2010 02:06:45 +0000 (02:06 +0000)
magick/colorspace.c
magick/identify.c
magick/quantum-private.h

index 3b4e0b3943559fc52f0ee6badeaaef7df668e759..134c9516dbc1a885ccf876ac61b0f8584d5ca51b 100644 (file)
@@ -606,7 +606,7 @@ MagickExport MagickBooleanType RGBTransformImage(Image *image,
       for (i=0; i <= (long) MaxMap; i++)
         logmap[i]=ScaleMapToQuantum((MagickRealType) (MaxMap*(reference_white+
           log10(black+((MagickRealType) i/MaxMap)*(1.0-black))/((gamma/density)*
-          0.002/film_gamma))/1024.0+0.5));
+          0.002/film_gamma))/1024.0));
       image_view=AcquireCacheView(image);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
@@ -1760,6 +1760,7 @@ MagickExport MagickBooleanType TransformRGBImage(Image *image,
       double
         black,
         density,
+        film_gamma,
         gamma,
         reference_black,
         reference_white;
@@ -1775,6 +1776,10 @@ MagickExport MagickBooleanType TransformRGBImage(Image *image,
       value=GetImageProperty(image,"gamma");
       if (value != (const char *) NULL)
         gamma=1.0/StringToDouble(value) != 0.0 ? StringToDouble(value) : 1.0;
+      film_gamma=FilmGamma;
+      value=GetImageProperty(image,"film-gamma");
+      if (value != (const char *) NULL)
+        film_gamma=StringToDouble(value);
       reference_black=ReferenceBlack;
       value=GetImageProperty(image,"reference-black");
       if (value != (const char *) NULL)
@@ -1789,13 +1794,13 @@ MagickExport MagickBooleanType TransformRGBImage(Image *image,
         ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
           image->filename);
       black=pow(10.0,(reference_black-reference_white)*(gamma/density)*
-        0.002/0.6);
+        0.002/film_gamma);
       for (i=0; i <= (long) (reference_black*MaxMap/1024.0); i++)
         logmap[i]=(Quantum) 0;
       for ( ; i < (long) (reference_white*MaxMap/1024.0); i++)
         logmap[i]=ClampToQuantum((MagickRealType) QuantumRange/(1.0-black)*
           (pow(10.0,(1024.0*i/MaxMap-reference_white)*
-          (gamma/density)*0.002/0.6)-black));
+          (gamma/density)*0.002/film_gamma)-black));
       for ( ; i <= (long) MaxMap; i++)
         logmap[i]=(Quantum) QuantumRange;
       if (SetImageStorageClass(image,DirectClass) == MagickFalse)
index 7c38a4278b8aa33575e98c72ec6c47cf734a5314..1004a144fc6acd55d2cd4860caf8de5bb51a5e38 100644 (file)
@@ -217,12 +217,13 @@ static int PrintChannelStatistics(FILE *file,const ChannelType channel,
   int
     status;
 
-  status=fprintf(file,StatisticsFormat,name,(Quantum) (scale*
-    channel_statistics[channel].minima+0.5),channel_statistics[channel].minima/
-    (double) QuantumRange,(Quantum) (scale*channel_statistics[channel].maxima+
-    0.5),channel_statistics[channel].maxima/(double) QuantumRange,scale*
-    channel_statistics[channel].mean,channel_statistics[channel].mean/
-    (double) QuantumRange,scale*channel_statistics[channel].standard_deviation,
+  status=fprintf(file,StatisticsFormat,name,ClampToQuantum(scale*
+    channel_statistics[channel].minima),channel_statistics[channel].minima/
+    (double) QuantumRange,ClampToQuantum(scale*
+    channel_statistics[channel].maxima),channel_statistics[channel].maxima/
+    (double) QuantumRange,scale*channel_statistics[channel].mean,
+    channel_statistics[channel].mean/(double) QuantumRange,scale*
+    channel_statistics[channel].standard_deviation,
     channel_statistics[channel].standard_deviation/(double) QuantumRange,
     channel_statistics[channel].kurtosis,channel_statistics[channel].skewness);
   return(status);
index 79fa1805516d3ded9760396b9a6c2cdc8c7e490f..27ba52c040cb844589c0b53e2e9d22ff8fa26337 100644 (file)
@@ -323,11 +323,13 @@ static inline Quantum ScaleLongToQuantum(const unsigned long value)
 
 static inline Quantum ScaleMapToQuantum(const MagickRealType value)
 {
+  if (value <= 0.0)
+    return((Quantum) 0);
 #if defined(MAGICKCORE_HDRI_SUPPORT)
+  if (value >= MaxMap)
+    return((Quantum) QuantumRange);
   return((Quantum) value);
 #else
-  if (value <= 0.0)
-    return(0);
   if ((value+0.5) >= MaxMap)
     return((Quantum) QuantumRange);
   return((Quantum) (value+0.5));
@@ -349,13 +351,13 @@ static inline unsigned long ScaleQuantumToLong(const Quantum quantum)
 
 static inline unsigned long ScaleQuantumToMap(const Quantum quantum)
 {
+  if (quantum < 0.0)
+    return(0UL);
   if (quantum >= (Quantum) MaxMap)
     return((unsigned long) MaxMap);
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((unsigned long) quantum);
 #else
-  if (quantum < 0.0)
-    return(0UL);
   return((unsigned long) (quantum+0.5));
 #endif
 }
@@ -403,11 +405,13 @@ static inline Quantum ScaleLongToQuantum(const unsigned long value)
 
 static inline Quantum ScaleMapToQuantum(const MagickRealType value)
 {
+  if (value <= 0.0)
+    return((Quantum) 0);
 #if defined(MAGICKCORE_HDRI_SUPPORT)
+  if (value >= MaxMap)
+    return((Quantum) QuantumRange);
   return((Quantum) value);
 #else
-  if (value <= 0.0)
-    return(0);
   if ((value+0.5) >= MaxMap)
     return((Quantum) QuantumRange);
   return((Quantum) (value+0.5));
@@ -429,13 +433,13 @@ static inline unsigned long ScaleQuantumToLong(const Quantum quantum)
 
 static inline unsigned long ScaleQuantumToMap(const Quantum quantum)
 {
+  if (quantum < 0.0)
+    return(0UL);
   if (quantum >= (Quantum) MaxMap)
     return((unsigned long) MaxMap);
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((unsigned long) quantum);
 #else
-  if (quantum < 0.0)
-    return(0UL);
   return((unsigned long) (quantum+0.5));
 #endif
 }
@@ -474,11 +478,13 @@ static inline Quantum ScaleLongToQuantum(const unsigned long value)
 
 static inline Quantum ScaleMapToQuantum(const MagickRealType value)
 {
+  if (value <= 0.0)
+    return((Quantum) 0);
 #if defined(MAGICKCORE_HDRI_SUPPORT)
+  if (value >= MaxMap)
+    return(QuantumRange);
   return((Quantum) (65537.0*value));
 #else
-  if (value <= 0.0)
-    return(0);
   if ((value+0.5) >= MaxMap)
     return(QuantumRange);
   return((Quantum) (65537UL*value));
@@ -492,14 +498,14 @@ static inline unsigned long ScaleQuantumToLong(const Quantum quantum)
 
 static inline unsigned long ScaleQuantumToMap(const Quantum quantum)
 {
+  if (quantum < 0.0)
+    return(0UL);
   if ((quantum/65537) >= MaxMap)
     return((unsigned long) MaxMap);
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((unsigned long) ((quantum+MagickULLConstant(32768))/
     MagickULLConstant(65537)));
 #else
-  if (quantum < 0.0)
-    return(0UL);
   return((unsigned long) (quantum/65537.0)+0.5);
 #endif
 }
@@ -547,11 +553,13 @@ static inline Quantum ScaleLongToQuantum(const unsigned long value)
 
 static inline Quantum ScaleMapToQuantum(const MagickRealType value)
 {
+  if (value <= 0.0)
+    return((Quantum) 0);
 #if defined(MAGICKCORE_HDRI_SUPPORT)
+  if (value >= MaxMap)
+    return(QuantumRange);
   return((Quantum) (281479271612415.0*value));
 #else
-  if (value <= 0.0)
-    return(0);
   if ((value+0.5) >= MaxMap)
     return(QuantumRange);
   return((Quantum) (MagickULLConstant(281479271612415)*value));
@@ -569,13 +577,13 @@ static inline unsigned long ScaleQuantumToLong(const Quantum quantum)
 
 static inline unsigned long ScaleQuantumToMap(const Quantum quantum)
 {
+  if (quantum < 0.0)
+    return(0UL);
   if ((quantum/281479271612415.0) >= MaxMap)
     return((unsigned long) MaxMap);
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((unsigned long) ((quantum+2147450879.0)/281479271612415.0));
 #else
-  if (quantum < 0.0)
-    return(0UL);
   return((unsigned long) (quantum/281479271612415.0)+0.5);
 #endif
 }