]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sun, 9 May 2010 03:05:41 +0000 (03:05 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sun, 9 May 2010 03:05:41 +0000 (03:05 +0000)
magick/quantum-private.h
magick/quantum.h

index 5ab1cd47e898a34874e9b12b6ed640fef1c49d16..fc4861c7c8dd3f7dc310edd57ff5ca971e94063f 100644 (file)
@@ -289,21 +289,13 @@ static inline const unsigned char *PushShortPixel(const EndianType endian,
 static inline Quantum ScaleAnyToQuantum(const QuantumAny quantum,
   const QuantumAny range)
 {
-#if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((Quantum) (((MagickRealType) QuantumRange*quantum)/range+0.5));
-#else
-  return((Quantum) (((MagickRealType) QuantumRange*quantum)/range+0.0));
-#endif
 }
 
 static inline QuantumAny ScaleQuantumToAny(const Quantum quantum,
   const QuantumAny range)
 {
-#if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((QuantumAny) (((MagickRealType) range*quantum)/QuantumRange+0.5));
-#else
-  return((QuantumAny) (((MagickRealType) range*quantum)/QuantumRange+0.5));
-#endif
 }
 
 #if (MAGICKCORE_QUANTUM_DEPTH == 8)
@@ -369,9 +361,9 @@ static inline unsigned short ScaleQuantumToShort(const Quantum quantum)
 #else
   if (quantum <= 0.0)
     return(0);
-  if ((256.0*quantum) >= 65535.0)
+  if ((257.0*quantum) >= 65535.0)
     return(65535);
-  return((unsigned short) (256.0*quantum+0.5));
+  return((unsigned short) (257.0*quantum+0.5));
 #endif
 }
 
@@ -380,7 +372,7 @@ static inline Quantum ScaleShortToQuantum(const unsigned short value)
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((Quantum) ((value+128U)/257U));
 #else
-  return((Quantum) (value/256.0+0.5));
+  return((Quantum) (value/257.0+0.5));
 #endif
 }
 #elif (MAGICKCORE_QUANTUM_DEPTH == 16)
@@ -389,7 +381,7 @@ static inline Quantum ScaleCharToQuantum(const unsigned char value)
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((Quantum) (257U*value));
 #else
-  return((Quantum) (256.0*value+0.5));
+  return((Quantum) (257.0*value+0.5));
 #endif
 }
 
@@ -399,7 +391,7 @@ static inline Quantum ScaleLongToQuantum(const unsigned long value)
   return((Quantum) ((value+MagickULLConstant(32768))/
     MagickULLConstant(65537)));
 #else
-  return((Quantum) (value/65536.0+0.5));
+  return((Quantum) (value/65537.0+0.5));
 #endif
 }
 
@@ -425,9 +417,9 @@ static inline unsigned long ScaleQuantumToLong(const Quantum quantum)
 #else
   if (quantum <= 0.0)
     return(0UL);
-  if ((65536.0*quantum) >= 4294967295.0)
+  if ((65537.0*quantum) >= 4294967295.0)
     return(4294967295UL);
-  return((unsigned long) (65536.0*quantum+0.5));
+  return((unsigned long) (65537.0*quantum+0.5));
 #endif
 }
 
@@ -467,7 +459,7 @@ static inline Quantum ScaleCharToQuantum(const unsigned char value)
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((Quantum) (16843009UL*value));
 #else
-  return((Quantum) (16843008.0*value+0.5));
+  return((Quantum) (16843009.0*value+0.5));
 #endif
 }
 
@@ -487,7 +479,7 @@ static inline Quantum ScaleMapToQuantum(const MagickRealType value)
 #else
   if (value >= MaxMap)
     return(QuantumRange);
-  return((Quantum) (65536UL*value+0.5));
+  return((Quantum) (65537UL*value+0.5));
 #endif
 }
 
@@ -506,7 +498,7 @@ static inline unsigned long ScaleQuantumToMap(const Quantum quantum)
   return((unsigned long) ((quantum+MagickULLConstant(32768))/
     MagickULLConstant(65537)));
 #else
-  return((unsigned long) (quantum/65536.0+0.5));
+  return((unsigned long) (quantum/65537.0+0.5));
 #endif
 }
 
@@ -518,9 +510,9 @@ static inline unsigned short ScaleQuantumToShort(const Quantum quantum)
 #else
   if (quantum <= 0.0)
     return(0);
-  if ((quantum/65536.0) >= 65535.0)
+  if ((quantum/65537.0) >= 65535.0)
     return(65535);
