MagickCore  7.0.10
color-private.h
Go to the documentation of this file.
1 /*
2  Copyright 1999-2020 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"
23 
24 #if defined(__cplusplus) || defined(c_plusplus)
25 extern "C" {
26 #endif
27 
30  IsEquivalentAlpha(const Image *,const PixelInfo *,const PixelInfo *),
31  IsEquivalentIntensity(const Image *,const PixelInfo *,const PixelInfo *);
32 
33 extern MagickPrivate 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 
44  status;
45 
46  if (*color != '\0')
47  {
48  register char
49  *p;
50 
51  (void) CopyMagickString(start_color,color,MagickPathExtent);
52  for (p=start_color; (*p != '-') && (*p != '\0'); p++)
53  if (*p == '(')
54  {
55  for (p++; (*p != ')') && (*p != '\0'); p++);
56  if (*p == '\0')
57  break;
58  }
59  if (*p == '-')
60  (void) CopyMagickString(stop_color,p+1,MagickPathExtent);
61  *p='\0';
62  }
63  status=QueryColorCompliance(start_color,AllCompliance,start,exception);
64  if (status == MagickFalse)
65  return(status);
66  return(QueryColorCompliance(stop_color,AllCompliance,stop,exception));
67 }
68 
69 static inline double GetFuzzyColorDistance(const Image *p,const Image *q)
70 {
71  double
72  fuzz;
73 
74  fuzz=(double) MagickMax(MagickMax(p->fuzz,q->fuzz),(MagickRealType)
75  MagickSQ1_2);
76  return(fuzz*fuzz);
77 }
78 
79 #if defined(__cplusplus) || defined(c_plusplus)
80 }
81 #endif
82 
83 #endif
MagickDoubleType MagickRealType
Definition: magick-type.h:124
#define MagickSQ1_2
Definition: image-private.h:41
MagickPrivate MagickBooleanType ColorComponentGenesis(void)
MagickPrivate MagickBooleanType IsEquivalentAlpha(const Image *, const PixelInfo *, const PixelInfo *)
MagickExport size_t CopyMagickString(char *magick_restrict destination, const char *magick_restrict source, const size_t length)
Definition: string.c:756
static double GetFuzzyColorDistance(const Image *p, const Image *q)
Definition: color-private.h:69
Definition: image.h:151
MagickBooleanType
Definition: magick-type.h:169
MagickPrivate void ColorComponentTerminus(void)
Definition: color.c:968
#define MagickPathExtent
MagickPrivate MagickBooleanType IsEquivalentIntensity(const Image *, const PixelInfo *, const PixelInfo *)
Definition: color.c:1823
static MagickBooleanType GetColorRange(const char *color, PixelInfo *start, PixelInfo *stop, ExceptionInfo *exception)
Definition: color-private.h:36
MagickExport MagickBooleanType QueryColorCompliance(const char *name, const ComplianceType compliance, PixelInfo *color, ExceptionInfo *exception)
Definition: color.c:2180
#define MagickMax(x, y)
Definition: image-private.h:36
#define MagickPrivate
double fuzz
Definition: image.h:216