MagickCore  7.1.0
Convert, Edit, Or Compose Bitmap Images
color-private.h
1 /*
2  Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization
3  dedicated to making software imaging solutions freely available.
4 
5  You may not use this file except in compliance with the License. You may
6  obtain a copy of the License at
7 
8  https://imagemagick.org/script/license.php
9 
10  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 private image color methods.
17 */
18 #ifndef MAGICKCORE_COLOR_PRIVATE_H
19 #define MAGICKCORE_COLOR_PRIVATE_H
20 
21 #include "MagickCore/image.h"
22 #include "MagickCore/image-private.h"
23 
24 #if defined(__cplusplus) || defined(c_plusplus)
25 extern "C" {
26 #endif
27 
28 extern MagickPrivate MagickBooleanType
29  ColorComponentGenesis(void),
30  IsEquivalentAlpha(const Image *,const PixelInfo *,const PixelInfo *),
31  IsEquivalentIntensity(const Image *,const PixelInfo *,const PixelInfo *);
32 
33 extern MagickPrivate void
34  ColorComponentTerminus(void);
35 
36 static inline MagickBooleanType GetColorRange(const char *color,
37  PixelInfo *start,PixelInfo *stop,ExceptionInfo *exception)
38 {
39  char
40  start_color[MagickPathExtent] = "white",
41  stop_color[MagickPathExtent] = "black";
42 
43  MagickBooleanType
44  status;
45 
46  if (color == (const char *) NULL)
47  return(MagickFalse);
48  if (*color != '\0')
49  {
50  char
51  *p;
52 
53  (void) CopyMagickString(start_color,color,MagickPathExtent);
54  for (p=start_color; (*p != '-') && (*p != '\0'); p++)
55  if (*p == '(')
56  {
57  for (p++; (*p != ')') && (*p != '\0'); p++);
58  if (*p == '\0')
59  break;
60  }
61  if (*p == '-')
62  (void) CopyMagickString(stop_color,p+1,MagickPathExtent);
63  *p='\0';
64  }
65  status=QueryColorCompliance(start_color,AllCompliance,start,exception);
66  if (status == MagickFalse)
67  return(status);
68  return(QueryColorCompliance(stop_color,AllCompliance,stop,exception));
69 }
70 
71 static inline double GetFuzzyColorDistance(const Image *p,const Image *q)
72 {
73  double
74  fuzz;
75 
76  fuzz=(double) MagickMax(MagickMax(p->fuzz,q->fuzz),(MagickRealType)
77  MagickSQ1_2);
78  return(fuzz*fuzz);
79 }
80 
81 #if defined(__cplusplus) || defined(c_plusplus)
82 }
83 #endif
84 
85 #endif
Definition: image.h:152