blob: e71e63acde7c094abb35804d34692a4c6431b25e [file] [log] [blame]
cristy380a11c2012-06-02 15:15:22 +00001/*
cristyfe676ee2013-11-18 13:03:38 +00002 Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization
cristy380a11c2012-06-02 15:15:22 +00003 dedicated to making software imaging solutions freely available.
cristy39feb2b2012-06-08 22:37:10 +00004
cristy380a11c2012-06-02 15:15:22 +00005 You may not use this file except in compliance with the License.
6 obtain a copy of the License at
cristy39feb2b2012-06-08 22:37:10 +00007
cristy380a11c2012-06-02 15:15:22 +00008 http://www.imagemagick.org/script/license.php
cristy39feb2b2012-06-08 22:37:10 +00009
cristy380a11c2012-06-02 15:15:22 +000010 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 MagickCore image pixel private methods.
17*/
18#ifndef _MAGICKCORE_PIXEL_PRIVATE_H
19#define _MAGICKCORE_PIXEL_PRIVATE_H
20
21#if defined(__cplusplus) || defined(c_plusplus)
22extern "C" {
23#endif
24
cristy3e3ec3a2012-11-03 23:11:06 +000025static inline double PerceptibleReciprocal(const double x)
cristy380a11c2012-06-02 15:15:22 +000026{
cristydfa38172012-10-14 22:17:01 +000027 double
28 sign;
29
cristy3e3ec3a2012-11-03 23:11:06 +000030 /*
31 Return 1/x where x is perceptible (not unlimited or infinitesimal).
32 */
cristyfdf6aed2012-10-14 22:22:17 +000033 sign=x < 0.0 ? -1.0 : 1.0;
cristydfa38172012-10-14 22:17:01 +000034 if ((sign*x) >= MagickEpsilon)
35 return(1.0/x);
cristyfdf6aed2012-10-14 22:22:17 +000036 return(sign/MagickEpsilon);
cristy380a11c2012-06-02 15:15:22 +000037}
38
39#if defined(__cplusplus) || defined(c_plusplus)
40}
41#endif
42
43#endif