MagickCore 6.9.13
Loading...
Searching...
No Matches
draw-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 drawing methods.
17*/
18#ifndef MAGICKCORE_DRAW_PRIVATE_H
19#define MAGICKCORE_DRAW_PRIVATE_H
20
21#include "magick/cache.h"
22#include "magick/image.h"
23#include "magick/memory_.h"
24
25#if defined(__cplusplus) || defined(c_plusplus)
26extern "C" {
27#endif
28
29static inline MagickBooleanType GetFillColor(const DrawInfo *draw_info,
30 const ssize_t x,const ssize_t y,PixelPacket *fill)
31{
32 Image
33 *pattern;
34
35 MagickBooleanType
36 status;
37
38 pattern=draw_info->fill_pattern;
39 if (pattern == (Image *) NULL)
40 {
41 *fill=draw_info->fill;
42 return(MagickTrue);
43 }
44 status=GetOneVirtualMethodPixel(pattern,TileVirtualPixelMethod,
45 x+pattern->tile_offset.x,y+pattern->tile_offset.y,fill,&pattern->exception);
46 if (pattern->matte == MagickFalse)
47 fill->opacity=OpaqueOpacity;
48 if (fabs(draw_info->fill_opacity-(double) TransparentOpacity) >= MagickEpsilon)
49 fill->opacity=(Quantum) ((double) QuantumRange-((double) QuantumRange-
50 (double) fill->opacity)*QuantumScale*((double) QuantumRange-(double)
51 draw_info->fill_opacity));
52 return(status);
53}
54
55static inline MagickBooleanType GetStrokeColor(const DrawInfo *draw_info,
56 const ssize_t x,const ssize_t y,PixelPacket *stroke)
57{
58 Image
59 *pattern;
60
61 MagickBooleanType
62 status;
63
64 pattern=draw_info->stroke_pattern;
65 if (pattern == (Image *) NULL)
66 {
67 *stroke=draw_info->stroke;
68 return(MagickTrue);
69 }
70 status=GetOneVirtualMethodPixel(pattern,TileVirtualPixelMethod,
71 x+pattern->tile_offset.x,y+pattern->tile_offset.y,stroke,
72 &pattern->exception);
73 if (pattern->matte == MagickFalse)
74 stroke->opacity=OpaqueOpacity;
75 if (fabs(draw_info->stroke_opacity-(double) TransparentOpacity) >= MagickEpsilon)
76 stroke->opacity=(Quantum) ((double) QuantumRange-((double) QuantumRange-
77 (double) stroke->opacity)*QuantumScale*((double) QuantumRange-(double)
78 draw_info->stroke_opacity));
79 return(status);
80}
81
82#if defined(__cplusplus) || defined(c_plusplus)
83}
84#endif
85
86#endif