-  return((unsigned short) (quantum/65536.0+0.5));
+  return((unsigned short) (quantum/65537.0+0.5));
 #endif
 }
 
@@ -529,7 +521,7 @@ static inline Quantum ScaleShortToQuantum(const unsigned short value)
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((Quantum) (65537UL*value));
 #else
-  return((Quantum) (65536.0*value+0.5));
+  return((Quantum) (65537.0*value+0.5));
 #endif
 }
 #elif (MAGICKCORE_QUANTUM_DEPTH == 64)
@@ -538,7 +530,7 @@ static inline Quantum ScaleCharToQuantum(const unsigned char value)
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((Quantum) (MagickULLConstant(71777214294589695)*value));
 #else
-  return((Quantum) (71777214294589694.0*value+0.5));
+  return((Quantum) (71777214294589695.0*value+0.5));
 #endif
 }
 
@@ -547,7 +539,7 @@ static inline Quantum ScaleLongToQuantum(const unsigned long value)
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((Quantum) (4294967295UL*value));
 #else
-  return((Quantum) (4294967294.0*value+0.5));
+  return((Quantum) (4294967295.0*value+0.5));
 #endif
 }
 
@@ -562,7 +554,7 @@ static inline Quantum ScaleMapToQuantum(const MagickRealType value)
 #else
   if (value >= MaxMap)
     return(QuantumRange);
-  return((Quantum) (MagickULLConstant(281479271612414)*value+0.5));
+  return((Quantum) (MagickULLConstant(281479271612415)*value+0.5));
 #endif
 }
 
@@ -571,7 +563,7 @@ static inline unsigned long ScaleQuantumToLong(const Quantum quantum)
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((unsigned long) ((quantum+2147483648.0)/4294967297.0));
 #else
-  return((unsigned long) (quantum/4294967296.0+0.5));
+  return((unsigned long) (quantum/4294967297.0+0.5));
 #endif
 }
 
@@ -584,7 +576,7 @@ static inline unsigned long ScaleQuantumToMap(const Quantum quantum)
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((unsigned long) ((quantum+2147450879.0)/281479271612415.0));
 #else
-  return((unsigned long) (quantum/281479271612414.0)+0.5);
+  return((unsigned long) (quantum/281479271612415.0)+0.5);
 #endif
 }
 
@@ -593,7 +585,7 @@ static inline unsigned short ScaleQuantumToShort(const Quantum quantum)
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((unsigned short) ((quantum+2147450879.0)/281479271612415.0));
 #else
-  return((unsigned short) (quantum/281479271612414.0+0.5));
+  return((unsigned short) (quantum/281479271612415.0+0.5));
 #endif
 }
 
@@ -602,7 +594,7 @@ static inline Quantum ScaleShortToQuantum(const unsigned short value)
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((Quantum) (MagickULLConstant(281479271612415)*value));
 #else
-  return((Quantum) (281479271612414.0*value));
+  return((Quantum) (281479271612415.0*value));
 #endif
 }
 #endif
index 8348068a538d68bd93db103b058e4d7295da9983..a36f0d37936d35798ee2dfe10dba3fc24047e720 100644 (file)
@@ -115,9 +115,9 @@ static inline unsigned char ScaleQuantumToChar(const Quantum quantum)
 #else
   if (quantum <= 0.0)
     return(0);
-  if ((quantum/256.0) >= 255.0)
+  if ((quantum/257.0) >= 255.0)
     return(255);
-  return((unsigned char) (quantum/256.0+0.5));
+  return((unsigned char) (quantum/257.0+0.5));
 #endif
 }
 #elif (MAGICKCORE_QUANTUM_DEPTH == 32)
@@ -129,9 +129,9 @@ static inline unsigned char ScaleQuantumToChar(const Quantum quantum)
 #else
   if (quantum <= 0.0)
     return(0);
-  if ((quantum/16843008.0) >= 255.0)
+  if ((quantum/16843009.0) >= 255.0)
     return(255);
-  return((unsigned char) (quantum/16843008.0+0.5));
+  return((unsigned char) (quantum/16843009.0+0.5));
 #endif
 }
 #elif (MAGICKCORE_QUANTUM_DEPTH == 64)
@@ -140,7 +140,7 @@ static inline unsigned char ScaleQuantumToChar(const Quantum quantum)
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((unsigned char) ((quantum+2155839615.0)/71777214294589695.0));
 #else
-  return((unsigned char) (quantum/71777214294589694.0+0.5));
+  return((unsigned char) (quantum/71777214294589695.0+0.5));
 #endif
 }
 #endif