]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/pixel-private.h
(no commit message)
[imagemagick] / MagickCore / pixel-private.h
index 58dc5111493bb48626a39c73f3cb8fa5bb1a1653..e71e63acde7c094abb35804d34692a4c6431b25e 100644 (file)
@@ -1,12 +1,12 @@
 /*
-  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization
+  Copyright 1999-2014 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.
   obtain a copy of the License at
-  
+
     http://www.imagemagick.org/script/license.php
-  
+
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 extern "C" {
 #endif
 
-static inline MagickRealType AlphaReciprocal(const MagickRealType alpha)
+static inline double PerceptibleReciprocal(const double x)
 {
-  MagickRealType
-    beta;
+  double
+    sign;
 
   /*
-    Reciprocal alpha: clamp to [MagickEpsilon,1], return reciprocal.
+    Return 1/x where x is perceptible (not unlimited or infinitesimal).
   */
-  beta=(alpha > (MagickRealType) 1.0 ? (MagickRealType) 1.0 : alpha);
-  beta=(beta < MagickEpsilon ? MagickEpsilon : beta);
-  return((MagickRealType) 1.0/beta);
+  sign=x < 0.0 ? -1.0 : 1.0;
+  if ((sign*x) >= MagickEpsilon)
+    return(1.0/x);
+  return(sign/MagickEpsilon);
 }
 
 #if defined(__cplusplus) || defined(c_plusplus)