MagickCore
7.1.2-32
Convert, Edit, Or Compose Bitmap Images
Toggle main menu visibility
Loading...
Searching...
No Matches
image-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/license/
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 image private methods.
17
*/
18
#ifndef MAGICKCORE_IMAGE_PRIVATE_H
19
#define MAGICKCORE_IMAGE_PRIVATE_H
20
21
#include <limits.h>
22
#include "MagickCore/pixel-accessor.h"
23
#include "MagickCore/quantum-private.h"
24
25
#if defined(__cplusplus) || defined(c_plusplus)
26
extern
"C"
{
27
#endif
28
29
#define BackgroundColor "#ffffff"
/* white */
30
#define BackgroundColorRGBA QuantumRange,QuantumRange,QuantumRange,OpaqueAlpha
31
#define BorderColor "#dfdfdf"
/* gray */
32
#define BorderColorRGBA ScaleShortToQuantum(0xdfdf),\
33
ScaleShortToQuantum(0xdfdf),ScaleShortToQuantum(0xdfdf),OpaqueAlpha
34
#define DefaultResolution 72.0
35
#define DefaultTileFrame "15x15+3+3"
36
#define DefaultTileGeometry "120x120+4+3>"
37
#define DefaultTileLabel "%f\n%G\n%b"
38
#define ForegroundColor "#000"
/* black */
39
#define ForegroundColorRGBA 0,0,0,OpaqueAlpha
40
#define LoadImagesTag "Load/Images"
41
#define LoadImageTag "Load/Image"
42
#define Magick2PI 6.28318530717958647692528676655900576839433879875020
43
#define MagickAbsoluteValue(x) ((x) < 0 ? -(x) : (x))
44
#define MagickPHI 1.61803398874989484820458683436563811772030917980576
45
#define MagickPI2 1.57079632679489661923132169163975144209858469968755
46
#define MagickPI 3.1415926535897932384626433832795028841971693993751058209749445923078164062
47
#define MagickSQ1_2 0.70710678118654752440084436210484903928483593768847
48
#define MagickSQ2 1.41421356237309504880168872420969807856967187537695
49
#define MagickSQ2PI 2.50662827463100024161235523934010416269302368164062
50
#define MAGICK_UCHAR_MAX (UCHAR_MAX)
51
#define MAGICK_UINT_MAX (UINT_MAX)
52
#define MAGICK_ULONG_MAX (ULONG_MAX)
53
#define MAGICK_USHORT_MAX (USHRT_MAX)
54
#define MatteColor "#bdbdbd"
/* gray */
55
#define MatteColorRGBA ScaleShortToQuantum(0xbdbd),\
56
ScaleShortToQuantum(0xbdbd),ScaleShortToQuantum(0xbdbd),OpaqueAlpha
57
#define PSDensityGeometry "72.0x72.0"
58
#define PSPageGeometry "612x792"
59
#define SaveImagesTag "Save/Images"
60
#define SaveImageTag "Save/Image"
61
#define TransparentColor "#00000000"
/* transparent black */
62
#define TransparentColorRGBA (Quantum) 0,(Quantum) 0,(Quantum) 0,TransparentAlpha
63
#define UndefinedCompressionQuality 0UL
64
#define UndefinedTicksPerSecond 100L
65
66
static
inline
int
CastDoubleToInt(
const
double
x)
67
{
68
double
69
value;
70
71
if
(IsNaN(x) != 0)
72
{
73
errno=ERANGE;
74
return
(0);
75
}
76
value=(x < 0.0) ? ceil(x) : floor(x);
77
if
(value < 0.0)
78
{
79
errno=ERANGE;
80
return
(0);
81
}
82
if
(value >= ((
double
) MAGICK_INT_MAX))
83
{
84
errno=ERANGE;
85
return
(MAGICK_INT_MAX);
86
}
87
return
((
int
) value);
88
}
89
90
static
inline
ptrdiff_t CastDoubleToPtrdiffT(
const
double
x)
91
{
92
double
93
value;
94
95
if
(IsNaN(x) != 0)
96
{
97
errno=ERANGE;
98
return
(0);
99
}
100
value=(x < 0.0) ? ceil(x) : floor(x);
101
if
(value < ((
double
) MAGICK_PTRDIFF_MIN))
102
{
103
errno=ERANGE;
104
return
(MAGICK_PTRDIFF_MIN);
105
}
106
if
(value >= ((
double
) MAGICK_PTRDIFF_MAX))
107
{
108
errno=ERANGE;
109
return
(MAGICK_PTRDIFF_MAX);
110
}
111
return
((ptrdiff_t) value);
112
}
113
114
static
inline
size_t
CastDoubleToSizeT(
const
double
x)
115
{
116
double
117
value;
118
119
if
(IsNaN(x) != 0)
120
{
121
errno=ERANGE;
122
return
(0);
123
}
124
value=(x < 0.0) ? ceil(x) : floor(x);
125
if
(value < 0.0)
126
{
127
errno=ERANGE;
128
return
(0);
129
}
130
if
(value >= ((
double
) MAGICK_SIZE_MAX))
131
{
132
errno=ERANGE;
133
return
(MAGICK_SIZE_MAX);
134
}
135
return
((
size_t
) value);
136
}
137
138
static
inline
ssize_t CastDoubleToSsizeT(
const
double
x)
139
{
140
double
141
value;
142
143
if
(IsNaN(x) != 0)
144
{
145
errno=ERANGE;
146
return
(0);
147
}
148
value=(x < 0.0) ? ceil(x) : floor(x);
149
if
(value < ((
double
) MAGICK_SSIZE_MIN))
150
{
151
errno=ERANGE;
152
return
((ssize_t) MAGICK_SSIZE_MIN);
153
}
154
if
(value >= ((
double
) MAGICK_SSIZE_MAX))
155
{
156
errno=ERANGE;
157
return
((ssize_t) MAGICK_SSIZE_MAX);
158
}
159
return
((ssize_t) value);
160
}
161
162
static
inline
unsigned
char
CastDoubleToUChar(
const
double
x)
163
{
164
double
165
value;
166
167
if
(IsNaN(x) != 0)
168
{
169
errno=ERANGE;
170
return
(0);
171
}
172
value=(x < 0.0) ? ceil(x) : floor(x);
173
if
(value < 0.0)
174
{
175
errno=ERANGE;
176
return
(0);
177
}
178
if
(value >= ((
double
) MAGICK_UCHAR_MAX))
179
{
180
errno=ERANGE;
181
return
(MAGICK_UCHAR_MAX);
182
}
183
return
((
unsigned
char
) value);
184
}
185
186
static
inline
unsigned
int
CastDoubleToUInt(
const
double
x)
187
{
188
double
189
value;
190
191
if
(IsNaN(x) != 0)
192
{
193
errno=ERANGE;
194
return
(0);
195
}
196
value=(x < 0.0) ? ceil(x) : floor(x);
197
if
(value < 0.0)
198
{
199
errno=ERANGE;
200
return
(0);
201
}
202
if
(value >= ((
double
) MAGICK_UINT_MAX))
203
{
204
errno=ERANGE;
205
return
(MAGICK_UINT_MAX);
206
}
207
return
((
unsigned
int
) value);
208
}
209
210
static
inline
unsigned
short
CastDoubleToUShort(
const
double
x)
211
{
212
double
213
value;
214
215
if
(IsNaN(x) != 0)
216
{
217
errno=ERANGE;
218
return
(0);
219
}
220
value=(x < 0.0) ? ceil(x) : floor(x);
221
if
(value < 0.0)
222
{
223
errno=ERANGE;
224
return
(0);
225
}
226
if
(value >= ((
double
) MAGICK_USHORT_MAX))
227
{
228
errno=ERANGE;
229
return
(MAGICK_USHORT_MAX);
230
}
231
return
((
unsigned
short
) value);
232
}
233
234
static
inline
double
DegreesToRadians(
const
double
degrees)
235
{
236
return
((
double
) (MagickPI*degrees/180.0));
237
}
238
239
static
inline
double
RadiansToDegrees(
const
double
radians)
240
{
241
return
((
double
) (180.0*radians/MagickPI));
242
}
243
244
static
inline
unsigned
char
ScaleColor5to8(
const
unsigned
int
color)
245
{
246
return
((
unsigned
char
) (((color) << 3) | ((color) >> 2)));
247
}
248
249
static
inline
unsigned
char
ScaleColor6to8(
const
unsigned
int
color)
250
{
251
return
((
unsigned
char
) (((color) << 2) | ((color) >> 4)));
252
}
253
254
static
inline
unsigned
int
ScaleColor8to5(
const
unsigned
char
color)
255
{
256
return
((
unsigned
int
) (((color) & ~0x07) >> 3));
257
}
258
259
static
inline
unsigned
int
ScaleColor8to6(
const
unsigned
char
color)
260
{
261
return
((
unsigned
int
) (((color) & ~0x03) >> 2));
262
}
263
264
#if defined(__cplusplus) || defined(c_plusplus)
265
}
266
#endif
267
268
#endif
MagickCore
image-private.h
Generated by
1.17.0