| 1 |
/* |
| 2 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 |
% % |
| 4 |
% % |
| 5 |
% PPPP EEEEE RRRR L % |
| 6 |
% P P E R R L % |
| 7 |
% PPPP EEE RRRR L % |
| 8 |
% P E R R L % |
| 9 |
% P EEEEE R R LLLLL % |
| 10 |
% % |
| 11 |
% M M AAA GGGG IIIII CCCC K K % |
| 12 |
% MM MM A A G I C K K % |
| 13 |
% M M M AAAAA G GGG I C KKK % |
| 14 |
% M M A A G G I C K K % |
| 15 |
% M M A A GGGG IIIII CCCC K K % |
| 16 |
% % |
| 17 |
% % |
| 18 |
% Object-oriented Perl interface to ImageMagick % |
| 19 |
% % |
| 20 |
% Software Design % |
| 21 |
% Kyle Shorter % |
| 22 |
% Cristy % |
| 23 |
% February 1997 % |
| 24 |
% % |
| 25 |
% % |
| 26 |
% Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization % |
| 27 |
% dedicated to making software imaging solutions freely available. % |
| 28 |
% % |
| 29 |
% You may not use this file except in compliance with the License. You may % |
| 30 |
% obtain a copy of the License at % |
| 31 |
% % |
| 32 |
% https://imagemagick.org/license/ % |
| 33 |
% % |
| 34 |
% Unless required by applicable law or agreed to in writing, software % |
| 35 |
% distributed under the License is distributed on an "AS IS" BASIS, % |
| 36 |
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 37 |
% See the License for the specific language governing permissions and % |
| 38 |
% limitations under the License. % |
| 39 |
% % |
| 40 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 41 |
% |
| 42 |
% PerlMagick is an objected-oriented Perl interface to ImageMagick. Use |
| 43 |
% the module to read, manipulate, or write an image or image sequence from |
| 44 |
% within a Perl script. This makes PerlMagick suitable for Web CGI scripts. |
| 45 |
% |
| 46 |
*/ |
| 47 |
|
| 48 |
/* |
| 49 |
Include declarations. |
| 50 |
*/ |
| 51 |
#if defined(__cplusplus) || defined(c_plusplus) |
| 52 |
extern "C" { |
| 53 |
#endif |
| 54 |
|
| 55 |
#define PERL_NO_GET_CONTEXT |
| 56 |
#include "EXTERN.h" |
| 57 |
#include "perl.h" |
| 58 |
#include "XSUB.h" |
| 59 |
#include <math.h> |
| 60 |
#include <MagickCore/MagickCore.h> |
| 61 |
#undef tainted |
| 62 |
|
| 63 |
#if defined(__cplusplus) || defined(c_plusplus) |
| 64 |
} |
| 65 |
#endif |
| 66 |
|
| 67 |
/* |
| 68 |
Define declarations. |
| 69 |
*/ |
| 70 |
#ifndef aTHX_ |
| 71 |
#define aTHX_ |
| 72 |
#define pTHX_ |
| 73 |
#define dTHX |
| 74 |
#endif |
| 75 |
#define DegreesToRadians(x) (MagickPI*(x)/180.0) |
| 76 |
#define EndOf(array) (&array[NumberOf(array)]) |
| 77 |
#define MagickPI 3.14159265358979323846264338327950288419716939937510 |
| 78 |
#define MaxArguments 35 |
| 79 |
#ifndef na |
| 80 |
#define na PL_na |
| 81 |
#endif |
| 82 |
#define NumberOf(array) (sizeof(array)/sizeof(*array)) |
| 83 |
#define PackageName "Image::Magick::Q16HDRI" |
| 84 |
#if PERL_VERSION <= 6 |
| 85 |
#define PerlIO FILE |
| 86 |
#define PerlIO_importFILE(f, fl) (f) |
| 87 |
#define PerlIO_findFILE(f) NULL |
| 88 |
#endif |
| 89 |
#ifndef sv_undef |
| 90 |
#define sv_undef PL_sv_undef |
| 91 |
#endif |
| 92 |
|
| 93 |
#define AddImageToRegistry(sv,image) \ |
| 94 |
{ \ |
| 95 |
if (magick_registry != (SplayTreeInfo *) NULL) \ |
| 96 |
{ \ |
| 97 |
(void) AddValueToSplayTree(magick_registry,image,image); \ |
| 98 |
(sv)=newSViv(PTR2IV(image)); \ |
| 99 |
} \ |
| 100 |
} |
| 101 |
|
| 102 |
#define DeleteImageFromRegistry(reference,image) \ |
| 103 |
{ \ |
| 104 |
if (magick_registry != (SplayTreeInfo *) NULL) \ |
| 105 |
{ \ |
| 106 |
if (GetImageReferenceCount(image) == 1) \ |
| 107 |
(void) DeleteNodeByValueFromSplayTree(magick_registry,image); \ |
| 108 |
image=DestroyImage(image); \ |
| 109 |
sv_setiv(reference,0); \ |
| 110 |
} \ |
| 111 |
} |
| 112 |
|
| 113 |
#define InheritPerlException(exception,perl_exception) \ |
| 114 |
{ \ |
| 115 |
char \ |
| 116 |
message[MagickPathExtent]; \ |
| 117 |
\ |
| 118 |
if ((exception)->severity != UndefinedException) \ |
| 119 |
{ \ |
| 120 |
(void) FormatLocaleString(message,MagickPathExtent,"Exception %d: %s%s%s%s",\ |
| 121 |
(exception)->severity, (exception)->reason ? \ |
| 122 |
GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \ |
| 123 |
"Unknown", (exception)->description ? " (" : "", \ |
| 124 |
(exception)->description ? GetLocaleExceptionMessage( \ |
| 125 |
(exception)->severity,(exception)->description) : "", \ |
| 126 |
(exception)->description ? ")" : ""); \ |
| 127 |
if ((perl_exception) != (SV *) NULL) \ |
| 128 |
{ \ |
| 129 |
if (SvCUR(perl_exception)) \ |
| 130 |
sv_catpv(perl_exception,"\n"); \ |
| 131 |
sv_catpv(perl_exception,message); \ |
| 132 |
} \ |
| 133 |
} \ |
| 134 |
} |
| 135 |
|
| 136 |
#define ThrowPerlException(exception,severity,tag,reason) \ |
| 137 |
(void) ThrowMagickException(exception,GetMagickModule(),severity, \ |
| 138 |
tag,"`%s'",reason); \ |
| 139 |
|
| 140 |
/* |
| 141 |
Typedef and structure declarations. |
| 142 |
*/ |
| 143 |
typedef enum |
| 144 |
{ |
| 145 |
NullReference = 0, |
| 146 |
ArrayReference = (~0), |
| 147 |
RealReference = (~0)-1, |
| 148 |
FileReference = (~0)-2, |
| 149 |
ImageReference = (~0)-3, |
| 150 |
IntegerReference = (~0)-4, |
| 151 |
StringReference = (~0)-5 |
| 152 |
} MagickReference; |
| 153 |
|
| 154 |
typedef struct _Arguments |
| 155 |
{ |
| 156 |
const char |
| 157 |
*method; |
| 158 |
|
| 159 |
ssize_t |
| 160 |
type; |
| 161 |
} Arguments; |
| 162 |
|
| 163 |
struct ArgumentList |
| 164 |
{ |
| 165 |
ssize_t |
| 166 |
integer_reference; |
| 167 |
|
| 168 |
double |
| 169 |
real_reference; |
| 170 |
|
| 171 |
const char |
| 172 |
*string_reference; |
| 173 |
|
| 174 |
Image |
| 175 |
*image_reference; |
| 176 |
|
| 177 |
SV |
| 178 |
*array_reference; |
| 179 |
|
| 180 |
FILE |
| 181 |
*file_reference; |
| 182 |
|
| 183 |
size_t |
| 184 |
length; |
| 185 |
}; |
| 186 |
|
| 187 |
struct PackageInfo |
| 188 |
{ |
| 189 |
ImageInfo |
| 190 |
*image_info; |
| 191 |
}; |
| 192 |
|
| 193 |
typedef void |
| 194 |
*Image__Magick__Q16HDRI; /* data type for the Image::Magick::@MAGICK_ABI_NAME@ package */ |
| 195 |
|
| 196 |
/* |
| 197 |
Static declarations. |
| 198 |
*/ |
| 199 |
static struct |
| 200 |
Methods |
| 201 |
{ |
| 202 |
const char |
| 203 |
*name; |
| 204 |
|
| 205 |
Arguments |
| 206 |
arguments[MaxArguments]; |
| 207 |
} Methods[] = |
| 208 |
{ |
| 209 |
{ "Comment", { {"comment", StringReference} } }, |
| 210 |
{ "Label", { {"label", StringReference} } }, |
| 211 |
{ "AddNoise", { {"noise", MagickNoiseOptions}, {"attenuate", RealReference}, |
| 212 |
{"channel", MagickChannelOptions} } }, |
| 213 |
{ "Colorize", { {"fill", StringReference}, {"blend", StringReference} } }, |
| 214 |
{ "Border", { {"geometry", StringReference}, {"width", IntegerReference}, |
| 215 |
{"height", IntegerReference}, {"fill", StringReference}, |
| 216 |
{"bordercolor", StringReference}, {"color", StringReference}, |
| 217 |
{"compose", MagickComposeOptions} } }, |
| 218 |
{ "Blur", { {"geometry", StringReference}, {"radius", RealReference}, |
| 219 |
{"sigma", RealReference}, {"channel", MagickChannelOptions} } }, |
| 220 |
{ "Chop", { {"geometry", StringReference}, {"width", IntegerReference}, |
| 221 |
{"height", IntegerReference}, {"x", IntegerReference}, |
| 222 |
{"y", IntegerReference}, {"gravity", MagickGravityOptions} } }, |
| 223 |
{ "Crop", { {"geometry", StringReference}, {"width", IntegerReference}, |
| 224 |
{"height", IntegerReference}, {"x", IntegerReference}, |
| 225 |
{"y", IntegerReference}, {"fuzz", StringReference}, |
| 226 |
{"gravity", MagickGravityOptions} } }, |
| 227 |
{ "Despeckle", { { (const char *) NULL, NullReference } } }, |
| 228 |
{ "Edge", { {"radius", RealReference} } }, |
| 229 |
{ "Emboss", { {"geometry", StringReference}, {"radius", RealReference}, |
| 230 |
{"sigma", RealReference} } }, |
| 231 |
{ "Enhance", { { (const char *) NULL, NullReference } } }, |
| 232 |
{ "Flip", { { (const char *) NULL, NullReference } } }, |
| 233 |
{ "Flop", { { (const char *) NULL, NullReference } } }, |
| 234 |
{ "Frame", { {"geometry", StringReference}, {"width", IntegerReference}, |
| 235 |
{"height", IntegerReference}, {"inner", IntegerReference}, |
| 236 |
{"outer", IntegerReference}, {"fill", StringReference}, |
| 237 |
{"color", StringReference}, {"compose", MagickComposeOptions} } }, |
| 238 |
{ "Implode", { {"amount", RealReference}, |
| 239 |
{"interpolate", MagickInterpolateOptions} } }, |
| 240 |
{ "Magnify", { { (const char *) NULL, NullReference } } }, |
| 241 |
{ "MedianFilter", { {"geometry", StringReference}, |
| 242 |
{"width", IntegerReference}, {"height", IntegerReference}, |
| 243 |
{"channel", MagickChannelOptions} } }, |
| 244 |
{ "Minify", { { (const char *) NULL, NullReference } } }, |
| 245 |
{ "OilPaint", { {"radius", RealReference}, {"sigma", RealReference} } }, |
| 246 |
{ "ReduceNoise", { {"geometry", StringReference}, |
| 247 |
{"width", IntegerReference},{"height", IntegerReference}, |
| 248 |
{"channel", MagickChannelOptions} } }, |
| 249 |
{ "Roll", { {"geometry", StringReference}, {"x", IntegerReference}, |
| 250 |
{"y", IntegerReference} } }, |
| 251 |
{ "Rotate", { {"degrees", RealReference}, |
| 252 |
{"background", StringReference} } }, |
| 253 |
{ "Sample", { {"geometry", StringReference}, {"width", IntegerReference}, |
| 254 |
{"height", IntegerReference} } }, |
| 255 |
{ "Scale", { {"geometry", StringReference}, {"width", IntegerReference}, |
| 256 |
{"height", IntegerReference} } }, |
| 257 |
{ "Shade", { {"geometry", StringReference}, {"azimuth", RealReference}, |
| 258 |
{"elevation", RealReference}, {"gray", MagickBooleanOptions} } }, |
| 259 |
{ "Sharpen", { {"geometry", StringReference}, {"radius", RealReference}, |
| 260 |
{"sigma", RealReference}, {"channel", MagickChannelOptions} } }, |
| 261 |
{ "Shear", { {"geometry", StringReference}, {"x", RealReference}, |
| 262 |
{"y", RealReference}, { "fill", StringReference}, |
| 263 |
{"color", StringReference} } }, |
| 264 |
{ "Spread", { {"radius", RealReference}, |
| 265 |
{"interpolate", MagickInterpolateOptions} } }, |
| 266 |
{ "Swirl", { {"degrees", RealReference}, |
| 267 |
{"interpolate", MagickInterpolateOptions} } }, |
| 268 |
{ "Resize", { {"geometry", StringReference}, {"width", IntegerReference}, |
| 269 |
{"height", IntegerReference}, {"filter", MagickFilterOptions}, |
| 270 |
{"support", StringReference } } }, |
| 271 |
{ "Zoom", { {"geometry", StringReference}, {"width", IntegerReference}, |
| 272 |
{"height", IntegerReference}, {"filter", MagickFilterOptions}, |
| 273 |
{"support", RealReference } } }, |
| 274 |
{ "Annotate", { {"text", StringReference}, {"font", StringReference}, |
| 275 |
{"pointsize", RealReference}, {"density", StringReference}, |
| 276 |
{"undercolor", StringReference}, {"stroke", StringReference}, |
| 277 |
{"fill", StringReference}, {"geometry", StringReference}, |
| 278 |
{"sans", StringReference}, {"x", RealReference}, |
| 279 |
{"y", RealReference}, {"gravity", MagickGravityOptions}, |
| 280 |
{"translate", StringReference}, {"scale", StringReference}, |
| 281 |
{"rotate", RealReference}, {"skewX", RealReference}, |
| 282 |
{"skewY", RealReference}, {"strokewidth", RealReference}, |
| 283 |
{"antialias", MagickBooleanOptions}, {"family", StringReference}, |
| 284 |
{"style", MagickStyleOptions}, {"stretch", MagickStretchOptions}, |
| 285 |
{"weight", IntegerReference}, {"align", MagickAlignOptions}, |
| 286 |
{"encoding", StringReference}, {"affine", ArrayReference}, |
| 287 |
{"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference}, |
| 288 |
{"tile", ImageReference}, {"kerning", RealReference}, |
| 289 |
{"interline-spacing", RealReference}, |
| 290 |
{"interword-spacing", RealReference}, |
| 291 |
{"direction", MagickDirectionOptions}, |
| 292 |
{"decorate", MagickDecorateOptions}, |
| 293 |
{"word-break", MagickWordBreakOptions} } }, |
| 294 |
{ "ColorFloodfill", { {"geometry", StringReference}, |
| 295 |
{"x", IntegerReference}, {"y", IntegerReference}, |
| 296 |
{"fill", StringReference}, {"bordercolor", StringReference}, |
| 297 |
{"fuzz", StringReference}, {"invert", MagickBooleanOptions} } }, |
| 298 |
{ "Composite", { {"image", ImageReference}, |
| 299 |
{"compose", MagickComposeOptions}, {"geometry", StringReference}, |
| 300 |
{"x", IntegerReference}, {"y", IntegerReference}, |
| 301 |
{"gravity", MagickGravityOptions}, {"opacity", StringReference}, |
| 302 |
{"tile", MagickBooleanOptions}, {"rotate", RealReference}, |
| 303 |
{"color", StringReference}, {"mask", ImageReference}, |
| 304 |
{"channel", MagickChannelOptions}, |
| 305 |
{"interpolate", MagickInterpolateOptions}, {"args", StringReference}, |
| 306 |
{"blend", StringReference}, {"clip-to-self", MagickBooleanOptions} } }, |
| 307 |
{ "Contrast", { {"sharpen", MagickBooleanOptions} } }, |
| 308 |
{ "CycleColormap", { {"display", IntegerReference} } }, |
| 309 |
{ "Draw", { {"primitive", MagickPrimitiveOptions}, |
| 310 |
{"points", StringReference}, {"method", MagickMethodOptions}, |
| 311 |
{"stroke", StringReference}, {"fill", StringReference}, |
| 312 |
{"strokewidth", RealReference}, {"font", StringReference}, |
| 313 |
{"bordercolor", StringReference}, {"x", RealReference}, |
| 314 |
{"y", RealReference}, {"translate", StringReference}, |
| 315 |
{"scale", StringReference}, {"rotate", RealReference}, |
| 316 |
{"skewX", RealReference}, {"skewY", RealReference}, |
| 317 |
{"tile", ImageReference}, {"pointsize", RealReference}, |
| 318 |
{"antialias", MagickBooleanOptions}, {"density", StringReference}, |
| 319 |
{"linewidth", RealReference}, {"affine", ArrayReference}, |
| 320 |
{"stroke-dashoffset", RealReference}, |
| 321 |
{"stroke-dasharray", ArrayReference}, |
| 322 |
{"interpolate", MagickInterpolateOptions}, |
| 323 |
{"origin", StringReference}, {"text", StringReference}, |
| 324 |
{"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference}, |
| 325 |
{"vector-graphics", StringReference}, {"kerning", RealReference}, |
| 326 |
{"interline-spacing", RealReference}, |
| 327 |
{"interword-spacing", RealReference}, |
| 328 |
{"direction", MagickDirectionOptions}, |
| 329 |
{"word-break", MagickWordBreakOptions} } }, |
| 330 |
{ "Equalize", { {"channel", MagickChannelOptions} } }, |
| 331 |
{ "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions}, |
| 332 |
{"red", RealReference}, {"green", RealReference}, |
| 333 |
{"blue", RealReference} } }, |
| 334 |
{ "Map", { {"image", ImageReference}, |
| 335 |
{"dither-method", MagickDitherOptions} } }, |
| 336 |
{ "MatteFloodfill", { {"geometry", StringReference}, |
| 337 |
{"x", IntegerReference}, {"y", IntegerReference}, |
| 338 |
{"opacity", StringReference}, {"bordercolor", StringReference}, |
| 339 |
{"fuzz", StringReference}, {"invert", MagickBooleanOptions} } }, |
| 340 |
{ "Modulate", { {"factor", StringReference}, {"hue", RealReference}, |
| 341 |
{"saturation", RealReference}, {"whiteness", RealReference}, |
| 342 |
{"brightness", RealReference}, {"lightness", RealReference}, |
| 343 |
{"blackness", RealReference} } }, |
| 344 |
{ "Negate", { {"gray", MagickBooleanOptions}, |
| 345 |
{"channel", MagickChannelOptions} } }, |
| 346 |
{ "Normalize", { {"channel", MagickChannelOptions} } }, |
| 347 |
{ "NumberColors", { { (const char *) NULL, NullReference } } }, |
| 348 |
{ "Opaque", { {"color", StringReference}, {"fill", StringReference}, |
| 349 |
{"fuzz", StringReference}, {"channel", MagickChannelOptions}, |
| 350 |
{"invert", MagickBooleanOptions} } }, |
| 351 |
{ "Quantize", { {"colors", IntegerReference}, |
| 352 |
{"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions}, |
| 353 |
{"dither", MagickDitherOptions}, {"measure", MagickBooleanOptions}, |
| 354 |
{"global", MagickBooleanOptions}, {"transparent-color", StringReference}, |
| 355 |
{"dither-method", MagickDitherOptions} } }, |
| 356 |
{ "Raise", { {"geometry", StringReference}, {"width", IntegerReference}, |
| 357 |
{"height", IntegerReference}, {"raise", MagickBooleanOptions} } }, |
| 358 |
{ "Segment", { {"geometry", StringReference}, |
| 359 |
{"cluster-threshold", RealReference}, |
| 360 |
{"smoothing-threshold", RealReference}, |
| 361 |
{"colorspace", MagickColorspaceOptions}, |
| 362 |
{"verbose", MagickBooleanOptions} } }, |
| 363 |
{ "Signature", { { (const char *) NULL, NullReference } } }, |
| 364 |
{ "Solarize", { {"geometry", StringReference}, |
| 365 |
{"threshold", StringReference} } }, |
| 366 |
{ "Sync", { { (const char *) NULL, NullReference } } }, |
| 367 |
{ "Texture", { {"texture", ImageReference} } }, |
| 368 |
{ "Evaluate", { {"value", RealReference}, |
| 369 |
{"operator", MagickEvaluateOptions}, |
| 370 |
{"channel", MagickChannelOptions} } }, |
| 371 |
{ "Transparent", { {"color", StringReference}, {"opacity", StringReference}, |
| 372 |
{"fuzz", StringReference}, {"invert", MagickBooleanOptions} } }, |
| 373 |
{ "Threshold", { {"threshold", StringReference}, |
| 374 |
{"channel", MagickChannelOptions} } }, |
| 375 |
{ "Charcoal", { {"geometry", StringReference}, {"radius", RealReference}, |
| 376 |
{"sigma", RealReference} } }, |
| 377 |
{ "Trim", { {"fuzz", StringReference} } }, |
| 378 |
{ "Wave", { {"geometry", StringReference}, {"amplitude", RealReference}, |
| 379 |
{"wavelength", RealReference}, |
| 380 |
{"interpolate", MagickInterpolateOptions} } }, |
| 381 |
{ "Separate", { {"channel", MagickChannelOptions} } }, |
| 382 |
{ "Condense", { { (const char *) NULL, NullReference } } }, |
| 383 |
{ "Stereo", { {"image", ImageReference}, {"x", IntegerReference}, |
| 384 |
{"y", IntegerReference} } }, |
| 385 |
{ "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } }, |
| 386 |
{ "Deconstruct", { { (const char *) NULL, NullReference } } }, |
| 387 |
{ "GaussianBlur", { {"geometry", StringReference}, |
| 388 |
{"radius", RealReference}, {"sigma", RealReference}, |
| 389 |
{"channel", MagickChannelOptions} } }, |
| 390 |
{ "Convolve", { {"coefficients", ArrayReference}, |
| 391 |
{"channel", MagickChannelOptions}, {"bias", StringReference}, |
| 392 |
{"kernel", StringReference} } }, |
| 393 |
{ "Profile", { {"name", StringReference}, {"profile", StringReference}, |
| 394 |
{ "rendering-intent", MagickIntentOptions}, |
| 395 |
{ "black-point-compensation", MagickBooleanOptions} } }, |
| 396 |
{ "UnsharpMask", { {"geometry", StringReference}, |
| 397 |
{"radius", RealReference}, {"sigma", RealReference}, |
| 398 |
{"gain", RealReference}, {"threshold", RealReference}, |
| 399 |
{"channel", MagickChannelOptions} } }, |
| 400 |
{ "MotionBlur", { {"geometry", StringReference}, |
| 401 |
{"radius", RealReference}, {"sigma", RealReference}, |
| 402 |
{"angle", RealReference}, {"channel", MagickChannelOptions} } }, |
| 403 |
{ "OrderedDither", { {"threshold", StringReference}, |
| 404 |
{"channel", MagickChannelOptions} } }, |
| 405 |
{ "Shave", { {"geometry", StringReference}, {"width", IntegerReference}, |
| 406 |
{"height", IntegerReference} } }, |
| 407 |
{ "Level", { {"levels", StringReference}, {"black-point", RealReference}, |
| 408 |
{"white-point", RealReference}, {"gamma", RealReference}, |
| 409 |
{"channel", MagickChannelOptions}, {"level", StringReference} } }, |
| 410 |
{ "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } }, |
| 411 |
{ "AffineTransform", { {"affine", ArrayReference}, |
| 412 |
{"translate", StringReference}, {"scale", StringReference}, |
| 413 |
{"rotate", RealReference}, {"skewX", RealReference}, |
| 414 |
{"skewY", RealReference}, {"interpolate", MagickInterpolateOptions}, |
| 415 |
{"background", StringReference} } }, |
| 416 |
{ "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } }, |
| 417 |
{ "AdaptiveThreshold", { {"geometry", StringReference}, |
| 418 |
{"width", IntegerReference}, {"height", IntegerReference}, |
| 419 |
{"bias", RealReference} } }, |
| 420 |
{ "Resample", { {"density", StringReference}, {"x", RealReference}, |
| 421 |
{"y", RealReference}, {"filter", MagickFilterOptions}, |
| 422 |
{"support", RealReference } } }, |
| 423 |
{ "Describe", { {"file", FileReference} } }, |
| 424 |
{ "BlackThreshold", { {"threshold", StringReference}, |
| 425 |
{"channel", MagickChannelOptions} } }, |
| 426 |
{ "WhiteThreshold", { {"threshold", StringReference}, |
| 427 |
{"channel", MagickChannelOptions} } }, |
| 428 |
{ "RotationalBlur", { {"geometry", StringReference}, |
| 429 |
{"angle", RealReference}, {"channel", MagickChannelOptions} } }, |
| 430 |
{ "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference}, |
| 431 |
{"height", IntegerReference} } }, |
| 432 |
{ "Strip", { { (const char *) NULL, NullReference } } }, |
| 433 |
{ "Tint", { {"fill", StringReference}, {"blend", StringReference} } }, |
| 434 |
{ "Channel", { {"channel", MagickChannelOptions} } }, |
| 435 |
{ "Splice", { {"geometry", StringReference}, {"width", IntegerReference}, |
| 436 |
{"height", IntegerReference}, {"x", IntegerReference}, |
| 437 |
{"y", IntegerReference}, {"fuzz", StringReference}, |
| 438 |
{"background", StringReference}, {"gravity", MagickGravityOptions} } }, |
| 439 |
{ "Posterize", { {"levels", IntegerReference}, |
| 440 |
{"dither", MagickBooleanOptions} } }, |
| 441 |
{ "Shadow", { {"geometry", StringReference}, {"alpha", RealReference}, |
| 442 |
{"sigma", RealReference}, {"x", IntegerReference}, |
| 443 |
{"y", IntegerReference} } }, |
| 444 |
{ "Identify", { {"file", FileReference}, {"features", StringReference}, |
| 445 |
{"moments", MagickBooleanOptions}, {"unique", MagickBooleanOptions} } }, |
| 446 |
{ "SepiaTone", { {"threshold", RealReference} } }, |
| 447 |
{ "SigmoidalContrast", { {"geometry", StringReference}, |
| 448 |
{"contrast", RealReference}, {"mid-point", RealReference}, |
| 449 |
{"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } }, |
| 450 |
{ "Extent", { {"geometry", StringReference}, {"width", IntegerReference}, |
| 451 |
{"height", IntegerReference}, {"x", IntegerReference}, |
| 452 |
{"y", IntegerReference}, {"fuzz", StringReference}, |
| 453 |
{"background", StringReference}, {"gravity", MagickGravityOptions} } }, |
| 454 |
{ "Vignette", { {"geometry", StringReference}, {"radius", RealReference}, |
| 455 |
{"sigma", RealReference}, {"x", IntegerReference}, |
| 456 |
{"y", IntegerReference}, {"background", StringReference} } }, |
| 457 |
{ "ContrastStretch", { {"levels", StringReference}, |
| 458 |
{"black-point", RealReference},{"white-point", RealReference}, |
| 459 |
{"channel", MagickChannelOptions} } }, |
| 460 |
{ "Sans0", { { (const char *) NULL, NullReference } } }, |
| 461 |
{ "Sans1", { { (const char *) NULL, NullReference } } }, |
| 462 |
{ "AdaptiveSharpen", { {"geometry", StringReference}, |
| 463 |
{"radius", RealReference}, {"sigma", RealReference}, |
| 464 |
{"bias", RealReference}, {"channel", MagickChannelOptions} } }, |
| 465 |
{ "Transpose", { { (const char *) NULL, NullReference } } }, |
| 466 |
{ "Transverse", { { (const char *) NULL, NullReference } } }, |
| 467 |
{ "AutoOrient", { { (const char *) NULL, NullReference } } }, |
| 468 |
{ "AdaptiveBlur", { {"geometry", StringReference}, |
| 469 |
{"radius", RealReference}, {"sigma", RealReference}, |
| 470 |
{"channel", MagickChannelOptions} } }, |
| 471 |
{ "Sketch", { {"geometry", StringReference}, |
| 472 |
{"radius", RealReference}, {"sigma", RealReference}, |
| 473 |
{"angle", RealReference} } }, |
| 474 |
{ "UniqueColors", { { (const char *) NULL, NullReference } } }, |
| 475 |
{ "AdaptiveResize", { {"geometry", StringReference}, |
| 476 |
{"width", IntegerReference}, {"height", IntegerReference}, |
| 477 |
{"filter", MagickFilterOptions}, {"support", StringReference }, |
| 478 |
{"blur", RealReference } } }, |
| 479 |
{ "ClipMask", { {"mask", ImageReference} } }, |
| 480 |
{ "LinearStretch", { {"levels", StringReference}, |
| 481 |
{"black-point", RealReference},{"white-point", RealReference} } }, |
| 482 |
{ "ColorMatrix", { {"matrix", ArrayReference} } }, |
| 483 |
{ "Mask", { {"mask", ImageReference} } }, |
| 484 |
{ "Polaroid", { {"caption", StringReference}, {"angle", RealReference}, |
| 485 |
{"font", StringReference}, {"stroke", StringReference}, |
| 486 |
{"fill", StringReference}, {"strokewidth", RealReference}, |
| 487 |
{"pointsize", RealReference}, {"gravity", MagickGravityOptions}, |
| 488 |
{"background", StringReference}, |
| 489 |
{"interpolate", MagickInterpolateOptions} } }, |
| 490 |
{ "FloodfillPaint", { {"geometry", StringReference}, |
| 491 |
{"x", IntegerReference}, {"y", IntegerReference}, |
| 492 |
{"fill", StringReference}, {"bordercolor", StringReference}, |
| 493 |
{"fuzz", StringReference}, {"channel", MagickChannelOptions}, |
| 494 |
{"invert", MagickBooleanOptions} } }, |
| 495 |
{ "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions}, |
| 496 |
{"virtual-pixel", MagickVirtualPixelOptions}, |
| 497 |
{"best-fit", MagickBooleanOptions} } }, |
| 498 |
{ "Clut", { {"image", ImageReference}, |
| 499 |
{"interpolate", MagickInterpolateOptions}, |
| 500 |
{"channel", MagickChannelOptions} } }, |
| 501 |
{ "LiquidRescale", { {"geometry", StringReference}, |
| 502 |
{"width", IntegerReference}, {"height", IntegerReference}, |
| 503 |
{"delta-x", RealReference}, {"rigidity", RealReference } } }, |
| 504 |
{ "Encipher", { {"passphrase", StringReference} } }, |
| 505 |
{ "Decipher", { {"passphrase", StringReference} } }, |
| 506 |
{ "Deskew", { {"geometry", StringReference}, |
| 507 |
{"threshold", StringReference} } }, |
| 508 |
{ "Remap", { {"image", ImageReference}, |
| 509 |
{"dither-method", MagickDitherOptions} } }, |
| 510 |
{ "SparseColor", { {"points", ArrayReference}, |
| 511 |
{"method", MagickSparseColorOptions}, |
| 512 |
{"virtual-pixel", MagickVirtualPixelOptions}, |
| 513 |
{"channel", MagickChannelOptions} } }, |
| 514 |
{ "Function", { {"parameters", ArrayReference}, |
| 515 |
{"function", MagickFunctionOptions}, |
| 516 |
{"virtual-pixel", MagickVirtualPixelOptions} } }, |
| 517 |
{ "SelectiveBlur", { {"geometry", StringReference}, |
| 518 |
{"radius", RealReference}, {"sigma", RealReference}, |
| 519 |
{"threshold", RealReference}, {"channel", MagickChannelOptions} } }, |
| 520 |
{ "HaldClut", { {"image", ImageReference}, |
| 521 |
{"channel", MagickChannelOptions} } }, |
| 522 |
{ "BlueShift", { {"factor", StringReference} } }, |
| 523 |
{ "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } }, |
| 524 |
{ "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } }, |
| 525 |
{ "ColorDecisionList", { |
| 526 |
{"color-correction-collection", StringReference} } }, |
| 527 |
{ "AutoGamma", { {"channel", MagickChannelOptions} } }, |
| 528 |
{ "AutoLevel", { {"channel", MagickChannelOptions} } }, |
| 529 |
{ "LevelColors", { {"invert", MagickBooleanOptions}, |
| 530 |
{"black-point", StringReference}, {"white-point", StringReference}, |
| 531 |
{"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } }, |
| 532 |
{ "Clamp", { {"channel", MagickChannelOptions} } }, |
| 533 |
{ "BrightnessContrast", { {"levels", StringReference}, |
| 534 |
{"brightness", RealReference},{"contrast", RealReference}, |
| 535 |
{"channel", MagickChannelOptions} } }, |
| 536 |
{ "Morphology", { {"kernel", StringReference}, |
| 537 |
{"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions}, |
| 538 |
{"iterations", IntegerReference} } }, |
| 539 |
{ "Mode", { {"geometry", StringReference}, |
| 540 |
{"width", IntegerReference},{"height", IntegerReference}, |
| 541 |
{"channel", MagickChannelOptions} } }, |
| 542 |
{ "Statistic", { {"geometry", StringReference}, |
| 543 |
{"width", IntegerReference},{"height", IntegerReference}, |
| 544 |
{"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } }, |
| 545 |
{ "Perceptible", { {"epsilon", RealReference}, |
| 546 |
{"channel", MagickChannelOptions} } }, |
| 547 |
{ "Poly", { {"terms", ArrayReference}, |
| 548 |
{"channel", MagickChannelOptions} } }, |
| 549 |
{ "Grayscale", { {"method", MagickNoiseOptions} } }, |
| 550 |
{ "CannyEdge", { {"geometry", StringReference}, |
| 551 |
{"radius", RealReference}, {"sigma", RealReference}, |
| 552 |
{"lower-percent", RealReference}, {"upper-percent", RealReference} } }, |
| 553 |
{ "HoughLine", { {"geometry", StringReference}, |
| 554 |
{"width", IntegerReference}, {"height", IntegerReference}, |
| 555 |
{"threshold", IntegerReference} } }, |
| 556 |
{ "MeanShift", { {"geometry", StringReference}, |
| 557 |
{"width", IntegerReference}, {"height", IntegerReference}, |
| 558 |
{"distance", RealReference} } }, |
| 559 |
{ "Kuwahara", { {"geometry", StringReference}, {"radius", RealReference}, |
| 560 |
{"sigma", RealReference}, {"channel", MagickChannelOptions} } }, |
| 561 |
{ "ConnectedComponents", { {"connectivity", IntegerReference} } }, |
| 562 |
{ "CopyPixels", { {"image", ImageReference}, {"geometry", StringReference}, |
| 563 |
{"width", IntegerReference}, {"height", IntegerReference}, |
| 564 |
{"x", IntegerReference}, {"y", IntegerReference}, |
| 565 |
{"gravity", MagickGravityOptions}, {"offset", StringReference}, |
| 566 |
{"dx", IntegerReference}, {"dy", IntegerReference} } }, |
| 567 |
{ "Color", { {"color", StringReference} } }, |
| 568 |
{ "WaveletDenoise", { {"geometry", StringReference}, |
| 569 |
{"threshold", RealReference}, {"softness", RealReference}, |
| 570 |
{"channel", MagickChannelOptions} } }, |
| 571 |
{ "Colorspace", { {"colorspace", MagickColorspaceOptions} } }, |
| 572 |
{ "AutoThreshold", { {"method", MagickAutoThresholdOptions} } }, |
| 573 |
{ "RangeThreshold", { {"geometry", StringReference}, |
| 574 |
{"low-black", RealReference}, {"low-white", RealReference}, |
| 575 |
{"high-white", RealReference}, {"high-black", RealReference}, |
| 576 |
{"channel", MagickChannelOptions} } }, |
| 577 |
{ "CLAHE", { {"geometry", StringReference}, {"width", IntegerReference}, |
| 578 |
{"height", IntegerReference}, {"number-bins", IntegerReference}, |
| 579 |
{"clip-limit", RealReference} } }, |
| 580 |
{ "Kmeans", { {"geometry", StringReference}, {"colors", IntegerReference}, |
| 581 |
{"iterations", IntegerReference}, {"tolerance", RealReference} } }, |
| 582 |
{ "ColorThreshold", { {"start-color", StringReference}, |
| 583 |
{"stop-color", StringReference}, {"channel", MagickChannelOptions} } }, |
| 584 |
{ "WhiteBalance", { { (const char *) NULL, NullReference } } }, |
| 585 |
{ "BilateralBlur", { {"geometry", StringReference}, |
| 586 |
{"width", IntegerReference}, {"height", IntegerReference}, |
| 587 |
{"intensity-sigma", RealReference}, {"spatial-sigma", RealReference}, |
| 588 |
{"channel", MagickChannelOptions} } }, |
| 589 |
{ "SortPixels", { { (const char *) NULL, NullReference } } }, |
| 590 |
{ "Integral", { { (const char *) NULL, NullReference } } }, |
| 591 |
}; |
| 592 |
|
| 593 |
static SplayTreeInfo |
| 594 |
*magick_registry = (SplayTreeInfo *) NULL; |
| 595 |
|
| 596 |
/* |
| 597 |
Forward declarations. |
| 598 |
*/ |
| 599 |
static Image |
| 600 |
*SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *); |
| 601 |
|
| 602 |
static ssize_t |
| 603 |
strEQcase(const char *,const char *); |
| 604 |
|
| 605 |
/* |
| 606 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 607 |
% % |
| 608 |
% % |
| 609 |
% % |
| 610 |
% C l o n e P a c k a g e I n f o % |
| 611 |
% % |
| 612 |
% % |
| 613 |
% % |
| 614 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 615 |
% |
| 616 |
% ClonePackageInfo makes a duplicate of the given info, or if info is NULL, |
| 617 |
% a new one. |
| 618 |
% |
| 619 |
% The format of the ClonePackageInfo routine is: |
| 620 |
% |
| 621 |
% struct PackageInfo *ClonePackageInfo(struct PackageInfo *info, |
| 622 |
% exception) |
| 623 |
% |
| 624 |
% A description of each parameter follows: |
| 625 |
% |
| 626 |
% o info: a structure of type info. |
| 627 |
% |
| 628 |
% o exception: Return any errors or warnings in this structure. |
| 629 |
% |
| 630 |
*/ |
| 631 |
static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info, |
| 632 |
ExceptionInfo *exception) |
| 633 |
{ |
| 634 |
struct PackageInfo |
| 635 |
*clone_info; |
| 636 |
|
| 637 |
clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info)); |
| 638 |
if (clone_info == (struct PackageInfo *) NULL) |
| 639 |
{ |
| 640 |
ThrowPerlException(exception,ResourceLimitError, |
| 641 |
"UnableToClonePackageInfo",PackageName); |
| 642 |
return((struct PackageInfo *) NULL); |
| 643 |
} |
| 644 |
if (info == (struct PackageInfo *) NULL) |
| 645 |
{ |
| 646 |
clone_info->image_info=CloneImageInfo((ImageInfo *) NULL); |
| 647 |
return(clone_info); |
| 648 |
} |
| 649 |
*clone_info=(*info); |
| 650 |
clone_info->image_info=CloneImageInfo(info->image_info); |
| 651 |
return(clone_info); |
| 652 |
} |
| 653 |
|
| 654 |
/* |
| 655 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 656 |
% % |
| 657 |
% % |
| 658 |
% % |
| 659 |
% c o n s t a n t % |
| 660 |
% % |
| 661 |
% % |
| 662 |
% % |
| 663 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 664 |
% |
| 665 |
% constant() returns a double value for the specified name. |
| 666 |
% |
| 667 |
% The format of the constant routine is: |
| 668 |
% |
| 669 |
% double constant(char *name,ssize_t sans) |
| 670 |
% |
| 671 |
% A description of each parameter follows: |
| 672 |
% |
| 673 |
% o value: Method constant returns a double value for the specified name. |
| 674 |
% |
| 675 |
% o name: The name of the constant. |
| 676 |
% |
| 677 |
% o sans: This integer value is not used. |
| 678 |
% |
| 679 |
*/ |
| 680 |
static double constant(char *name,ssize_t sans) |
| 681 |
{ |
| 682 |
(void) sans; |
| 683 |
errno=0; |
| 684 |
switch (*name) |
| 685 |
{ |
| 686 |
case 'B': |
| 687 |
{ |
| 688 |
if (strEQ(name,"BlobError")) |
| 689 |
return(BlobError); |
| 690 |
if (strEQ(name,"BlobWarning")) |
| 691 |
return(BlobWarning); |
| 692 |
break; |
| 693 |
} |
| 694 |
case 'C': |
| 695 |
{ |
| 696 |
if (strEQ(name,"CacheError")) |
| 697 |
return(CacheError); |
| 698 |
if (strEQ(name,"CacheWarning")) |
| 699 |
return(CacheWarning); |
| 700 |
if (strEQ(name,"CoderError")) |
| 701 |
return(CoderError); |
| 702 |
if (strEQ(name,"CoderWarning")) |
| 703 |
return(CoderWarning); |
| 704 |
if (strEQ(name,"ConfigureError")) |
| 705 |
return(ConfigureError); |
| 706 |
if (strEQ(name,"ConfigureWarning")) |
| 707 |
return(ConfigureWarning); |
| 708 |
if (strEQ(name,"CorruptImageError")) |
| 709 |
return(CorruptImageError); |
| 710 |
if (strEQ(name,"CorruptImageWarning")) |
| 711 |
return(CorruptImageWarning); |
| 712 |
break; |
| 713 |
} |
| 714 |
case 'D': |
| 715 |
{ |
| 716 |
if (strEQ(name,"DelegateError")) |
| 717 |
return(DelegateError); |
| 718 |
if (strEQ(name,"DelegateWarning")) |
| 719 |
return(DelegateWarning); |
| 720 |
if (strEQ(name,"DrawError")) |
| 721 |
return(DrawError); |
| 722 |
if (strEQ(name,"DrawWarning")) |
| 723 |
return(DrawWarning); |
| 724 |
break; |
| 725 |
} |
| 726 |
case 'E': |
| 727 |
{ |
| 728 |
if (strEQ(name,"ErrorException")) |
| 729 |
return(ErrorException); |
| 730 |
if (strEQ(name,"ExceptionError")) |
| 731 |
return(CoderError); |
| 732 |
if (strEQ(name,"ExceptionWarning")) |
| 733 |
return(CoderWarning); |
| 734 |
break; |
| 735 |
} |
| 736 |
case 'F': |
| 737 |
{ |
| 738 |
if (strEQ(name,"FatalErrorException")) |
| 739 |
return(FatalErrorException); |
| 740 |
if (strEQ(name,"FileOpenError")) |
| 741 |
return(FileOpenError); |
| 742 |
if (strEQ(name,"FileOpenWarning")) |
| 743 |
return(FileOpenWarning); |
| 744 |
break; |
| 745 |
} |
| 746 |
case 'I': |
| 747 |
{ |
| 748 |
if (strEQ(name,"ImageError")) |
| 749 |
return(ImageError); |
| 750 |
if (strEQ(name,"ImageWarning")) |
| 751 |
return(ImageWarning); |
| 752 |
break; |
| 753 |
} |
| 754 |
case 'M': |
| 755 |
{ |
| 756 |
if (strEQ(name,"MaxRGB")) |
| 757 |
return(QuantumRange); |
| 758 |
if (strEQ(name,"MissingDelegateError")) |
| 759 |
return(MissingDelegateError); |
| 760 |
if (strEQ(name,"MissingDelegateWarning")) |
| 761 |
return(MissingDelegateWarning); |
| 762 |
if (strEQ(name,"ModuleError")) |
| 763 |
return(ModuleError); |
| 764 |
if (strEQ(name,"ModuleWarning")) |
| 765 |
return(ModuleWarning); |
| 766 |
break; |
| 767 |
} |
| 768 |
case 'O': |
| 769 |
{ |
| 770 |
if (strEQ(name,"Opaque")) |
| 771 |
return(OpaqueAlpha); |
| 772 |
if (strEQ(name,"OptionError")) |
| 773 |
return(OptionError); |
| 774 |
if (strEQ(name,"OptionWarning")) |
| 775 |
return(OptionWarning); |
| 776 |
break; |
| 777 |
} |
| 778 |
case 'Q': |
| 779 |
{ |
| 780 |
if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH")) |
| 781 |
return(MAGICKCORE_QUANTUM_DEPTH); |
| 782 |
if (strEQ(name,"QuantumDepth")) |
| 783 |
return(MAGICKCORE_QUANTUM_DEPTH); |
| 784 |
if (strEQ(name,"QuantumRange")) |
| 785 |
return(QuantumRange); |
| 786 |
break; |
| 787 |
} |
| 788 |
case 'R': |
| 789 |
{ |
| 790 |
if (strEQ(name,"ResourceLimitError")) |
| 791 |
return(ResourceLimitError); |
| 792 |
if (strEQ(name,"ResourceLimitWarning")) |
| 793 |
return(ResourceLimitWarning); |
| 794 |
if (strEQ(name,"RegistryError")) |
| 795 |
return(RegistryError); |
| 796 |
if (strEQ(name,"RegistryWarning")) |
| 797 |
return(RegistryWarning); |
| 798 |
break; |
| 799 |
} |
| 800 |
case 'S': |
| 801 |
{ |
| 802 |
if (strEQ(name,"StreamError")) |
| 803 |
return(StreamError); |
| 804 |
if (strEQ(name,"StreamWarning")) |
| 805 |
return(StreamWarning); |
| 806 |
if (strEQ(name,"Success")) |
| 807 |
return(0); |
| 808 |
break; |
| 809 |
} |
| 810 |
case 'T': |
| 811 |
{ |
| 812 |
if (strEQ(name,"Transparent")) |
| 813 |
return(TransparentAlpha); |
| 814 |
if (strEQ(name,"TypeError")) |
| 815 |
return(TypeError); |
| 816 |
if (strEQ(name,"TypeWarning")) |
| 817 |
return(TypeWarning); |
| 818 |
break; |
| 819 |
} |
| 820 |
case 'W': |
| 821 |
{ |
| 822 |
if (strEQ(name,"WarningException")) |
| 823 |
return(WarningException); |
| 824 |
break; |
| 825 |
} |
| 826 |
case 'X': |
| 827 |
{ |
| 828 |
if (strEQ(name,"XServerError")) |
| 829 |
return(XServerError); |
| 830 |
if (strEQ(name,"XServerWarning")) |
| 831 |
return(XServerWarning); |
| 832 |
break; |
| 833 |
} |
| 834 |
} |
| 835 |
errno=EINVAL; |
| 836 |
return(0); |
| 837 |
} |
| 838 |
|
| 839 |
/* |
| 840 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 841 |
% % |
| 842 |
% % |
| 843 |
% % |
| 844 |
% D e s t r o y P a c k a g e I n f o % |
| 845 |
% % |
| 846 |
% % |
| 847 |
% % |
| 848 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 849 |
% |
| 850 |
% Method DestroyPackageInfo frees a previously created info structure. |
| 851 |
% |
| 852 |
% The format of the DestroyPackageInfo routine is: |
| 853 |
% |
| 854 |
% DestroyPackageInfo(struct PackageInfo *info) |
| 855 |
% |
| 856 |
% A description of each parameter follows: |
| 857 |
% |
| 858 |
% o info: a structure of type info. |
| 859 |
% |
| 860 |
*/ |
| 861 |
static void DestroyPackageInfo(struct PackageInfo *info) |
| 862 |
{ |
| 863 |
info->image_info=DestroyImageInfo(info->image_info); |
| 864 |
info=(struct PackageInfo *) RelinquishMagickMemory(info); |
| 865 |
} |
| 866 |
|
| 867 |
/* |
| 868 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 869 |
% % |
| 870 |
% % |
| 871 |
% % |
| 872 |
% G e t L i s t % |
| 873 |
% % |
| 874 |
% % |
| 875 |
% % |
| 876 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 877 |
% |
| 878 |
% Method GetList is recursively called by SetupList to traverse the |
| 879 |
% Image__Magick reference. If building an reference_vector (see SetupList), |
| 880 |
% *current is the current position in *reference_vector and *last is the final |
| 881 |
% entry in *reference_vector. |
| 882 |
% |
| 883 |
% The format of the GetList routine is: |
| 884 |
% |
| 885 |
% GetList(info) |
| 886 |
% |
| 887 |
% A description of each parameter follows: |
| 888 |
% |
| 889 |
% o info: a structure of type info. |
| 890 |
% |
| 891 |
*/ |
| 892 |
static Image *GetList(pTHX_ SV *reference,SV ***reference_vector, |
| 893 |
ssize_t *current,ssize_t *last,ExceptionInfo *exception) |
| 894 |
{ |
| 895 |
Image |
| 896 |
*image; |
| 897 |
|
| 898 |
if (reference == (SV *) NULL) |
| 899 |
return(NULL); |
| 900 |
switch (SvTYPE(reference)) |
| 901 |
{ |
| 902 |
case SVt_PVAV: |
| 903 |
{ |
| 904 |
AV |
| 905 |
*av; |
| 906 |
|
| 907 |
Image |
| 908 |
*head, |
| 909 |
*previous; |
| 910 |
|
| 911 |
ssize_t |
| 912 |
i, |
| 913 |
n; |
| 914 |
|
| 915 |
/* |
| 916 |
Array of images. |
| 917 |
*/ |
| 918 |
previous=(Image *) NULL; |
| 919 |
head=(Image *) NULL; |
| 920 |
av=(AV *) reference; |
| 921 |
n=av_len(av); |
| 922 |
for (i=0; i <= n; i++) |
| 923 |
{ |
| 924 |
SV |
| 925 |
**rv; |
| 926 |
|
| 927 |
rv=av_fetch(av,i,0); |
| 928 |
if (rv && *rv && sv_isobject(*rv)) |
| 929 |
{ |
| 930 |
image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last, |
| 931 |
exception); |
| 932 |
if (image == (Image *) NULL) |
| 933 |
continue; |
| 934 |
if (image == previous) |
| 935 |
{ |
| 936 |
image=CloneImage(image,0,0,MagickTrue,exception); |
| 937 |
if (image == (Image *) NULL) |
| 938 |
return(NULL); |
| 939 |
} |
| 940 |
image->previous=previous; |
| 941 |
*(previous ? &previous->next : &head)=image; |
| 942 |
for (previous=image; previous->next; previous=previous->next) ; |
| 943 |
} |
| 944 |
} |
| 945 |
return(head); |
| 946 |
} |
| 947 |
case SVt_PVMG: |
| 948 |
{ |
| 949 |
/* |
| 950 |
Blessed scalar, one image. |
| 951 |
*/ |
| 952 |
image=INT2PTR(Image *,SvIV(reference)); |
| 953 |
if (image == (Image *) NULL) |
| 954 |
return(NULL); |
| 955 |
image->previous=(Image *) NULL; |
| 956 |
image->next=(Image *) NULL; |
| 957 |
if (reference_vector) |
| 958 |
{ |
| 959 |
if (*current == *last) |
| 960 |
{ |
| 961 |
*last+=256; |
| 962 |
if (*reference_vector == (SV **) NULL) |
| 963 |
*reference_vector=(SV **) AcquireQuantumMemory((size_t) *last, |
| 964 |
sizeof(*reference_vector)); |
| 965 |
else |
| 966 |
*reference_vector=(SV **) ResizeQuantumMemory(*reference_vector, |
| 967 |
(size_t) *last,sizeof(*reference_vector)); |
| 968 |
} |
| 969 |
if (*reference_vector == (SV **) NULL) |
| 970 |
{ |
| 971 |
ThrowPerlException(exception,ResourceLimitError, |
| 972 |
"MemoryAllocationFailed",PackageName); |
| 973 |
return((Image *) NULL); |
| 974 |
} |
| 975 |
(*reference_vector)[*current]=reference; |
| 976 |
(*reference_vector)[++(*current)]=NULL; |
| 977 |
} |
| 978 |
return(image); |
| 979 |
} |
| 980 |
default: |
| 981 |
break; |
| 982 |
} |
| 983 |
(void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n", |
| 984 |
(double) SvTYPE(reference)); |
| 985 |
return((Image *) NULL); |
| 986 |
} |
| 987 |
|
| 988 |
/* |
| 989 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 990 |
% % |
| 991 |
% % |
| 992 |
% % |
| 993 |
% G e t P a c k a g e I n f o % |
| 994 |
% % |
| 995 |
% % |
| 996 |
% % |
| 997 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 998 |
% |
| 999 |
% Method GetPackageInfo looks up or creates an info structure for the given |
| 1000 |
% Image__Magick reference. If it does create a new one, the information in |
| 1001 |
% package_info is used to initialize it. |
| 1002 |
% |
| 1003 |
% The format of the GetPackageInfo routine is: |
| 1004 |
% |
| 1005 |
% struct PackageInfo *GetPackageInfo(void *reference, |
| 1006 |
% struct PackageInfo *package_info,ExceptionInfo *exception) |
| 1007 |
% |
| 1008 |
% A description of each parameter follows: |
| 1009 |
% |
| 1010 |
% o info: a structure of type info. |
| 1011 |
% |
| 1012 |
% o exception: Return any errors or warnings in this structure. |
| 1013 |
% |
| 1014 |
*/ |
| 1015 |
static struct PackageInfo *GetPackageInfo(pTHX_ void *reference, |
| 1016 |
struct PackageInfo *package_info,ExceptionInfo *exception) |
| 1017 |
{ |
| 1018 |
char |
| 1019 |
message[MagickPathExtent]; |
| 1020 |
|
| 1021 |
struct PackageInfo |
| 1022 |
*clone_info; |
| 1023 |
|
| 1024 |
SV |
| 1025 |
*sv; |
| 1026 |
|
| 1027 |
(void) FormatLocaleString(message,MagickPathExtent,"%s::package%s%p", |
| 1028 |
PackageName,XS_VERSION,reference); |
| 1029 |
sv=perl_get_sv(message,(TRUE | 0x02)); |
| 1030 |
if (sv == (SV *) NULL) |
| 1031 |
{ |
| 1032 |
ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo", |
| 1033 |
message); |
| 1034 |
return(package_info); |
| 1035 |
} |
| 1036 |
if (SvREFCNT(sv) == 0) |
| 1037 |
(void) SvREFCNT_inc(sv); |
| 1038 |
if (SvIOKp(sv) && (clone_info=INT2PTR(struct PackageInfo *,SvIV(sv)))) |
| 1039 |
return(clone_info); |
| 1040 |
clone_info=ClonePackageInfo(package_info,exception); |
| 1041 |
sv_setiv(sv,PTR2IV(clone_info)); |
| 1042 |
return(clone_info); |
| 1043 |
} |
| 1044 |
|
| 1045 |
/* |
| 1046 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1047 |
% % |
| 1048 |
% % |
| 1049 |
% % |
| 1050 |
% S e t A t t r i b u t e % |
| 1051 |
% % |
| 1052 |
% % |
| 1053 |
% % |
| 1054 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1055 |
% |
| 1056 |
% SetAttribute() sets the attribute to the value in sval. This can change |
| 1057 |
% either or both of image or info. |
| 1058 |
% |
| 1059 |
% The format of the SetAttribute routine is: |
| 1060 |
% |
| 1061 |
% SetAttribute(struct PackageInfo *info,Image *image,char *attribute, |
| 1062 |
% SV *sval,ExceptionInfo *exception) |
| 1063 |
% |
| 1064 |
% A description of each parameter follows: |
| 1065 |
% |
| 1066 |
% o list: a list of strings. |
| 1067 |
% |
| 1068 |
% o string: a character string. |
| 1069 |
% |
| 1070 |
*/ |
| 1071 |
|
| 1072 |
static double SiPrefixToDoubleInterval(const char *string,const double interval) |
| 1073 |
{ |
| 1074 |
char |
| 1075 |
*q; |
| 1076 |
|
| 1077 |
double |
| 1078 |
value; |
| 1079 |
|
| 1080 |
value=InterpretSiPrefixValue(string,&q); |
| 1081 |
if (*q == '%') |
| 1082 |
value*=interval/100.0; |
| 1083 |
return(value); |
| 1084 |
} |
| 1085 |
|
| 1086 |
static inline double StringToDouble(const char *string,char **sentinel) |
| 1087 |
{ |
| 1088 |
return(InterpretLocaleValue(string,sentinel)); |
| 1089 |
} |
| 1090 |
|
| 1091 |
static double StringToDoubleInterval(const char *string,const double interval) |
| 1092 |
{ |
| 1093 |
char |
| 1094 |
*q; |
| 1095 |
|
| 1096 |
double |
| 1097 |
value; |
| 1098 |
|
| 1099 |
value=InterpretLocaleValue(string,&q); |
| 1100 |
if (*q == '%') |
| 1101 |
value*=interval/100.0; |
| 1102 |
return(value); |
| 1103 |
} |
| 1104 |
|
| 1105 |
static inline ssize_t StringToLong(const char *value) |
| 1106 |
{ |
| 1107 |
return(strtol(value,(char **) NULL,10)); |
| 1108 |
} |
| 1109 |
|
| 1110 |
static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, |
| 1111 |
const char *attribute,SV *sval,ExceptionInfo *exception) |
| 1112 |
{ |
| 1113 |
GeometryInfo |
| 1114 |
geometry_info; |
| 1115 |
|
| 1116 |
long |
| 1117 |
x, |
| 1118 |
y; |
| 1119 |
|
| 1120 |
PixelInfo |
| 1121 |
pixel; |
| 1122 |
|
| 1123 |
MagickStatusType |
| 1124 |
flags; |
| 1125 |
|
| 1126 |
PixelInfo |
| 1127 |
*color, |
| 1128 |
target_color; |
| 1129 |
|
| 1130 |
ssize_t |
| 1131 |
sp; |
| 1132 |
|
| 1133 |
switch (*attribute) |
| 1134 |
{ |
| 1135 |
case 'A': |
| 1136 |
case 'a': |
| 1137 |
{ |
| 1138 |
if (LocaleCompare(attribute,"adjoin") == 0) |
| 1139 |
{ |
| 1140 |
sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse, |
| 1141 |
SvPV(sval,na)) : SvIV(sval); |
| 1142 |
if (sp < 0) |
| 1143 |
{ |
| 1144 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 1145 |
SvPV(sval,na)); |
| 1146 |
break; |
| 1147 |
} |
| 1148 |
if (info) |
| 1149 |
info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse; |
| 1150 |
break; |
| 1151 |
} |
| 1152 |
if (LocaleCompare(attribute,"alpha") == 0) |
| 1153 |
{ |
| 1154 |
sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaChannelOptions, |
| 1155 |
MagickFalse,SvPV(sval,na)) : SvIV(sval); |
| 1156 |
if (sp < 0) |
| 1157 |
{ |
| 1158 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 1159 |
SvPV(sval,na)); |
| 1160 |
break; |
| 1161 |
} |
| 1162 |
for ( ; image; image=image->next) |
| 1163 |
(void) SetImageAlphaChannel(image,(AlphaChannelOption) sp, |
| 1164 |
exception); |
| 1165 |
break; |
| 1166 |
} |
| 1167 |
if (LocaleCompare(attribute,"antialias") == 0) |
| 1168 |
{ |
| 1169 |
sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse, |
| 1170 |
SvPV(sval,na)) : SvIV(sval); |
| 1171 |
if (sp < 0) |
| 1172 |
{ |
| 1173 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 1174 |
SvPV(sval,na)); |
| 1175 |
break; |
| 1176 |
} |
| 1177 |
if (info) |
| 1178 |
info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse; |
| 1179 |
break; |
| 1180 |
} |
| 1181 |
if (LocaleCompare(attribute,"area-limit") == 0) |
| 1182 |
{ |
| 1183 |
MagickSizeType |
| 1184 |
limit; |
| 1185 |
|
| 1186 |
limit=MagickResourceInfinity; |
| 1187 |
if (LocaleCompare(SvPV(sval,na),"unlimited") != 0) |
| 1188 |
limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na), |
| 1189 |
100.0); |
| 1190 |
(void) SetMagickResourceLimit(AreaResource,limit); |
| 1191 |
break; |
| 1192 |
} |
| 1193 |
if (LocaleCompare(attribute,"attenuate") == 0) |
| 1194 |
{ |
| 1195 |
if (info) |
| 1196 |
(void) SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 1197 |
break; |
| 1198 |
} |
| 1199 |
if (LocaleCompare(attribute,"authenticate") == 0) |
| 1200 |
{ |
| 1201 |
if (info) |
| 1202 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 1203 |
break; |
| 1204 |
} |
| 1205 |
if (info) |
| 1206 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 1207 |
for ( ; image; image=image->next) |
| 1208 |
{ |
| 1209 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 1210 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 1211 |
} |
| 1212 |
break; |
| 1213 |
} |
| 1214 |
case 'B': |
| 1215 |
case 'b': |
| 1216 |
{ |
| 1217 |
if (LocaleCompare(attribute,"background") == 0) |
| 1218 |
{ |
| 1219 |
(void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color, |
| 1220 |
exception); |
| 1221 |
if (info) |
| 1222 |
info->image_info->background_color=target_color; |
| 1223 |
for ( ; image; image=image->next) |
| 1224 |
image->background_color=target_color; |
| 1225 |
break; |
| 1226 |
} |
| 1227 |
if (LocaleCompare(attribute,"blue-primary") == 0) |
| 1228 |
{ |
| 1229 |
for ( ; image; image=image->next) |
| 1230 |
{ |
| 1231 |
flags=ParseGeometry(SvPV(sval,na),&geometry_info); |
| 1232 |
image->chromaticity.blue_primary.x=geometry_info.rho; |
| 1233 |
image->chromaticity.blue_primary.y=geometry_info.sigma; |
| 1234 |
if ((flags & SigmaValue) == 0) |
| 1235 |
image->chromaticity.blue_primary.y= |
| 1236 |
image->chromaticity.blue_primary.x; |
| 1237 |
} |
| 1238 |
break; |
| 1239 |
} |
| 1240 |
if (LocaleCompare(attribute,"bordercolor") == 0) |
| 1241 |
{ |
| 1242 |
(void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color, |
| 1243 |
exception); |
| 1244 |
if (info) |
| 1245 |
info->image_info->border_color=target_color; |
| 1246 |
for ( ; image; image=image->next) |
| 1247 |
image->border_color=target_color; |
| 1248 |
break; |
| 1249 |
} |
| 1250 |
if (info) |
| 1251 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 1252 |
for ( ; image; image=image->next) |
| 1253 |
{ |
| 1254 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 1255 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 1256 |
} |
| 1257 |
break; |
| 1258 |
} |
| 1259 |
case 'C': |
| 1260 |
case 'c': |
| 1261 |
{ |
| 1262 |
if (LocaleCompare(attribute,"cache-threshold") == 0) |
| 1263 |
{ |
| 1264 |
(void) SetMagickResourceLimit(MemoryResource,(MagickSizeType) |
| 1265 |
SiPrefixToDoubleInterval(SvPV(sval,na),100.0)); |
| 1266 |
(void) SetMagickResourceLimit(MapResource,(MagickSizeType) |
| 1267 |
(2.0*SiPrefixToDoubleInterval(SvPV(sval,na),100.0))); |
| 1268 |
break; |
| 1269 |
} |
| 1270 |
if (LocaleCompare(attribute,"clip-mask") == 0) |
| 1271 |
{ |
| 1272 |
Image |
| 1273 |
*clip_mask; |
| 1274 |
|
| 1275 |
clip_mask=(Image *) NULL; |
| 1276 |
if (SvPOK(sval)) |
| 1277 |
clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception); |
| 1278 |
for ( ; image; image=image->next) |
| 1279 |
SetImageMask(image,ReadPixelMask,clip_mask,exception); |
| 1280 |
break; |
| 1281 |
} |
| 1282 |
if (LocaleNCompare(attribute,"colormap",8) == 0) |
| 1283 |
{ |
| 1284 |
for ( ; image; image=image->next) |
| 1285 |
{ |
| 1286 |
int |
| 1287 |
items; |
| 1288 |
|
| 1289 |
ssize_t |
| 1290 |
i; |
| 1291 |
|
| 1292 |
if (image->storage_class == DirectClass) |
| 1293 |
continue; |
| 1294 |
i=0; |
| 1295 |
items=sscanf(attribute,"%*[^[][%ld",&i); |
| 1296 |
(void) items; |
| 1297 |
if (i > (ssize_t) image->colors) |
| 1298 |
i%=(ssize_t) image->colors; |
| 1299 |
if ((strchr(SvPV(sval,na),',') == 0) || |
| 1300 |
(strchr(SvPV(sval,na),')') != 0)) |
| 1301 |
QueryColorCompliance(SvPV(sval,na),AllCompliance, |
| 1302 |
image->colormap+i,exception); |
| 1303 |
else |
| 1304 |
{ |
| 1305 |
color=image->colormap+i; |
| 1306 |
pixel.red=color->red; |
| 1307 |
pixel.green=color->green; |
| 1308 |
pixel.blue=color->blue; |
| 1309 |
flags=ParseGeometry(SvPV(sval,na),&geometry_info); |
| 1310 |
pixel.red=geometry_info.rho; |
| 1311 |
pixel.green=geometry_info.sigma; |
| 1312 |
pixel.blue=geometry_info.xi; |
| 1313 |
color->red=ClampToQuantum(pixel.red); |
| 1314 |
color->green=ClampToQuantum(pixel.green); |
| 1315 |
color->blue=ClampToQuantum(pixel.blue); |
| 1316 |
} |
| 1317 |
} |
| 1318 |
break; |
| 1319 |
} |
| 1320 |
if (LocaleCompare(attribute,"colorspace") == 0) |
| 1321 |
{ |
| 1322 |
sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions, |
| 1323 |
MagickFalse,SvPV(sval,na)) : SvIV(sval); |
| 1324 |
if (sp < 0) |
| 1325 |
{ |
| 1326 |
ThrowPerlException(exception,OptionError,"UnrecognizedColorspace", |
| 1327 |
SvPV(sval,na)); |
| 1328 |
break; |
| 1329 |
} |
| 1330 |
for ( ; image; image=image->next) |
| 1331 |
(void) SetImageColorspace(image,(ColorspaceType) sp,exception); |
| 1332 |
break; |
| 1333 |
} |
| 1334 |
if (LocaleCompare(attribute,"comment") == 0) |
| 1335 |
{ |
| 1336 |
for ( ; image; image=image->next) |
| 1337 |
(void) SetImageProperty(image,"Comment",InterpretImageProperties( |
| 1338 |
info ? info->image_info : (ImageInfo *) NULL,image, |
| 1339 |
SvPV(sval,na),exception),exception); |
| 1340 |
break; |
| 1341 |
} |
| 1342 |
if (LocaleCompare(attribute,"compression") == 0) |
| 1343 |
{ |
| 1344 |
sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions, |
| 1345 |
MagickFalse,SvPV(sval,na)) : SvIV(sval); |
| 1346 |
if (sp < 0) |
| 1347 |
{ |
| 1348 |
ThrowPerlException(exception,OptionError, |
| 1349 |
"UnrecognizedImageCompression",SvPV(sval,na)); |
| 1350 |
break; |
| 1351 |
} |
| 1352 |
if (info) |
| 1353 |
info->image_info->compression=(CompressionType) sp; |
| 1354 |
for ( ; image; image=image->next) |
| 1355 |
image->compression=(CompressionType) sp; |
| 1356 |
break; |
| 1357 |
} |
| 1358 |
if (info) |
| 1359 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 1360 |
for ( ; image; image=image->next) |
| 1361 |
{ |
| 1362 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 1363 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 1364 |
} |
| 1365 |
break; |
| 1366 |
} |
| 1367 |
case 'D': |
| 1368 |
case 'd': |
| 1369 |
{ |
| 1370 |
if (LocaleCompare(attribute,"debug") == 0) |
| 1371 |
{ |
| 1372 |
SetLogEventMask(SvPV(sval,na)); |
| 1373 |
break; |
| 1374 |
} |
| 1375 |
if (LocaleCompare(attribute,"delay") == 0) |
| 1376 |
{ |
| 1377 |
flags=ParseGeometry(SvPV(sval,na),&geometry_info); |
| 1378 |
for ( ; image; image=image->next) |
| 1379 |
{ |
| 1380 |
image->delay=(size_t) floor(geometry_info.rho+0.5); |
| 1381 |
if ((flags & SigmaValue) != 0) |
| 1382 |
image->ticks_per_second=(ssize_t) |
| 1383 |
floor(geometry_info.sigma+0.5); |
| 1384 |
} |
| 1385 |
break; |
| 1386 |
} |
| 1387 |
if (LocaleCompare(attribute,"disk-limit") == 0) |
| 1388 |
{ |
| 1389 |
MagickSizeType |
| 1390 |
limit; |
| 1391 |
|
| 1392 |
limit=MagickResourceInfinity; |
| 1393 |
if (LocaleCompare(SvPV(sval,na),"unlimited") != 0) |
| 1394 |
limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na), |
| 1395 |
100.0); |
| 1396 |
(void) SetMagickResourceLimit(DiskResource,limit); |
| 1397 |
break; |
| 1398 |
} |
| 1399 |
if (LocaleCompare(attribute,"density") == 0) |
| 1400 |
{ |
| 1401 |
if (IsGeometry(SvPV(sval,na)) == MagickFalse) |
| 1402 |
{ |
| 1403 |
ThrowPerlException(exception,OptionError,"MissingGeometry", |
| 1404 |
SvPV(sval,na)); |
| 1405 |
break; |
| 1406 |
} |
| 1407 |
if (info) |
| 1408 |
(void) CloneString(&info->image_info->density,SvPV(sval,na)); |
| 1409 |
for ( ; image; image=image->next) |
| 1410 |
{ |
| 1411 |
flags=ParseGeometry(SvPV(sval,na),&geometry_info); |
| 1412 |
image->resolution.x=geometry_info.rho; |
| 1413 |
image->resolution.y=geometry_info.sigma; |
| 1414 |
if ((flags & SigmaValue) == 0) |
| 1415 |
image->resolution.y=image->resolution.x; |
| 1416 |
} |
| 1417 |
break; |
| 1418 |
} |
| 1419 |
if (LocaleCompare(attribute,"depth") == 0) |
| 1420 |
{ |
| 1421 |
if (info) |
| 1422 |
info->image_info->depth=(size_t) SvIV(sval); |
| 1423 |
for ( ; image; image=image->next) |
| 1424 |
(void) SetImageDepth(image,(size_t) SvIV(sval),exception); |
| 1425 |
break; |
| 1426 |
} |
| 1427 |
if (LocaleCompare(attribute,"dispose") == 0) |
| 1428 |
{ |
| 1429 |
sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse, |
| 1430 |
SvPV(sval,na)) : SvIV(sval); |
| 1431 |
if (sp < 0) |
| 1432 |
{ |
| 1433 |
ThrowPerlException(exception,OptionError, |
| 1434 |
"UnrecognizedDisposeMethod",SvPV(sval,na)); |
| 1435 |
break; |
| 1436 |
} |
| 1437 |
for ( ; image; image=image->next) |
| 1438 |
image->dispose=(DisposeType) sp; |
| 1439 |
break; |
| 1440 |
} |
| 1441 |
if (LocaleCompare(attribute,"dither") == 0) |
| 1442 |
{ |
| 1443 |
if (info) |
| 1444 |
{ |
| 1445 |
sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions, |
| 1446 |
MagickFalse,SvPV(sval,na)) : SvIV(sval); |
| 1447 |
if (sp < 0) |
| 1448 |
{ |
| 1449 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 1450 |
SvPV(sval,na)); |
| 1451 |
break; |
| 1452 |
} |
| 1453 |
info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse; |
| 1454 |
} |
| 1455 |
break; |
| 1456 |
} |
| 1457 |
if (LocaleCompare(attribute,"display") == 0) |
| 1458 |
{ |
| 1459 |
display: |
| 1460 |
if (info) |
| 1461 |
(void) CloneString(&info->image_info->server_name,SvPV(sval,na)); |
| 1462 |
break; |
| 1463 |
} |
| 1464 |
if (info) |
| 1465 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 1466 |
for ( ; image; image=image->next) |
| 1467 |
{ |
| 1468 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 1469 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 1470 |
} |
| 1471 |
break; |
| 1472 |
} |
| 1473 |
case 'E': |
| 1474 |
case 'e': |
| 1475 |
{ |
| 1476 |
if (LocaleCompare(attribute,"endian") == 0) |
| 1477 |
{ |
| 1478 |
sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse, |
| 1479 |
SvPV(sval,na)) : SvIV(sval); |
| 1480 |
if (sp < 0) |
| 1481 |
{ |
| 1482 |
ThrowPerlException(exception,OptionError,"UnrecognizedEndianType", |
| 1483 |
SvPV(sval,na)); |
| 1484 |
break; |
| 1485 |
} |
| 1486 |
if (info) |
| 1487 |
info->image_info->endian=(EndianType) sp; |
| 1488 |
for ( ; image; image=image->next) |
| 1489 |
image->endian=(EndianType) sp; |
| 1490 |
break; |
| 1491 |
} |
| 1492 |
if (LocaleCompare(attribute,"extract") == 0) |
| 1493 |
{ |
| 1494 |
/* |
| 1495 |
Set image extract geometry. |
| 1496 |
*/ |
| 1497 |
(void) CloneString(&info->image_info->extract,SvPV(sval,na)); |
| 1498 |
break; |
| 1499 |
} |
| 1500 |
if (info) |
| 1501 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 1502 |
for ( ; image; image=image->next) |
| 1503 |
{ |
| 1504 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 1505 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 1506 |
} |
| 1507 |
break; |
| 1508 |
} |
| 1509 |
case 'F': |
| 1510 |
case 'f': |
| 1511 |
{ |
| 1512 |
if (LocaleCompare(attribute,"filename") == 0) |
| 1513 |
{ |
| 1514 |
if (info) |
| 1515 |
(void) CopyMagickString(info->image_info->filename,SvPV(sval,na), |
| 1516 |
MagickPathExtent); |
| 1517 |
for ( ; image; image=image->next) |
| 1518 |
(void) CopyMagickString(image->filename,SvPV(sval,na), |
| 1519 |
MagickPathExtent); |
| 1520 |
break; |
| 1521 |
} |
| 1522 |
if (LocaleCompare(attribute,"file") == 0) |
| 1523 |
{ |
| 1524 |
FILE |
| 1525 |
*file; |
| 1526 |
|
| 1527 |
PerlIO |
| 1528 |
*io_info; |
| 1529 |
|
| 1530 |
if (info == (struct PackageInfo *) NULL) |
| 1531 |
break; |
| 1532 |
io_info=IoIFP(sv_2io(sval)); |
| 1533 |
if (io_info == (PerlIO *) NULL) |
| 1534 |
{ |
| 1535 |
ThrowPerlException(exception,BlobError,"UnableToOpenFile", |
| 1536 |
PackageName); |
| 1537 |
break; |
| 1538 |
} |
| 1539 |
file=PerlIO_findFILE(io_info); |
| 1540 |
if (file == (FILE *) NULL) |
| 1541 |
{ |
| 1542 |
ThrowPerlException(exception,BlobError,"UnableToOpenFile", |
| 1543 |
PackageName); |
| 1544 |
break; |
| 1545 |
} |
| 1546 |
SetImageInfoFile(info->image_info,file); |
| 1547 |
break; |
| 1548 |
} |
| 1549 |
if (LocaleCompare(attribute,"fill") == 0) |
| 1550 |
{ |
| 1551 |
if (info) |
| 1552 |
(void) SetImageOption(info->image_info,"fill",SvPV(sval,na)); |
| 1553 |
break; |
| 1554 |
} |
| 1555 |
if (LocaleCompare(attribute,"font") == 0) |
| 1556 |
{ |
| 1557 |
if (info) |
| 1558 |
(void) CloneString(&info->image_info->font,SvPV(sval,na)); |
| 1559 |
break; |
| 1560 |
} |
| 1561 |
if (LocaleCompare(attribute,"foreground") == 0) |
| 1562 |
break; |
| 1563 |
if (LocaleCompare(attribute,"fuzz") == 0) |
| 1564 |
{ |
| 1565 |
if (info) |
| 1566 |
info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),(double) |
| 1567 |
QuantumRange+1.0); |
| 1568 |
for ( ; image; image=image->next) |
| 1569 |
image->fuzz=StringToDoubleInterval(SvPV(sval,na),(double) |
| 1570 |
QuantumRange+1.0); |
| 1571 |
break; |
| 1572 |
} |
| 1573 |
if (info) |
| 1574 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 1575 |
for ( ; image; image=image->next) |
| 1576 |
{ |
| 1577 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 1578 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 1579 |
} |
| 1580 |
break; |
| 1581 |
} |
| 1582 |
case 'G': |
| 1583 |
case 'g': |
| 1584 |
{ |
| 1585 |
if (LocaleCompare(attribute,"gamma") == 0) |
| 1586 |
{ |
| 1587 |
for ( ; image; image=image->next) |
| 1588 |
image->gamma=SvNV(sval); |
| 1589 |
break; |
| 1590 |
} |
| 1591 |
if (LocaleCompare(attribute,"gravity") == 0) |
| 1592 |
{ |
| 1593 |
sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse, |
| 1594 |
SvPV(sval,na)) : SvIV(sval); |
| 1595 |
if (sp < 0) |
| 1596 |
{ |
| 1597 |
ThrowPerlException(exception,OptionError, |
| 1598 |
"UnrecognizedGravityType",SvPV(sval,na)); |
| 1599 |
break; |
| 1600 |
} |
| 1601 |
if (info) |
| 1602 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 1603 |
for ( ; image; image=image->next) |
| 1604 |
image->gravity=(GravityType) sp; |
| 1605 |
break; |
| 1606 |
} |
| 1607 |
if (LocaleCompare(attribute,"green-primary") == 0) |
| 1608 |
{ |
| 1609 |
for ( ; image; image=image->next) |
| 1610 |
{ |
| 1611 |
flags=ParseGeometry(SvPV(sval,na),&geometry_info); |
| 1612 |
image->chromaticity.green_primary.x=geometry_info.rho; |
| 1613 |
image->chromaticity.green_primary.y=geometry_info.sigma; |
| 1614 |
if ((flags & SigmaValue) == 0) |
| 1615 |
image->chromaticity.green_primary.y= |
| 1616 |
image->chromaticity.green_primary.x; |
| 1617 |
} |
| 1618 |
break; |
| 1619 |
} |
| 1620 |
if (info) |
| 1621 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 1622 |
for ( ; image; image=image->next) |
| 1623 |
{ |
| 1624 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 1625 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 1626 |
} |
| 1627 |
break; |
| 1628 |
} |
| 1629 |
case 'I': |
| 1630 |
case 'i': |
| 1631 |
{ |
| 1632 |
if (LocaleNCompare(attribute,"index",5) == 0) |
| 1633 |
{ |
| 1634 |
int |
| 1635 |
items; |
| 1636 |
|
| 1637 |
long |
| 1638 |
index; |
| 1639 |
|
| 1640 |
Quantum |
| 1641 |
*q; |
| 1642 |
|
| 1643 |
CacheView |
| 1644 |
*image_view; |
| 1645 |
|
| 1646 |
for ( ; image; image=image->next) |
| 1647 |
{ |
| 1648 |
if (image->storage_class != PseudoClass) |
| 1649 |
continue; |
| 1650 |
x=0; |
| 1651 |
y=0; |
| 1652 |
items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y); |
| 1653 |
(void) items; |
| 1654 |
image_view=AcquireAuthenticCacheView(image,exception); |
| 1655 |
q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception); |
| 1656 |
if (q != (Quantum *) NULL) |
| 1657 |
{ |
| 1658 |
items=sscanf(SvPV(sval,na),"%ld",&index); |
| 1659 |
if ((index >= 0) && (index < (ssize_t) image->colors)) |
| 1660 |
SetPixelIndex(image,index,q); |
| 1661 |
(void) SyncCacheViewAuthenticPixels(image_view,exception); |
| 1662 |
} |
| 1663 |
image_view=DestroyCacheView(image_view); |
| 1664 |
} |
| 1665 |
break; |
| 1666 |
} |
| 1667 |
if (LocaleCompare(attribute,"iterations") == 0) |
| 1668 |
{ |
| 1669 |
iterations: |
| 1670 |
for ( ; image; image=image->next) |
| 1671 |
image->iterations=(size_t) SvIV(sval); |
| 1672 |
break; |
| 1673 |
} |
| 1674 |
if (LocaleCompare(attribute,"interlace") == 0) |
| 1675 |
{ |
| 1676 |
sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions, |
| 1677 |
MagickFalse,SvPV(sval,na)) : SvIV(sval); |
| 1678 |
if (sp < 0) |
| 1679 |
{ |
| 1680 |
ThrowPerlException(exception,OptionError, |
| 1681 |
"UnrecognizedInterlaceType",SvPV(sval,na)); |
| 1682 |
break; |
| 1683 |
} |
| 1684 |
if (info) |
| 1685 |
info->image_info->interlace=(InterlaceType) sp; |
| 1686 |
for ( ; image; image=image->next) |
| 1687 |
image->interlace=(InterlaceType) sp; |
| 1688 |
break; |
| 1689 |
} |
| 1690 |
if (info) |
| 1691 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 1692 |
for ( ; image; image=image->next) |
| 1693 |
SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 1694 |
break; |
| 1695 |
} |
| 1696 |
case 'L': |
| 1697 |
case 'l': |
| 1698 |
{ |
| 1699 |
if (LocaleCompare(attribute,"label") == 0) |
| 1700 |
{ |
| 1701 |
for ( ; image; image=image->next) |
| 1702 |
(void) SetImageProperty(image,"label",InterpretImageProperties( |
| 1703 |
info ? info->image_info : (ImageInfo *) NULL,image, |
| 1704 |
SvPV(sval,na),exception),exception); |
| 1705 |
break; |
| 1706 |
} |
| 1707 |
if (LocaleCompare(attribute,"loop") == 0) |
| 1708 |
goto iterations; |
| 1709 |
if (info) |
| 1710 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 1711 |
for ( ; image; image=image->next) |
| 1712 |
{ |
| 1713 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 1714 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 1715 |
} |
| 1716 |
break; |
| 1717 |
} |
| 1718 |
case 'M': |
| 1719 |
case 'm': |
| 1720 |
{ |
| 1721 |
if (LocaleCompare(attribute,"magick") == 0) |
| 1722 |
{ |
| 1723 |
if (info) |
| 1724 |
(void) FormatLocaleString(info->image_info->filename, |
| 1725 |
MagickPathExtent,"%s:",SvPV(sval,na)); |
| 1726 |
for ( ; image; image=image->next) |
| 1727 |
(void) CopyMagickString(image->magick,SvPV(sval,na), |
| 1728 |
MagickPathExtent); |
| 1729 |
break; |
| 1730 |
} |
| 1731 |
if (LocaleCompare(attribute,"map-limit") == 0) |
| 1732 |
{ |
| 1733 |
MagickSizeType |
| 1734 |
limit; |
| 1735 |
|
| 1736 |
limit=MagickResourceInfinity; |
| 1737 |
if (LocaleCompare(SvPV(sval,na),"unlimited") != 0) |
| 1738 |
limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na), |
| 1739 |
100.0); |
| 1740 |
(void) SetMagickResourceLimit(MapResource,limit); |
| 1741 |
break; |
| 1742 |
} |
| 1743 |
if (LocaleCompare(attribute,"mask") == 0) |
| 1744 |
{ |
| 1745 |
Image |
| 1746 |
*mask; |
| 1747 |
|
| 1748 |
mask=(Image *) NULL; |
| 1749 |
if (SvPOK(sval)) |
| 1750 |
mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception); |
| 1751 |
for ( ; image; image=image->next) |
| 1752 |
SetImageMask(image,ReadPixelMask,mask,exception); |
| 1753 |
break; |
| 1754 |
} |
| 1755 |
if (LocaleCompare(attribute,"mattecolor") == 0) |
| 1756 |
{ |
| 1757 |
(void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color, |
| 1758 |
exception); |
| 1759 |
if (info) |
| 1760 |
info->image_info->alpha_color=target_color; |
| 1761 |
for ( ; image; image=image->next) |
| 1762 |
image->alpha_color=target_color; |
| 1763 |
break; |
| 1764 |
} |
| 1765 |
if (LocaleCompare(attribute,"matte") == 0) |
| 1766 |
{ |
| 1767 |
sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse, |
| 1768 |
SvPV(sval,na)) : SvIV(sval); |
| 1769 |
if (sp < 0) |
| 1770 |
{ |
| 1771 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 1772 |
SvPV(sval,na)); |
| 1773 |
break; |
| 1774 |
} |
| 1775 |
for ( ; image; image=image->next) |
| 1776 |
image->alpha_trait=sp != 0 ? BlendPixelTrait : UndefinedPixelTrait; |
| 1777 |
break; |
| 1778 |
} |
| 1779 |
if (LocaleCompare(attribute,"memory-limit") == 0) |
| 1780 |
{ |
| 1781 |
MagickSizeType |
| 1782 |
limit; |
| 1783 |
|
| 1784 |
limit=MagickResourceInfinity; |
| 1785 |
if (LocaleCompare(SvPV(sval,na),"unlimited") != 0) |
| 1786 |
limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na), |
| 1787 |
100.0); |
| 1788 |
(void) SetMagickResourceLimit(MemoryResource,limit); |
| 1789 |
break; |
| 1790 |
} |
| 1791 |
if (LocaleCompare(attribute,"monochrome") == 0) |
| 1792 |
{ |
| 1793 |
sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse, |
| 1794 |
SvPV(sval,na)) : SvIV(sval); |
| 1795 |
if (sp < 0) |
| 1796 |
{ |
| 1797 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 1798 |
SvPV(sval,na)); |
| 1799 |
break; |
| 1800 |
} |
| 1801 |
if (info) |
| 1802 |
info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse; |
| 1803 |
for ( ; image; image=image->next) |
| 1804 |
(void) SetImageType(image,BilevelType,exception); |
| 1805 |
break; |
| 1806 |
} |
| 1807 |
if (info) |
| 1808 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 1809 |
for ( ; image; image=image->next) |
| 1810 |
{ |
| 1811 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 1812 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 1813 |
} |
| 1814 |
break; |
| 1815 |
} |
| 1816 |
case 'O': |
| 1817 |
case 'o': |
| 1818 |
{ |
| 1819 |
if (LocaleCompare(attribute,"option") == 0) |
| 1820 |
{ |
| 1821 |
if (info) |
| 1822 |
DefineImageOption(info->image_info,SvPV(sval,na)); |
| 1823 |
break; |
| 1824 |
} |
| 1825 |
if (LocaleCompare(attribute,"orientation") == 0) |
| 1826 |
{ |
| 1827 |
sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions, |
| 1828 |
MagickFalse,SvPV(sval,na)) : SvIV(sval); |
| 1829 |
if (sp < 0) |
| 1830 |
{ |
| 1831 |
ThrowPerlException(exception,OptionError, |
| 1832 |
"UnrecognizedOrientationType",SvPV(sval,na)); |
| 1833 |
break; |
| 1834 |
} |
| 1835 |
if (info) |
| 1836 |
info->image_info->orientation=(OrientationType) sp; |
| 1837 |
for ( ; image; image=image->next) |
| 1838 |
image->orientation=(OrientationType) sp; |
| 1839 |
break; |
| 1840 |
} |
| 1841 |
if (info) |
| 1842 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 1843 |
for ( ; image; image=image->next) |
| 1844 |
{ |
| 1845 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 1846 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 1847 |
} |
| 1848 |
break; |
| 1849 |
} |
| 1850 |
case 'P': |
| 1851 |
case 'p': |
| 1852 |
{ |
| 1853 |
if (LocaleCompare(attribute,"page") == 0) |
| 1854 |
{ |
| 1855 |
char |
| 1856 |
*geometry; |
| 1857 |
|
| 1858 |
geometry=GetPageGeometry(SvPV(sval,na)); |
| 1859 |
if (info) |
| 1860 |
(void) CloneString(&info->image_info->page,geometry); |
| 1861 |
for ( ; image; image=image->next) |
| 1862 |
(void) ParsePageGeometry(image,geometry,&image->page,exception); |
| 1863 |
geometry=(char *) RelinquishMagickMemory(geometry); |
| 1864 |
break; |
| 1865 |
} |
| 1866 |
if (LocaleNCompare(attribute,"pixel",5) == 0) |
| 1867 |
{ |
| 1868 |
int |
| 1869 |
items; |
| 1870 |
|
| 1871 |
PixelInfo |
| 1872 |
pixel; |
| 1873 |
|
| 1874 |
Quantum |
| 1875 |
*q; |
| 1876 |
|
| 1877 |
CacheView |
| 1878 |
*image_view; |
| 1879 |
|
| 1880 |
for ( ; image; image=image->next) |
| 1881 |
{ |
| 1882 |
if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) |
| 1883 |
break; |
| 1884 |
x=0; |
| 1885 |
y=0; |
| 1886 |
items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y); |
| 1887 |
(void) items; |
| 1888 |
image_view=AcquireVirtualCacheView(image,exception); |
| 1889 |
q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception); |
| 1890 |
if (q != (Quantum *) NULL) |
| 1891 |
{ |
| 1892 |
if ((strchr(SvPV(sval,na),',') == 0) || |
| 1893 |
(strchr(SvPV(sval,na),')') != 0)) |
| 1894 |
QueryColorCompliance(SvPV(sval,na),AllCompliance, |
| 1895 |
&pixel,exception); |
| 1896 |
else |
| 1897 |
{ |
| 1898 |
GetPixelInfo(image,&pixel); |
| 1899 |
flags=ParseGeometry(SvPV(sval,na),&geometry_info); |
| 1900 |
pixel.red=geometry_info.rho; |
| 1901 |
if ((flags & SigmaValue) != 0) |
| 1902 |
pixel.green=geometry_info.sigma; |
| 1903 |
if ((flags & XiValue) != 0) |
| 1904 |
pixel.blue=geometry_info.xi; |
| 1905 |
if ((flags & PsiValue) != 0) |
| 1906 |
pixel.alpha=geometry_info.psi; |
| 1907 |
if ((flags & ChiValue) != 0) |
| 1908 |
pixel.black=geometry_info.chi; |
| 1909 |
} |
| 1910 |
SetPixelRed(image,ClampToQuantum(pixel.red),q); |
| 1911 |
SetPixelGreen(image,ClampToQuantum(pixel.green),q); |
| 1912 |
SetPixelBlue(image,ClampToQuantum(pixel.blue),q); |
| 1913 |
if (image->colorspace == CMYKColorspace) |
| 1914 |
SetPixelBlack(image,ClampToQuantum(pixel.black),q); |
| 1915 |
SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q); |
| 1916 |
(void) SyncCacheViewAuthenticPixels(image_view,exception); |
| 1917 |
} |
| 1918 |
image_view=DestroyCacheView(image_view); |
| 1919 |
} |
| 1920 |
break; |
| 1921 |
} |
| 1922 |
if (LocaleCompare(attribute,"pointsize") == 0) |
| 1923 |
{ |
| 1924 |
if (info) |
| 1925 |
{ |
| 1926 |
(void) ParseGeometry(SvPV(sval,na),&geometry_info); |
| 1927 |
info->image_info->pointsize=geometry_info.rho; |
| 1928 |
} |
| 1929 |
break; |
| 1930 |
} |
| 1931 |
if (LocaleCompare(attribute,"precision") == 0) |
| 1932 |
{ |
| 1933 |
(void) SetMagickPrecision(SvIV(sval)); |
| 1934 |
break; |
| 1935 |
} |
| 1936 |
if (info) |
| 1937 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 1938 |
for ( ; image; image=image->next) |
| 1939 |
{ |
| 1940 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 1941 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 1942 |
} |
| 1943 |
break; |
| 1944 |
} |
| 1945 |
case 'Q': |
| 1946 |
case 'q': |
| 1947 |
{ |
| 1948 |
if (LocaleCompare(attribute,"quality") == 0) |
| 1949 |
{ |
| 1950 |
if (info) |
| 1951 |
info->image_info->quality=(size_t) SvIV(sval); |
| 1952 |
for ( ; image; image=image->next) |
| 1953 |
image->quality=(size_t) SvIV(sval); |
| 1954 |
break; |
| 1955 |
} |
| 1956 |
if (info) |
| 1957 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 1958 |
for ( ; image; image=image->next) |
| 1959 |
{ |
| 1960 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 1961 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 1962 |
} |
| 1963 |
break; |
| 1964 |
} |
| 1965 |
case 'R': |
| 1966 |
case 'r': |
| 1967 |
{ |
| 1968 |
if (LocaleCompare(attribute,"read-mask") == 0) |
| 1969 |
{ |
| 1970 |
Image |
| 1971 |
*mask; |
| 1972 |
|
| 1973 |
mask=(Image *) NULL; |
| 1974 |
if (SvPOK(sval)) |
| 1975 |
mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception); |
| 1976 |
for ( ; image; image=image->next) |
| 1977 |
SetImageMask(image,ReadPixelMask,mask,exception); |
| 1978 |
break; |
| 1979 |
} |
| 1980 |
if (LocaleCompare(attribute,"red-primary") == 0) |
| 1981 |
{ |
| 1982 |
for ( ; image; image=image->next) |
| 1983 |
{ |
| 1984 |
flags=ParseGeometry(SvPV(sval,na),&geometry_info); |
| 1985 |
image->chromaticity.red_primary.x=geometry_info.rho; |
| 1986 |
image->chromaticity.red_primary.y=geometry_info.sigma; |
| 1987 |
if ((flags & SigmaValue) == 0) |
| 1988 |
image->chromaticity.red_primary.y= |
| 1989 |
image->chromaticity.red_primary.x; |
| 1990 |
} |
| 1991 |
break; |
| 1992 |
} |
| 1993 |
if (LocaleNCompare(attribute,"registry:",9) == 0) |
| 1994 |
{ |
| 1995 |
(void) SetImageRegistry(StringRegistryType,attribute+9,SvPV(sval,na), |
| 1996 |
exception); |
| 1997 |
break; |
| 1998 |
} |
| 1999 |
if (LocaleCompare(attribute,"render") == 0) |
| 2000 |
{ |
| 2001 |
sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse, |
| 2002 |
SvPV(sval,na)) : SvIV(sval); |
| 2003 |
if (sp < 0) |
| 2004 |
{ |
| 2005 |
ThrowPerlException(exception,OptionError,"UnrecognizedIntentType", |
| 2006 |
SvPV(sval,na)); |
| 2007 |
break; |
| 2008 |
} |
| 2009 |
for ( ; image; image=image->next) |
| 2010 |
image->rendering_intent=(RenderingIntent) sp; |
| 2011 |
break; |
| 2012 |
} |
| 2013 |
if (LocaleCompare(attribute,"repage") == 0) |
| 2014 |
{ |
| 2015 |
RectangleInfo |
| 2016 |
geometry; |
| 2017 |
|
| 2018 |
for ( ; image; image=image->next) |
| 2019 |
{ |
| 2020 |
flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry); |
| 2021 |
if ((flags & WidthValue) != 0) |
| 2022 |
{ |
| 2023 |
if ((flags & HeightValue) == 0) |
| 2024 |
geometry.height=geometry.width; |
| 2025 |
image->page.width=geometry.width; |
| 2026 |
image->page.height=geometry.height; |
| 2027 |
} |
| 2028 |
if ((flags & AspectValue) != 0) |
| 2029 |
{ |
| 2030 |
if ((flags & XValue) != 0) |
| 2031 |
image->page.x+=geometry.x; |
| 2032 |
if ((flags & YValue) != 0) |
| 2033 |
image->page.y+=geometry.y; |
| 2034 |
} |
| 2035 |
else |
| 2036 |
{ |
| 2037 |
if ((flags & XValue) != 0) |
| 2038 |
{ |
| 2039 |
image->page.x=geometry.x; |
| 2040 |
if (((flags & WidthValue) != 0) && (geometry.x > 0)) |
| 2041 |
image->page.width=(size_t) ((ssize_t) image->columns+ |
| 2042 |
geometry.x); |
| 2043 |
} |
| 2044 |
if ((flags & YValue) != 0) |
| 2045 |
{ |
| 2046 |
image->page.y=geometry.y; |
| 2047 |
if (((flags & HeightValue) != 0) && (geometry.y > 0)) |
| 2048 |
image->page.height=(size_t) ((ssize_t) image->rows+ |
| 2049 |
geometry.y); |
| 2050 |
} |
| 2051 |
} |
| 2052 |
} |
| 2053 |
break; |
| 2054 |
} |
| 2055 |
if (info) |
| 2056 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 2057 |
for ( ; image; image=image->next) |
| 2058 |
{ |
| 2059 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 2060 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 2061 |
} |
| 2062 |
break; |
| 2063 |
} |
| 2064 |
case 'S': |
| 2065 |
case 's': |
| 2066 |
{ |
| 2067 |
if (LocaleCompare(attribute,"sampling-factor") == 0) |
| 2068 |
{ |
| 2069 |
if (IsGeometry(SvPV(sval,na)) == MagickFalse) |
| 2070 |
{ |
| 2071 |
ThrowPerlException(exception,OptionError,"MissingGeometry", |
| 2072 |
SvPV(sval,na)); |
| 2073 |
break; |
| 2074 |
} |
| 2075 |
if (info) |
| 2076 |
(void) CloneString(&info->image_info->sampling_factor, |
| 2077 |
SvPV(sval,na)); |
| 2078 |
break; |
| 2079 |
} |
| 2080 |
if (LocaleCompare(attribute,"scene") == 0) |
| 2081 |
{ |
| 2082 |
for ( ; image; image=image->next) |
| 2083 |
image->scene=(size_t) SvIV(sval); |
| 2084 |
break; |
| 2085 |
} |
| 2086 |
if (LocaleCompare(attribute,"server") == 0) |
| 2087 |
goto display; |
| 2088 |
if (LocaleCompare(attribute,"size") == 0) |
| 2089 |
{ |
| 2090 |
if (info) |
| 2091 |
{ |
| 2092 |
if (IsGeometry(SvPV(sval,na)) == MagickFalse) |
| 2093 |
{ |
| 2094 |
ThrowPerlException(exception,OptionError,"MissingGeometry", |
| 2095 |
SvPV(sval,na)); |
| 2096 |
break; |
| 2097 |
} |
| 2098 |
(void) CloneString(&info->image_info->size,SvPV(sval,na)); |
| 2099 |
} |
| 2100 |
break; |
| 2101 |
} |
| 2102 |
if (LocaleCompare(attribute,"stroke") == 0) |
| 2103 |
{ |
| 2104 |
if (info) |
| 2105 |
(void) SetImageOption(info->image_info,"stroke",SvPV(sval,na)); |
| 2106 |
break; |
| 2107 |
} |
| 2108 |
if (info) |
| 2109 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 2110 |
for ( ; image; image=image->next) |
| 2111 |
{ |
| 2112 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 2113 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 2114 |
} |
| 2115 |
break; |
| 2116 |
} |
| 2117 |
case 'T': |
| 2118 |
case 't': |
| 2119 |
{ |
| 2120 |
if (LocaleCompare(attribute,"texture") == 0) |
| 2121 |
{ |
| 2122 |
if (info) |
| 2123 |
(void) CloneString(&info->image_info->texture,SvPV(sval,na)); |
| 2124 |
break; |
| 2125 |
} |
| 2126 |
if (LocaleCompare(attribute,"thread-limit") == 0) |
| 2127 |
{ |
| 2128 |
MagickSizeType |
| 2129 |
limit; |
| 2130 |
|
| 2131 |
limit=MagickResourceInfinity; |
| 2132 |
if (LocaleCompare(SvPV(sval,na),"unlimited") != 0) |
| 2133 |
limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na), |
| 2134 |
100.0); |
| 2135 |
(void) SetMagickResourceLimit(ThreadResource,limit); |
| 2136 |
break; |
| 2137 |
} |
| 2138 |
if (LocaleCompare(attribute,"tile-offset") == 0) |
| 2139 |
{ |
| 2140 |
char |
| 2141 |
*geometry; |
| 2142 |
|
| 2143 |
geometry=GetPageGeometry(SvPV(sval,na)); |
| 2144 |
if (info) |
| 2145 |
(void) CloneString(&info->image_info->page,geometry); |
| 2146 |
for ( ; image; image=image->next) |
| 2147 |
(void) ParsePageGeometry(image,geometry,&image->tile_offset, |
| 2148 |
exception); |
| 2149 |
geometry=(char *) RelinquishMagickMemory(geometry); |
| 2150 |
break; |
| 2151 |
} |
| 2152 |
if (LocaleCompare(attribute,"time-limit") == 0) |
| 2153 |
{ |
| 2154 |
MagickSizeType |
| 2155 |
limit; |
| 2156 |
|
| 2157 |
limit=MagickResourceInfinity; |
| 2158 |
if (LocaleCompare(SvPV(sval,na),"unlimited") != 0) |
| 2159 |
limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na), |
| 2160 |
100.0); |
| 2161 |
(void) SetMagickResourceLimit(TimeResource,limit); |
| 2162 |
break; |
| 2163 |
} |
| 2164 |
if (LocaleCompare(attribute,"title") == 0) |
| 2165 |
{ |
| 2166 |
for ( ; image; image=image->next) |
| 2167 |
(void) CopyMagickString(image->magick_filename,SvPV(sval,na), |
| 2168 |
MaxTextExtent); |
| 2169 |
break; |
| 2170 |
} |
| 2171 |
if (LocaleCompare(attribute,"transparent-color") == 0) |
| 2172 |
{ |
| 2173 |
(void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color, |
| 2174 |
exception); |
| 2175 |
if (info) |
| 2176 |
info->image_info->transparent_color=target_color; |
| 2177 |
for ( ; image; image=image->next) |
| 2178 |
image->transparent_color=target_color; |
| 2179 |
break; |
| 2180 |
} |
| 2181 |
if (LocaleCompare(attribute,"type") == 0) |
| 2182 |
{ |
| 2183 |
sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 2184 |
SvPV(sval,na)) : SvIV(sval); |
| 2185 |
if (sp < 0) |
| 2186 |
{ |
| 2187 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 2188 |
SvPV(sval,na)); |
| 2189 |
break; |
| 2190 |
} |
| 2191 |
if (info) |
| 2192 |
info->image_info->type=(ImageType) sp; |
| 2193 |
for ( ; image; image=image->next) |
| 2194 |
SetImageType(image,(ImageType) sp,exception); |
| 2195 |
break; |
| 2196 |
} |
| 2197 |
if (info) |
| 2198 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 2199 |
for ( ; image; image=image->next) |
| 2200 |
{ |
| 2201 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 2202 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 2203 |
} |
| 2204 |
break; |
| 2205 |
} |
| 2206 |
case 'U': |
| 2207 |
case 'u': |
| 2208 |
{ |
| 2209 |
if (LocaleCompare(attribute,"units") == 0) |
| 2210 |
{ |
| 2211 |
sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions, |
| 2212 |
MagickFalse,SvPV(sval,na)) : SvIV(sval); |
| 2213 |
if (sp < 0) |
| 2214 |
{ |
| 2215 |
ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType", |
| 2216 |
SvPV(sval,na)); |
| 2217 |
break; |
| 2218 |
} |
| 2219 |
if (info) |
| 2220 |
info->image_info->units=(ResolutionType) sp; |
| 2221 |
for ( ; image; image=image->next) |
| 2222 |
{ |
| 2223 |
ResolutionType |
| 2224 |
units; |
| 2225 |
|
| 2226 |
units=(ResolutionType) sp; |
| 2227 |
if (image->units != units) |
| 2228 |
switch (image->units) |
| 2229 |
{ |
| 2230 |
case UndefinedResolution: |
| 2231 |
case PixelsPerInchResolution: |
| 2232 |
{ |
| 2233 |
if (units == PixelsPerCentimeterResolution) |
| 2234 |
{ |
| 2235 |
image->resolution.x*=2.54; |
| 2236 |
image->resolution.y*=2.54; |
| 2237 |
} |
| 2238 |
break; |
| 2239 |
} |
| 2240 |
case PixelsPerCentimeterResolution: |
| 2241 |
{ |
| 2242 |
if (units == PixelsPerInchResolution) |
| 2243 |
{ |
| 2244 |
image->resolution.x/=2.54; |
| 2245 |
image->resolution.y/=2.54; |
| 2246 |
} |
| 2247 |
break; |
| 2248 |
} |
| 2249 |
} |
| 2250 |
image->units=units; |
| 2251 |
} |
| 2252 |
break; |
| 2253 |
} |
| 2254 |
if (info) |
| 2255 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 2256 |
for ( ; image; image=image->next) |
| 2257 |
{ |
| 2258 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 2259 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 2260 |
} |
| 2261 |
break; |
| 2262 |
} |
| 2263 |
case 'V': |
| 2264 |
case 'v': |
| 2265 |
{ |
| 2266 |
if (LocaleCompare(attribute,"verbose") == 0) |
| 2267 |
{ |
| 2268 |
sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse, |
| 2269 |
SvPV(sval,na)) : SvIV(sval); |
| 2270 |
if (sp < 0) |
| 2271 |
{ |
| 2272 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 2273 |
SvPV(sval,na)); |
| 2274 |
break; |
| 2275 |
} |
| 2276 |
if (info) |
| 2277 |
info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse; |
| 2278 |
break; |
| 2279 |
} |
| 2280 |
if (LocaleCompare(attribute,"virtual-pixel") == 0) |
| 2281 |
{ |
| 2282 |
sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions, |
| 2283 |
MagickFalse,SvPV(sval,na)) : SvIV(sval); |
| 2284 |
if (sp < 0) |
| 2285 |
{ |
| 2286 |
ThrowPerlException(exception,OptionError, |
| 2287 |
"UnrecognizedVirtualPixelMethod",SvPV(sval,na)); |
| 2288 |
break; |
| 2289 |
} |
| 2290 |
for ( ; image; image=image->next) |
| 2291 |
SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp,exception); |
| 2292 |
break; |
| 2293 |
} |
| 2294 |
if (info) |
| 2295 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 2296 |
for ( ; image; image=image->next) |
| 2297 |
{ |
| 2298 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 2299 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 2300 |
} |
| 2301 |
break; |
| 2302 |
} |
| 2303 |
case 'W': |
| 2304 |
case 'w': |
| 2305 |
{ |
| 2306 |
if (LocaleCompare(attribute,"white-point") == 0) |
| 2307 |
{ |
| 2308 |
for ( ; image; image=image->next) |
| 2309 |
{ |
| 2310 |
flags=ParseGeometry(SvPV(sval,na),&geometry_info); |
| 2311 |
image->chromaticity.white_point.x=geometry_info.rho; |
| 2312 |
image->chromaticity.white_point.y=geometry_info.sigma; |
| 2313 |
if ((flags & SigmaValue) == 0) |
| 2314 |
image->chromaticity.white_point.y= |
| 2315 |
image->chromaticity.white_point.x; |
| 2316 |
} |
| 2317 |
break; |
| 2318 |
} |
| 2319 |
if (LocaleCompare(attribute,"write-mask") == 0) |
| 2320 |
{ |
| 2321 |
Image |
| 2322 |
*mask; |
| 2323 |
|
| 2324 |
mask=(Image *) NULL; |
| 2325 |
if (SvPOK(sval)) |
| 2326 |
mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception); |
| 2327 |
for ( ; image; image=image->next) |
| 2328 |
SetImageMask(image,WritePixelMask,mask,exception); |
| 2329 |
break; |
| 2330 |
} |
| 2331 |
if (info) |
| 2332 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 2333 |
for ( ; image; image=image->next) |
| 2334 |
{ |
| 2335 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 2336 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 2337 |
} |
| 2338 |
break; |
| 2339 |
} |
| 2340 |
default: |
| 2341 |
{ |
| 2342 |
if (info) |
| 2343 |
SetImageOption(info->image_info,attribute,SvPV(sval,na)); |
| 2344 |
for ( ; image; image=image->next) |
| 2345 |
{ |
| 2346 |
(void) SetImageProperty(image,attribute,SvPV(sval,na),exception); |
| 2347 |
(void) SetImageArtifact(image,attribute,SvPV(sval,na)); |
| 2348 |
} |
| 2349 |
break; |
| 2350 |
} |
| 2351 |
} |
| 2352 |
} |
| 2353 |
|
| 2354 |
/* |
| 2355 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2356 |
% % |
| 2357 |
% % |
| 2358 |
% % |
| 2359 |
% S e t u p L i s t % |
| 2360 |
% % |
| 2361 |
% % |
| 2362 |
% % |
| 2363 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2364 |
% |
| 2365 |
% Method SetupList returns the list of all the images linked by their |
| 2366 |
% image->next and image->previous link lists for use with ImageMagick. If |
| 2367 |
% info is non-NULL, an info structure is returned in *info. If |
| 2368 |
% reference_vector is non-NULL,an array of SV* are returned in |
| 2369 |
% *reference_vector. Reference_vector is used when the images are going to be |
| 2370 |
% replaced with new Image*'s. |
| 2371 |
% |
| 2372 |
% The format of the SetupList routine is: |
| 2373 |
% |
| 2374 |
% Image *SetupList(SV *reference,struct PackageInfo **info, |
| 2375 |
% SV ***reference_vector,ExceptionInfo *exception) |
| 2376 |
% |
| 2377 |
% A description of each parameter follows: |
| 2378 |
% |
| 2379 |
% o list: a list of strings. |
| 2380 |
% |
| 2381 |
% o string: a character string. |
| 2382 |
% |
| 2383 |
% o exception: Return any errors or warnings in this structure. |
| 2384 |
% |
| 2385 |
*/ |
| 2386 |
static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info, |
| 2387 |
SV ***reference_vector,ExceptionInfo *exception) |
| 2388 |
{ |
| 2389 |
Image |
| 2390 |
*image; |
| 2391 |
|
| 2392 |
ssize_t |
| 2393 |
current, |
| 2394 |
last; |
| 2395 |
|
| 2396 |
if (reference_vector) |
| 2397 |
*reference_vector=NULL; |
| 2398 |
if (info) |
| 2399 |
*info=NULL; |
| 2400 |
current=0; |
| 2401 |
last=0; |
| 2402 |
image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception); |
| 2403 |
if (info && (SvTYPE(reference) == SVt_PVAV)) |
| 2404 |
*info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL, |
| 2405 |
exception); |
| 2406 |
return(image); |
| 2407 |
} |
| 2408 |
|
| 2409 |
/* |
| 2410 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2411 |
% % |
| 2412 |
% % |
| 2413 |
% % |
| 2414 |
% s t r E Q c a s e % |
| 2415 |
% % |
| 2416 |
% % |
| 2417 |
% % |
| 2418 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2419 |
% |
| 2420 |
% strEQcase() compares two strings and returns 0 if they are the |
| 2421 |
% same or if the second string runs out first. The comparison is case |
| 2422 |
% insensitive. |
| 2423 |
% |
| 2424 |
% The format of the strEQcase routine is: |
| 2425 |
% |
| 2426 |
% ssize_t strEQcase(const char *p,const char *q) |
| 2427 |
% |
| 2428 |
% A description of each parameter follows: |
| 2429 |
% |
| 2430 |
% o p: a character string. |
| 2431 |
% |
| 2432 |
% o q: a character string. |
| 2433 |
% |
| 2434 |
% |
| 2435 |
*/ |
| 2436 |
static ssize_t strEQcase(const char *p,const char *q) |
| 2437 |
{ |
| 2438 |
char |
| 2439 |
c; |
| 2440 |
|
| 2441 |
ssize_t |
| 2442 |
i; |
| 2443 |
|
| 2444 |
for (i=0 ; (c=(*q)) != 0; i++) |
| 2445 |
{ |
| 2446 |
if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) != |
| 2447 |
(isUPPER((unsigned char) *p) ? toLOWER(*p) : *p)) |
| 2448 |
return(0); |
| 2449 |
p++; |
| 2450 |
q++; |
| 2451 |
} |
| 2452 |
return(((*q == 0) && (*p == 0)) ? i : 0); |
| 2453 |
} |
| 2454 |
|
| 2455 |
/* |
| 2456 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2457 |
% % |
| 2458 |
% % |
| 2459 |
% % |
| 2460 |
% I m a g e : : M a g i c k % |
| 2461 |
% % |
| 2462 |
% % |
| 2463 |
% % |
| 2464 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2465 |
% |
| 2466 |
% |
| 2467 |
*/ |
| 2468 |
MODULE = Image::Magick::Q16HDRI PACKAGE = Image::Magick::Q16HDRI |
| 2469 |
|
| 2470 |
PROTOTYPES: ENABLE |
| 2471 |
|
| 2472 |
BOOT: |
| 2473 |
MagickCoreGenesis("PerlMagick",MagickFalse); |
| 2474 |
SetWarningHandler(NULL); |
| 2475 |
SetErrorHandler(NULL); |
| 2476 |
magick_registry=NewSplayTree((int (*)(const void *,const void *)) |
| 2477 |
NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL); |
| 2478 |
|
| 2479 |
void |
| 2480 |
UNLOAD() |
| 2481 |
PPCODE: |
| 2482 |
{ |
| 2483 |
if (magick_registry != (SplayTreeInfo *) NULL) |
| 2484 |
magick_registry=DestroySplayTree(magick_registry); |
| 2485 |
MagickCoreTerminus(); |
| 2486 |
} |
| 2487 |
|
| 2488 |
double |
| 2489 |
constant(name,argument) |
| 2490 |
char *name |
| 2491 |
ssize_t argument |
| 2492 |
|
| 2493 |
# |
| 2494 |
############################################################################### |
| 2495 |
# # |
| 2496 |
# # |
| 2497 |
# # |
| 2498 |
# A n i m a t e # |
| 2499 |
# # |
| 2500 |
# # |
| 2501 |
# # |
| 2502 |
############################################################################### |
| 2503 |
# |
| 2504 |
# |
| 2505 |
void |
| 2506 |
Animate(ref,...) |
| 2507 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 2508 |
ALIAS: |
| 2509 |
AnimateImage = 1 |
| 2510 |
animate = 2 |
| 2511 |
animateimage = 3 |
| 2512 |
PPCODE: |
| 2513 |
{ |
| 2514 |
ExceptionInfo |
| 2515 |
*exception; |
| 2516 |
|
| 2517 |
Image |
| 2518 |
*image; |
| 2519 |
|
| 2520 |
ssize_t |
| 2521 |
i; |
| 2522 |
|
| 2523 |
struct PackageInfo |
| 2524 |
*info, |
| 2525 |
*package_info; |
| 2526 |
|
| 2527 |
SV |
| 2528 |
*perl_exception, |
| 2529 |
*reference; |
| 2530 |
|
| 2531 |
PERL_UNUSED_VAR(ref); |
| 2532 |
PERL_UNUSED_VAR(ix); |
| 2533 |
exception=AcquireExceptionInfo(); |
| 2534 |
perl_exception=newSVpv("",0); |
| 2535 |
package_info=(struct PackageInfo *) NULL; |
| 2536 |
if (sv_isobject(ST(0)) == 0) |
| 2537 |
{ |
| 2538 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 2539 |
PackageName); |
| 2540 |
goto PerlException; |
| 2541 |
} |
| 2542 |
reference=SvRV(ST(0)); |
| 2543 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 2544 |
if (image == (Image *) NULL) |
| 2545 |
{ |
| 2546 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 2547 |
PackageName); |
| 2548 |
goto PerlException; |
| 2549 |
} |
| 2550 |
package_info=ClonePackageInfo(info,exception); |
| 2551 |
if (items == 2) |
| 2552 |
SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception); |
| 2553 |
else |
| 2554 |
if (items > 2) |
| 2555 |
for (i=2; i < items; i+=2) |
| 2556 |
SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i), |
| 2557 |
exception); |
| 2558 |
(void) AnimateImages(package_info->image_info,image,exception); |
| 2559 |
(void) CatchImageException(image); |
| 2560 |
|
| 2561 |
PerlException: |
| 2562 |
if (package_info != (struct PackageInfo *) NULL) |
| 2563 |
DestroyPackageInfo(package_info); |
| 2564 |
InheritPerlException(exception,perl_exception); |
| 2565 |
exception=DestroyExceptionInfo(exception); |
| 2566 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 2567 |
SvPOK_on(perl_exception); |
| 2568 |
ST(0)=sv_2mortal(perl_exception); |
| 2569 |
XSRETURN(1); |
| 2570 |
} |
| 2571 |
|
| 2572 |
# |
| 2573 |
############################################################################### |
| 2574 |
# # |
| 2575 |
# # |
| 2576 |
# # |
| 2577 |
# A p p e n d # |
| 2578 |
# # |
| 2579 |
# # |
| 2580 |
# # |
| 2581 |
############################################################################### |
| 2582 |
# |
| 2583 |
# |
| 2584 |
void |
| 2585 |
Append(ref,...) |
| 2586 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 2587 |
ALIAS: |
| 2588 |
AppendImage = 1 |
| 2589 |
append = 2 |
| 2590 |
appendimage = 3 |
| 2591 |
PPCODE: |
| 2592 |
{ |
| 2593 |
AV |
| 2594 |
*av; |
| 2595 |
|
| 2596 |
char |
| 2597 |
*attribute; |
| 2598 |
|
| 2599 |
ExceptionInfo |
| 2600 |
*exception; |
| 2601 |
|
| 2602 |
HV |
| 2603 |
*hv; |
| 2604 |
|
| 2605 |
Image |
| 2606 |
*image; |
| 2607 |
|
| 2608 |
ssize_t |
| 2609 |
i, |
| 2610 |
stack; |
| 2611 |
|
| 2612 |
struct PackageInfo |
| 2613 |
*info; |
| 2614 |
|
| 2615 |
SV |
| 2616 |
*av_reference, |
| 2617 |
*perl_exception, |
| 2618 |
*reference, |
| 2619 |
*rv, |
| 2620 |
*sv; |
| 2621 |
|
| 2622 |
PERL_UNUSED_VAR(ref); |
| 2623 |
PERL_UNUSED_VAR(ix); |
| 2624 |
exception=AcquireExceptionInfo(); |
| 2625 |
perl_exception=newSVpv("",0); |
| 2626 |
sv=NULL; |
| 2627 |
attribute=NULL; |
| 2628 |
av=NULL; |
| 2629 |
if (sv_isobject(ST(0)) == 0) |
| 2630 |
{ |
| 2631 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 2632 |
PackageName); |
| 2633 |
goto PerlException; |
| 2634 |
} |
| 2635 |
reference=SvRV(ST(0)); |
| 2636 |
hv=SvSTASH(reference); |
| 2637 |
av=newAV(); |
| 2638 |
av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv)); |
| 2639 |
SvREFCNT_dec(av); |
| 2640 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 2641 |
if (image == (Image *) NULL) |
| 2642 |
{ |
| 2643 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 2644 |
PackageName); |
| 2645 |
goto PerlException; |
| 2646 |
} |
| 2647 |
info=GetPackageInfo(aTHX_ (void *) av,info,exception); |
| 2648 |
/* |
| 2649 |
Get options. |
| 2650 |
*/ |
| 2651 |
stack=MagickTrue; |
| 2652 |
for (i=2; i < items; i+=2) |
| 2653 |
{ |
| 2654 |
attribute=(char *) SvPV(ST(i-1),na); |
| 2655 |
switch (*attribute) |
| 2656 |
{ |
| 2657 |
case 'S': |
| 2658 |
case 's': |
| 2659 |
{ |
| 2660 |
if (LocaleCompare(attribute,"stack") == 0) |
| 2661 |
{ |
| 2662 |
stack=ParseCommandOption(MagickBooleanOptions,MagickFalse, |
| 2663 |
SvPV(ST(i),na)); |
| 2664 |
if (stack < 0) |
| 2665 |
{ |
| 2666 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 2667 |
SvPV(ST(i),na)); |
| 2668 |
return; |
| 2669 |
} |
| 2670 |
break; |
| 2671 |
} |
| 2672 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 2673 |
attribute); |
| 2674 |
break; |
| 2675 |
} |
| 2676 |
default: |
| 2677 |
{ |
| 2678 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 2679 |
attribute); |
| 2680 |
break; |
| 2681 |
} |
| 2682 |
} |
| 2683 |
} |
| 2684 |
image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception); |
| 2685 |
if (image == (Image *) NULL) |
| 2686 |
goto PerlException; |
| 2687 |
for ( ; image; image=image->next) |
| 2688 |
{ |
| 2689 |
AddImageToRegistry(sv,image); |
| 2690 |
rv=newRV(sv); |
| 2691 |
av_push(av,sv_bless(rv,hv)); |
| 2692 |
SvREFCNT_dec(sv); |
| 2693 |
} |
| 2694 |
exception=DestroyExceptionInfo(exception); |
| 2695 |
ST(0)=av_reference; |
| 2696 |
SvREFCNT_dec(perl_exception); |
| 2697 |
XSRETURN(1); |
| 2698 |
|
| 2699 |
PerlException: |
| 2700 |
InheritPerlException(exception,perl_exception); |
| 2701 |
exception=DestroyExceptionInfo(exception); |
| 2702 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 2703 |
SvPOK_on(perl_exception); |
| 2704 |
ST(0)=sv_2mortal(perl_exception); |
| 2705 |
XSRETURN(1); |
| 2706 |
} |
| 2707 |
|
| 2708 |
# |
| 2709 |
############################################################################### |
| 2710 |
# # |
| 2711 |
# # |
| 2712 |
# # |
| 2713 |
# A v e r a g e # |
| 2714 |
# # |
| 2715 |
# # |
| 2716 |
# # |
| 2717 |
############################################################################### |
| 2718 |
# |
| 2719 |
# |
| 2720 |
void |
| 2721 |
Average(ref) |
| 2722 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 2723 |
ALIAS: |
| 2724 |
AverageImage = 1 |
| 2725 |
average = 2 |
| 2726 |
averageimage = 3 |
| 2727 |
PPCODE: |
| 2728 |
{ |
| 2729 |
AV |
| 2730 |
*av; |
| 2731 |
|
| 2732 |
char |
| 2733 |
*p; |
| 2734 |
|
| 2735 |
ExceptionInfo |
| 2736 |
*exception; |
| 2737 |
|
| 2738 |
HV |
| 2739 |
*hv; |
| 2740 |
|
| 2741 |
Image |
| 2742 |
*image; |
| 2743 |
|
| 2744 |
struct PackageInfo |
| 2745 |
*info; |
| 2746 |
|
| 2747 |
SV |
| 2748 |
*perl_exception, |
| 2749 |
*reference, |
| 2750 |
*rv, |
| 2751 |
*sv; |
| 2752 |
|
| 2753 |
PERL_UNUSED_VAR(ref); |
| 2754 |
PERL_UNUSED_VAR(ix); |
| 2755 |
exception=AcquireExceptionInfo(); |
| 2756 |
perl_exception=newSVpv("",0); |
| 2757 |
sv=NULL; |
| 2758 |
if (sv_isobject(ST(0)) == 0) |
| 2759 |
{ |
| 2760 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 2761 |
PackageName); |
| 2762 |
goto PerlException; |
| 2763 |
} |
| 2764 |
reference=SvRV(ST(0)); |
| 2765 |
hv=SvSTASH(reference); |
| 2766 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 2767 |
if (image == (Image *) NULL) |
| 2768 |
{ |
| 2769 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 2770 |
PackageName); |
| 2771 |
goto PerlException; |
| 2772 |
} |
| 2773 |
image=EvaluateImages(image,MeanEvaluateOperator,exception); |
| 2774 |
if (image == (Image *) NULL) |
| 2775 |
goto PerlException; |
| 2776 |
/* |
| 2777 |
Create blessed Perl array for the returned image. |
| 2778 |
*/ |
| 2779 |
av=newAV(); |
| 2780 |
ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv)); |
| 2781 |
SvREFCNT_dec(av); |
| 2782 |
AddImageToRegistry(sv,image); |
| 2783 |
rv=newRV(sv); |
| 2784 |
av_push(av,sv_bless(rv,hv)); |
| 2785 |
SvREFCNT_dec(sv); |
| 2786 |
info=GetPackageInfo(aTHX_ (void *) av,info,exception); |
| 2787 |
(void) FormatLocaleString(info->image_info->filename,MagickPathExtent, |
| 2788 |
"average-%.*s",(int) (MagickPathExtent-9), |
| 2789 |
((p=strrchr(image->filename,'/')) ? p+1 : image->filename)); |
| 2790 |
(void) CopyMagickString(image->filename,info->image_info->filename, |
| 2791 |
MagickPathExtent); |
| 2792 |
SetImageInfo(info->image_info,0,exception); |
| 2793 |
exception=DestroyExceptionInfo(exception); |
| 2794 |
SvREFCNT_dec(perl_exception); |
| 2795 |
XSRETURN(1); |
| 2796 |
|
| 2797 |
PerlException: |
| 2798 |
InheritPerlException(exception,perl_exception); |
| 2799 |
exception=DestroyExceptionInfo(exception); |
| 2800 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 2801 |
SvPOK_on(perl_exception); |
| 2802 |
ST(0)=sv_2mortal(perl_exception); |
| 2803 |
XSRETURN(1); |
| 2804 |
} |
| 2805 |
|
| 2806 |
# |
| 2807 |
############################################################################### |
| 2808 |
# # |
| 2809 |
# # |
| 2810 |
# # |
| 2811 |
# B l o b T o I m a g e # |
| 2812 |
# # |
| 2813 |
# # |
| 2814 |
# # |
| 2815 |
############################################################################### |
| 2816 |
# |
| 2817 |
# |
| 2818 |
void |
| 2819 |
BlobToImage(ref,...) |
| 2820 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 2821 |
ALIAS: |
| 2822 |
BlobToImage = 1 |
| 2823 |
blobtoimage = 2 |
| 2824 |
blobto = 3 |
| 2825 |
PPCODE: |
| 2826 |
{ |
| 2827 |
AV |
| 2828 |
*av; |
| 2829 |
|
| 2830 |
char |
| 2831 |
**keep, |
| 2832 |
**list; |
| 2833 |
|
| 2834 |
ExceptionInfo |
| 2835 |
*exception; |
| 2836 |
|
| 2837 |
HV |
| 2838 |
*hv; |
| 2839 |
|
| 2840 |
Image |
| 2841 |
*image; |
| 2842 |
|
| 2843 |
char |
| 2844 |
**p; |
| 2845 |
|
| 2846 |
ssize_t |
| 2847 |
ac, |
| 2848 |
i, |
| 2849 |
n, |
| 2850 |
number_images; |
| 2851 |
|
| 2852 |
STRLEN |
| 2853 |
*length; |
| 2854 |
|
| 2855 |
struct PackageInfo |
| 2856 |
*info; |
| 2857 |
|
| 2858 |
SV |
| 2859 |
*perl_exception, |
| 2860 |
*reference, |
| 2861 |
*rv, |
| 2862 |
*sv; |
| 2863 |
|
| 2864 |
PERL_UNUSED_VAR(ref); |
| 2865 |
PERL_UNUSED_VAR(ix); |
| 2866 |
exception=AcquireExceptionInfo(); |
| 2867 |
perl_exception=newSVpv("",0); |
| 2868 |
sv=NULL; |
| 2869 |
number_images=0; |
| 2870 |
ac=(items < 2) ? 1 : items-1; |
| 2871 |
length=(STRLEN *) NULL; |
| 2872 |
list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list)); |
| 2873 |
if (list == (char **) NULL) |
| 2874 |
{ |
| 2875 |
ThrowPerlException(exception,ResourceLimitError, |
| 2876 |
"MemoryAllocationFailed",PackageName); |
| 2877 |
goto PerlException; |
| 2878 |
} |
| 2879 |
length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length)); |
| 2880 |
if (length == (STRLEN *) NULL) |
| 2881 |
{ |
| 2882 |
ThrowPerlException(exception,ResourceLimitError, |
| 2883 |
"MemoryAllocationFailed",PackageName); |
| 2884 |
goto PerlException; |
| 2885 |
} |
| 2886 |
if (sv_isobject(ST(0)) == 0) |
| 2887 |
{ |
| 2888 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 2889 |
PackageName); |
| 2890 |
goto PerlException; |
| 2891 |
} |
| 2892 |
reference=SvRV(ST(0)); |
| 2893 |
hv=SvSTASH(reference); |
| 2894 |
if (SvTYPE(reference) != SVt_PVAV) |
| 2895 |
{ |
| 2896 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 2897 |
PackageName); |
| 2898 |
goto PerlException; |
| 2899 |
} |
| 2900 |
av=(AV *) reference; |
| 2901 |
info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL, |
| 2902 |
exception); |
| 2903 |
n=1; |
| 2904 |
if (items <= 1) |
| 2905 |
{ |
| 2906 |
ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName); |
| 2907 |
goto PerlException; |
| 2908 |
} |
| 2909 |
for (n=0, i=0; i < ac; i++) |
| 2910 |
{ |
| 2911 |
list[n]=(char *) (SvPV(ST(i+1),length[n])); |
| 2912 |
if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob")) |
| 2913 |
{ |
| 2914 |
list[n]=(char *) (SvPV(ST(i+2),length[n])); |
| 2915 |
continue; |
| 2916 |
} |
| 2917 |
n++; |
| 2918 |
} |
| 2919 |
list[n]=(char *) NULL; |
| 2920 |
keep=list; |
| 2921 |
for (i=number_images=0; i < n; i++) |
| 2922 |
{ |
| 2923 |
image=BlobToImage(info->image_info,list[i],length[i],exception); |
| 2924 |
if (image == (Image *) NULL) |
| 2925 |
break; |
| 2926 |
for ( ; image; image=image->next) |
| 2927 |
{ |
| 2928 |
AddImageToRegistry(sv,image); |
| 2929 |
rv=newRV(sv); |
| 2930 |
av_push(av,sv_bless(rv,hv)); |
| 2931 |
SvREFCNT_dec(sv); |
| 2932 |
number_images++; |
| 2933 |
} |
| 2934 |
} |
| 2935 |
/* |
| 2936 |
Free resources. |
| 2937 |
*/ |
| 2938 |
for (i=0; i < n; i++) |
| 2939 |
if (list[i] != (char *) NULL) |
| 2940 |
for (p=keep; list[i] != *p++; ) |
| 2941 |
if (*p == (char *) NULL) |
| 2942 |
{ |
| 2943 |
list[i]=(char *) RelinquishMagickMemory(list[i]); |
| 2944 |
break; |
| 2945 |
} |
| 2946 |
|
| 2947 |
PerlException: |
| 2948 |
if (list) |
| 2949 |
list=(char **) RelinquishMagickMemory(list); |
| 2950 |
if (length) |
| 2951 |
length=(STRLEN *) RelinquishMagickMemory(length); |
| 2952 |
InheritPerlException(exception,perl_exception); |
| 2953 |
exception=DestroyExceptionInfo(exception); |
| 2954 |
sv_setiv(perl_exception,(IV) number_images); |
| 2955 |
SvPOK_on(perl_exception); |
| 2956 |
ST(0)=sv_2mortal(perl_exception); |
| 2957 |
XSRETURN(1); |
| 2958 |
} |
| 2959 |
|
| 2960 |
# |
| 2961 |
############################################################################### |
| 2962 |
# # |
| 2963 |
# # |
| 2964 |
# # |
| 2965 |
# C h a n n e l F x # |
| 2966 |
# # |
| 2967 |
# # |
| 2968 |
# # |
| 2969 |
############################################################################### |
| 2970 |
# |
| 2971 |
# |
| 2972 |
void |
| 2973 |
ChannelFx(ref,...) |
| 2974 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 2975 |
ALIAS: |
| 2976 |
ChannelFxImage = 1 |
| 2977 |
channelfx = 2 |
| 2978 |
channelfximage = 3 |
| 2979 |
PPCODE: |
| 2980 |
{ |
| 2981 |
AV |
| 2982 |
*av; |
| 2983 |
|
| 2984 |
char |
| 2985 |
*attribute, |
| 2986 |
expression[MagickPathExtent]; |
| 2987 |
|
| 2988 |
ChannelType |
| 2989 |
channel, |
| 2990 |
channel_mask; |
| 2991 |
|
| 2992 |
ExceptionInfo |
| 2993 |
*exception; |
| 2994 |
|
| 2995 |
HV |
| 2996 |
*hv; |
| 2997 |
|
| 2998 |
Image |
| 2999 |
*image; |
| 3000 |
|
| 3001 |
ssize_t |
| 3002 |
i; |
| 3003 |
|
| 3004 |
struct PackageInfo |
| 3005 |
*info; |
| 3006 |
|
| 3007 |
SV |
| 3008 |
*av_reference, |
| 3009 |
*perl_exception, |
| 3010 |
*reference, |
| 3011 |
*rv, |
| 3012 |
*sv; |
| 3013 |
|
| 3014 |
PERL_UNUSED_VAR(ref); |
| 3015 |
PERL_UNUSED_VAR(ix); |
| 3016 |
exception=AcquireExceptionInfo(); |
| 3017 |
perl_exception=newSVpv("",0); |
| 3018 |
sv=NULL; |
| 3019 |
attribute=NULL; |
| 3020 |
av=NULL; |
| 3021 |
if (sv_isobject(ST(0)) == 0) |
| 3022 |
{ |
| 3023 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 3024 |
PackageName); |
| 3025 |
goto PerlException; |
| 3026 |
} |
| 3027 |
reference=SvRV(ST(0)); |
| 3028 |
hv=SvSTASH(reference); |
| 3029 |
av=newAV(); |
| 3030 |
av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv)); |
| 3031 |
SvREFCNT_dec(av); |
| 3032 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 3033 |
if (image == (Image *) NULL) |
| 3034 |
{ |
| 3035 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 3036 |
PackageName); |
| 3037 |
goto PerlException; |
| 3038 |
} |
| 3039 |
info=GetPackageInfo(aTHX_ (void *) av,info,exception); |
| 3040 |
/* |
| 3041 |
Get options. |
| 3042 |
*/ |
| 3043 |
channel=DefaultChannels; |
| 3044 |
(void) CopyMagickString(expression,"u",MagickPathExtent); |
| 3045 |
if (items == 2) |
| 3046 |
(void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MagickPathExtent); |
| 3047 |
else |
| 3048 |
for (i=2; i < items; i+=2) |
| 3049 |
{ |
| 3050 |
attribute=(char *) SvPV(ST(i-1),na); |
| 3051 |
switch (*attribute) |
| 3052 |
{ |
| 3053 |
case 'C': |
| 3054 |
case 'c': |
| 3055 |
{ |
| 3056 |
if (LocaleCompare(attribute,"channel") == 0) |
| 3057 |
{ |
| 3058 |
ssize_t |
| 3059 |
option; |
| 3060 |
|
| 3061 |
option=ParseChannelOption(SvPV(ST(i),na)); |
| 3062 |
if (option < 0) |
| 3063 |
{ |
| 3064 |
ThrowPerlException(exception,OptionError, |
| 3065 |
"UnrecognizedType",SvPV(ST(i),na)); |
| 3066 |
return; |
| 3067 |
} |
| 3068 |
channel=(ChannelType) option; |
| 3069 |
break; |
| 3070 |
} |
| 3071 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 3072 |
attribute); |
| 3073 |
break; |
| 3074 |
} |
| 3075 |
case 'E': |
| 3076 |
case 'e': |
| 3077 |
{ |
| 3078 |
if (LocaleCompare(attribute,"expression") == 0) |
| 3079 |
{ |
| 3080 |
(void) CopyMagickString(expression,SvPV(ST(i),na), |
| 3081 |
MagickPathExtent); |
| 3082 |
break; |
| 3083 |
} |
| 3084 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 3085 |
attribute); |
| 3086 |
break; |
| 3087 |
} |
| 3088 |
default: |
| 3089 |
{ |
| 3090 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 3091 |
attribute); |
| 3092 |
break; |
| 3093 |
} |
| 3094 |
} |
| 3095 |
} |
| 3096 |
channel_mask=SetImageChannelMask(image,channel); |
| 3097 |
image=ChannelFxImage(image,expression,exception); |
| 3098 |
if (image != (Image *) NULL) |
| 3099 |
(void) SetImageChannelMask(image,channel_mask); |
| 3100 |
if (image == (Image *) NULL) |
| 3101 |
goto PerlException; |
| 3102 |
for ( ; image; image=image->next) |
| 3103 |
{ |
| 3104 |
AddImageToRegistry(sv,image); |
| 3105 |
rv=newRV(sv); |
| 3106 |
av_push(av,sv_bless(rv,hv)); |
| 3107 |
SvREFCNT_dec(sv); |
| 3108 |
} |
| 3109 |
exception=DestroyExceptionInfo(exception); |
| 3110 |
ST(0)=av_reference; |
| 3111 |
SvREFCNT_dec(perl_exception); /* can't return warning messages */ |
| 3112 |
XSRETURN(1); |
| 3113 |
|
| 3114 |
PerlException: |
| 3115 |
InheritPerlException(exception,perl_exception); |
| 3116 |
exception=DestroyExceptionInfo(exception); |
| 3117 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 3118 |
SvPOK_on(perl_exception); |
| 3119 |
ST(0)=sv_2mortal(perl_exception); |
| 3120 |
XSRETURN(1); |
| 3121 |
} |
| 3122 |
|
| 3123 |
# |
| 3124 |
############################################################################### |
| 3125 |
# # |
| 3126 |
# # |
| 3127 |
# # |
| 3128 |
# C l o n e # |
| 3129 |
# # |
| 3130 |
# # |
| 3131 |
# # |
| 3132 |
############################################################################### |
| 3133 |
# |
| 3134 |
# |
| 3135 |
void |
| 3136 |
Clone(ref) |
| 3137 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 3138 |
ALIAS: |
| 3139 |
CopyImage = 1 |
| 3140 |
copy = 2 |
| 3141 |
copyimage = 3 |
| 3142 |
CloneImage = 4 |
| 3143 |
clone = 5 |
| 3144 |
cloneimage = 6 |
| 3145 |
Clone = 7 |
| 3146 |
PPCODE: |
| 3147 |
{ |
| 3148 |
AV |
| 3149 |
*av; |
| 3150 |
|
| 3151 |
ExceptionInfo |
| 3152 |
*exception; |
| 3153 |
|
| 3154 |
HV |
| 3155 |
*hv; |
| 3156 |
|
| 3157 |
Image |
| 3158 |
*clone, |
| 3159 |
*image; |
| 3160 |
|
| 3161 |
struct PackageInfo |
| 3162 |
*info; |
| 3163 |
|
| 3164 |
SV |
| 3165 |
*perl_exception, |
| 3166 |
*reference, |
| 3167 |
*rv, |
| 3168 |
*sv; |
| 3169 |
|
| 3170 |
PERL_UNUSED_VAR(ref); |
| 3171 |
PERL_UNUSED_VAR(ix); |
| 3172 |
exception=AcquireExceptionInfo(); |
| 3173 |
perl_exception=newSVpv("",0); |
| 3174 |
sv=NULL; |
| 3175 |
if (sv_isobject(ST(0)) == 0) |
| 3176 |
{ |
| 3177 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 3178 |
PackageName); |
| 3179 |
goto PerlException; |
| 3180 |
} |
| 3181 |
reference=SvRV(ST(0)); |
| 3182 |
hv=SvSTASH(reference); |
| 3183 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 3184 |
if (image == (Image *) NULL) |
| 3185 |
{ |
| 3186 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 3187 |
PackageName); |
| 3188 |
goto PerlException; |
| 3189 |
} |
| 3190 |
/* |
| 3191 |
Create blessed Perl array for the returned image. |
| 3192 |
*/ |
| 3193 |
av=newAV(); |
| 3194 |
ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv)); |
| 3195 |
SvREFCNT_dec(av); |
| 3196 |
for ( ; image; image=image->next) |
| 3197 |
{ |
| 3198 |
clone=CloneImage(image,0,0,MagickTrue,exception); |
| 3199 |
if (clone == (Image *) NULL) |
| 3200 |
break; |
| 3201 |
AddImageToRegistry(sv,clone); |
| 3202 |
rv=newRV(sv); |
| 3203 |
av_push(av,sv_bless(rv,hv)); |
| 3204 |
SvREFCNT_dec(sv); |
| 3205 |
} |
| 3206 |
exception=DestroyExceptionInfo(exception); |
| 3207 |
SvREFCNT_dec(perl_exception); |
| 3208 |
XSRETURN(1); |
| 3209 |
|
| 3210 |
PerlException: |
| 3211 |
InheritPerlException(exception,perl_exception); |
| 3212 |
exception=DestroyExceptionInfo(exception); |
| 3213 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 3214 |
SvPOK_on(perl_exception); |
| 3215 |
ST(0)=sv_2mortal(perl_exception); |
| 3216 |
XSRETURN(1); |
| 3217 |
} |
| 3218 |
|
| 3219 |
# |
| 3220 |
############################################################################### |
| 3221 |
# # |
| 3222 |
# # |
| 3223 |
# # |
| 3224 |
# C L O N E # |
| 3225 |
# # |
| 3226 |
# # |
| 3227 |
# # |
| 3228 |
############################################################################### |
| 3229 |
# |
| 3230 |
# |
| 3231 |
void |
| 3232 |
CLONE(ref,...) |
| 3233 |
SV *ref; |
| 3234 |
CODE: |
| 3235 |
{ |
| 3236 |
PERL_UNUSED_VAR(ref); |
| 3237 |
if (magick_registry != (SplayTreeInfo *) NULL) |
| 3238 |
{ |
| 3239 |
Image |
| 3240 |
*p; |
| 3241 |
|
| 3242 |
ResetSplayTreeIterator(magick_registry); |
| 3243 |
p=(Image *) GetNextKeyInSplayTree(magick_registry); |
| 3244 |
while (p != (Image *) NULL) |
| 3245 |
{ |
| 3246 |
ReferenceImage(p); |
| 3247 |
p=(Image *) GetNextKeyInSplayTree(magick_registry); |
| 3248 |
} |
| 3249 |
} |
| 3250 |
} |
| 3251 |
|
| 3252 |
# |
| 3253 |
############################################################################### |
| 3254 |
# # |
| 3255 |
# # |
| 3256 |
# # |
| 3257 |
# C o a l e s c e # |
| 3258 |
# # |
| 3259 |
# # |
| 3260 |
# # |
| 3261 |
############################################################################### |
| 3262 |
# |
| 3263 |
# |
| 3264 |
void |
| 3265 |
Coalesce(ref) |
| 3266 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 3267 |
ALIAS: |
| 3268 |
CoalesceImage = 1 |
| 3269 |
coalesce = 2 |
| 3270 |
coalesceimage = 3 |
| 3271 |
PPCODE: |
| 3272 |
{ |
| 3273 |
AV |
| 3274 |
*av; |
| 3275 |
|
| 3276 |
ExceptionInfo |
| 3277 |
*exception; |
| 3278 |
|
| 3279 |
HV |
| 3280 |
*hv; |
| 3281 |
|
| 3282 |
Image |
| 3283 |
*image; |
| 3284 |
|
| 3285 |
struct PackageInfo |
| 3286 |
*info; |
| 3287 |
|
| 3288 |
SV |
| 3289 |
*av_reference, |
| 3290 |
*perl_exception, |
| 3291 |
*reference, |
| 3292 |
*rv, |
| 3293 |
*sv; |
| 3294 |
|
| 3295 |
PERL_UNUSED_VAR(ref); |
| 3296 |
PERL_UNUSED_VAR(ix); |
| 3297 |
exception=AcquireExceptionInfo(); |
| 3298 |
perl_exception=newSVpv("",0); |
| 3299 |
sv=NULL; |
| 3300 |
if (sv_isobject(ST(0)) == 0) |
| 3301 |
{ |
| 3302 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 3303 |
PackageName); |
| 3304 |
goto PerlException; |
| 3305 |
} |
| 3306 |
reference=SvRV(ST(0)); |
| 3307 |
hv=SvSTASH(reference); |
| 3308 |
av=newAV(); |
| 3309 |
av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv)); |
| 3310 |
SvREFCNT_dec(av); |
| 3311 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 3312 |
if (image == (Image *) NULL) |
| 3313 |
{ |
| 3314 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 3315 |
PackageName); |
| 3316 |
goto PerlException; |
| 3317 |
} |
| 3318 |
image=CoalesceImages(image,exception); |
| 3319 |
if (image == (Image *) NULL) |
| 3320 |
goto PerlException; |
| 3321 |
for ( ; image; image=image->next) |
| 3322 |
{ |
| 3323 |
AddImageToRegistry(sv,image); |
| 3324 |
rv=newRV(sv); |
| 3325 |
av_push(av,sv_bless(rv,hv)); |
| 3326 |
SvREFCNT_dec(sv); |
| 3327 |
} |
| 3328 |
exception=DestroyExceptionInfo(exception); |
| 3329 |
ST(0)=av_reference; |
| 3330 |
SvREFCNT_dec(perl_exception); |
| 3331 |
XSRETURN(1); |
| 3332 |
|
| 3333 |
PerlException: |
| 3334 |
InheritPerlException(exception,perl_exception); |
| 3335 |
exception=DestroyExceptionInfo(exception); |
| 3336 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 3337 |
SvPOK_on(perl_exception); |
| 3338 |
ST(0)=sv_2mortal(perl_exception); |
| 3339 |
XSRETURN(1); |
| 3340 |
} |
| 3341 |
|
| 3342 |
# |
| 3343 |
############################################################################### |
| 3344 |
# # |
| 3345 |
# # |
| 3346 |
# # |
| 3347 |
# C o m p a r e # |
| 3348 |
# # |
| 3349 |
# # |
| 3350 |
# # |
| 3351 |
############################################################################### |
| 3352 |
# |
| 3353 |
# |
| 3354 |
void |
| 3355 |
Compare(ref,...) |
| 3356 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 3357 |
ALIAS: |
| 3358 |
CompareImages = 1 |
| 3359 |
compare = 2 |
| 3360 |
compareimage = 3 |
| 3361 |
PPCODE: |
| 3362 |
{ |
| 3363 |
AV |
| 3364 |
*av; |
| 3365 |
|
| 3366 |
char |
| 3367 |
*attribute; |
| 3368 |
|
| 3369 |
double |
| 3370 |
distortion; |
| 3371 |
|
| 3372 |
ExceptionInfo |
| 3373 |
*exception; |
| 3374 |
|
| 3375 |
HV |
| 3376 |
*hv; |
| 3377 |
|
| 3378 |
Image |
| 3379 |
*difference_image, |
| 3380 |
*image, |
| 3381 |
*reconstruct_image; |
| 3382 |
|
| 3383 |
MetricType |
| 3384 |
metric; |
| 3385 |
|
| 3386 |
ssize_t |
| 3387 |
i, |
| 3388 |
option; |
| 3389 |
|
| 3390 |
struct PackageInfo |
| 3391 |
*info; |
| 3392 |
|
| 3393 |
SV |
| 3394 |
*av_reference, |
| 3395 |
*perl_exception, |
| 3396 |
*reference, |
| 3397 |
*rv, |
| 3398 |
*sv; |
| 3399 |
|
| 3400 |
PERL_UNUSED_VAR(ref); |
| 3401 |
PERL_UNUSED_VAR(ix); |
| 3402 |
exception=AcquireExceptionInfo(); |
| 3403 |
perl_exception=newSVpv("",0); |
| 3404 |
sv=NULL; |
| 3405 |
av=NULL; |
| 3406 |
attribute=NULL; |
| 3407 |
if (sv_isobject(ST(0)) == 0) |
| 3408 |
{ |
| 3409 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 3410 |
PackageName); |
| 3411 |
goto PerlException; |
| 3412 |
} |
| 3413 |
reference=SvRV(ST(0)); |
| 3414 |
hv=SvSTASH(reference); |
| 3415 |
av=newAV(); |
| 3416 |
av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv)); |
| 3417 |
SvREFCNT_dec(av); |
| 3418 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 3419 |
if (image == (Image *) NULL) |
| 3420 |
{ |
| 3421 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 3422 |
PackageName); |
| 3423 |
goto PerlException; |
| 3424 |
} |
| 3425 |
info=GetPackageInfo(aTHX_ (void *) av,info,exception); |
| 3426 |
/* |
| 3427 |
Get attribute. |
| 3428 |
*/ |
| 3429 |
reconstruct_image=image; |
| 3430 |
metric=RootMeanSquaredErrorMetric; |
| 3431 |
for (i=2; i < items; i+=2) |
| 3432 |
{ |
| 3433 |
attribute=(char *) SvPV(ST(i-1),na); |
| 3434 |
switch (*attribute) |
| 3435 |
{ |
| 3436 |
case 'C': |
| 3437 |
case 'c': |
| 3438 |
{ |
| 3439 |
if (LocaleCompare(attribute,"channel") == 0) |
| 3440 |
{ |
| 3441 |
ssize_t |
| 3442 |
option; |
| 3443 |
|
| 3444 |
option=ParseChannelOption(SvPV(ST(i),na)); |
| 3445 |
if (option < 0) |
| 3446 |
{ |
| 3447 |
ThrowPerlException(exception,OptionError, |
| 3448 |
"UnrecognizedType",SvPV(ST(i),na)); |
| 3449 |
return; |
| 3450 |
} |
| 3451 |
(void) SetPixelChannelMask(image,(ChannelType) option); |
| 3452 |
break; |
| 3453 |
} |
| 3454 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 3455 |
attribute); |
| 3456 |
break; |
| 3457 |
} |
| 3458 |
case 'F': |
| 3459 |
case 'f': |
| 3460 |
{ |
| 3461 |
if (LocaleCompare(attribute,"fuzz") == 0) |
| 3462 |
{ |
| 3463 |
image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0); |
| 3464 |
break; |
| 3465 |
} |
| 3466 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 3467 |
attribute); |
| 3468 |
break; |
| 3469 |
} |
| 3470 |
case 'I': |
| 3471 |
case 'i': |
| 3472 |
{ |
| 3473 |
if (LocaleCompare(attribute,"image") == 0) |
| 3474 |
{ |
| 3475 |
reconstruct_image=SetupList(aTHX_ SvRV(ST(i)), |
| 3476 |
(struct PackageInfo **) NULL,(SV ***) NULL,exception); |
| 3477 |
break; |
| 3478 |
} |
| 3479 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 3480 |
attribute); |
| 3481 |
break; |
| 3482 |
} |
| 3483 |
case 'M': |
| 3484 |
case 'm': |
| 3485 |
{ |
| 3486 |
if (LocaleCompare(attribute,"metric") == 0) |
| 3487 |
{ |
| 3488 |
option=ParseCommandOption(MagickMetricOptions,MagickFalse, |
| 3489 |
SvPV(ST(i),na)); |
| 3490 |
if (option < 0) |
| 3491 |
{ |
| 3492 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 3493 |
SvPV(ST(i),na)); |
| 3494 |
break; |
| 3495 |
} |
| 3496 |
metric=(MetricType) option; |
| 3497 |
break; |
| 3498 |
} |
| 3499 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 3500 |
attribute); |
| 3501 |
break; |
| 3502 |
} |
| 3503 |
default: |
| 3504 |
{ |
| 3505 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 3506 |
attribute); |
| 3507 |
break; |
| 3508 |
} |
| 3509 |
} |
| 3510 |
} |
| 3511 |
difference_image=CompareImages(image,reconstruct_image,metric,&distortion, |
| 3512 |
exception); |
| 3513 |
if (difference_image != (Image *) NULL) |
| 3514 |
{ |
| 3515 |
difference_image->error.mean_error_per_pixel=distortion; |
| 3516 |
AddImageToRegistry(sv,difference_image); |
| 3517 |
rv=newRV(sv); |
| 3518 |
av_push(av,sv_bless(rv,hv)); |
| 3519 |
SvREFCNT_dec(sv); |
| 3520 |
} |
| 3521 |
exception=DestroyExceptionInfo(exception); |
| 3522 |
ST(0)=av_reference; |
| 3523 |
SvREFCNT_dec(perl_exception); /* can't return warning messages */ |
| 3524 |
XSRETURN(1); |
| 3525 |
|
| 3526 |
PerlException: |
| 3527 |
InheritPerlException(exception,perl_exception); |
| 3528 |
exception=DestroyExceptionInfo(exception); |
| 3529 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 3530 |
SvPOK_on(perl_exception); |
| 3531 |
ST(0)=sv_2mortal(perl_exception); |
| 3532 |
XSRETURN(1); |
| 3533 |
} |
| 3534 |
|
| 3535 |
# |
| 3536 |
############################################################################### |
| 3537 |
# # |
| 3538 |
# # |
| 3539 |
# # |
| 3540 |
# C o m p l e x I m a g e s # |
| 3541 |
# # |
| 3542 |
# # |
| 3543 |
# # |
| 3544 |
############################################################################### |
| 3545 |
# |
| 3546 |
# |
| 3547 |
void |
| 3548 |
ComplexImages(ref,...) |
| 3549 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 3550 |
ALIAS: |
| 3551 |
ComplexImages = 1 |
| 3552 |
compleximages = 2 |
| 3553 |
PPCODE: |
| 3554 |
{ |
| 3555 |
AV |
| 3556 |
*av; |
| 3557 |
|
| 3558 |
char |
| 3559 |
*attribute, |
| 3560 |
*p; |
| 3561 |
|
| 3562 |
ComplexOperator |
| 3563 |
op; |
| 3564 |
|
| 3565 |
ExceptionInfo |
| 3566 |
*exception; |
| 3567 |
|
| 3568 |
HV |
| 3569 |
*hv; |
| 3570 |
|
| 3571 |
Image |
| 3572 |
*image; |
| 3573 |
|
| 3574 |
ssize_t |
| 3575 |
i; |
| 3576 |
|
| 3577 |
struct PackageInfo |
| 3578 |
*info; |
| 3579 |
|
| 3580 |
SV |
| 3581 |
*perl_exception, |
| 3582 |
*reference, |
| 3583 |
*rv, |
| 3584 |
*sv; |
| 3585 |
|
| 3586 |
PERL_UNUSED_VAR(ref); |
| 3587 |
PERL_UNUSED_VAR(ix); |
| 3588 |
exception=AcquireExceptionInfo(); |
| 3589 |
perl_exception=newSVpv("",0); |
| 3590 |
sv=NULL; |
| 3591 |
if (sv_isobject(ST(0)) == 0) |
| 3592 |
{ |
| 3593 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 3594 |
PackageName); |
| 3595 |
goto PerlException; |
| 3596 |
} |
| 3597 |
reference=SvRV(ST(0)); |
| 3598 |
hv=SvSTASH(reference); |
| 3599 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 3600 |
if (image == (Image *) NULL) |
| 3601 |
{ |
| 3602 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 3603 |
PackageName); |
| 3604 |
goto PerlException; |
| 3605 |
} |
| 3606 |
op=UndefinedComplexOperator; |
| 3607 |
if (items == 2) |
| 3608 |
{ |
| 3609 |
ssize_t |
| 3610 |
in; |
| 3611 |
|
| 3612 |
in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *) |
| 3613 |
SvPV(ST(1),na)); |
| 3614 |
if (in < 0) |
| 3615 |
{ |
| 3616 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 3617 |
SvPV(ST(1),na)); |
| 3618 |
return; |
| 3619 |
} |
| 3620 |
op=(ComplexOperator) in; |
| 3621 |
} |
| 3622 |
else |
| 3623 |
for (i=2; i < items; i+=2) |
| 3624 |
{ |
| 3625 |
attribute=(char *) SvPV(ST(i-1),na); |
| 3626 |
switch (*attribute) |
| 3627 |
{ |
| 3628 |
case 'O': |
| 3629 |
case 'o': |
| 3630 |
{ |
| 3631 |
if (LocaleCompare(attribute,"operator") == 0) |
| 3632 |
{ |
| 3633 |
ssize_t |
| 3634 |
in; |
| 3635 |
|
| 3636 |
in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption( |
| 3637 |
MagickComplexOptions,MagickFalse,SvPV(ST(i),na)); |
| 3638 |
if (in < 0) |
| 3639 |
{ |
| 3640 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 3641 |
SvPV(ST(i),na)); |
| 3642 |
return; |
| 3643 |
} |
| 3644 |
op=(ComplexOperator) in; |
| 3645 |
break; |
| 3646 |
} |
| 3647 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 3648 |
attribute); |
| 3649 |
break; |
| 3650 |
} |
| 3651 |
default: |
| 3652 |
{ |
| 3653 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 3654 |
attribute); |
| 3655 |
break; |
| 3656 |
} |
| 3657 |
} |
| 3658 |
} |
| 3659 |
image=ComplexImages(image,op,exception); |
| 3660 |
if (image == (Image *) NULL) |
| 3661 |
goto PerlException; |
| 3662 |
/* |
| 3663 |
Create blessed Perl array for the returned image. |
| 3664 |
*/ |
| 3665 |
av=newAV(); |
| 3666 |
ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv)); |
| 3667 |
SvREFCNT_dec(av); |
| 3668 |
AddImageToRegistry(sv,image); |
| 3669 |
rv=newRV(sv); |
| 3670 |
av_push(av,sv_bless(rv,hv)); |
| 3671 |
SvREFCNT_dec(sv); |
| 3672 |
info=GetPackageInfo(aTHX_ (void *) av,info,exception); |
| 3673 |
(void) FormatLocaleString(info->image_info->filename,MagickPathExtent, |
| 3674 |
"complex-%.*s",(int) (MagickPathExtent-9), |
| 3675 |
((p=strrchr(image->filename,'/')) ? p+1 : image->filename)); |
| 3676 |
(void) CopyMagickString(image->filename,info->image_info->filename, |
| 3677 |
MagickPathExtent); |
| 3678 |
SetImageInfo(info->image_info,0,exception); |
| 3679 |
exception=DestroyExceptionInfo(exception); |
| 3680 |
SvREFCNT_dec(perl_exception); |
| 3681 |
XSRETURN(1); |
| 3682 |
|
| 3683 |
PerlException: |
| 3684 |
InheritPerlException(exception,perl_exception); |
| 3685 |
exception=DestroyExceptionInfo(exception); |
| 3686 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 3687 |
SvPOK_on(perl_exception); |
| 3688 |
ST(0)=sv_2mortal(perl_exception); |
| 3689 |
XSRETURN(1); |
| 3690 |
} |
| 3691 |
|
| 3692 |
# |
| 3693 |
############################################################################### |
| 3694 |
# # |
| 3695 |
# # |
| 3696 |
# # |
| 3697 |
# C o m p a r e L a y e r s # |
| 3698 |
# # |
| 3699 |
# # |
| 3700 |
# # |
| 3701 |
############################################################################### |
| 3702 |
# |
| 3703 |
# |
| 3704 |
void |
| 3705 |
CompareLayers(ref,...) |
| 3706 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 3707 |
ALIAS: |
| 3708 |
CompareImagesLayers = 1 |
| 3709 |
comparelayers = 2 |
| 3710 |
compareimagelayers = 3 |
| 3711 |
PPCODE: |
| 3712 |
{ |
| 3713 |
AV |
| 3714 |
*av; |
| 3715 |
|
| 3716 |
char |
| 3717 |
*attribute; |
| 3718 |
|
| 3719 |
ExceptionInfo |
| 3720 |
*exception; |
| 3721 |
|
| 3722 |
HV |
| 3723 |
*hv; |
| 3724 |
|
| 3725 |
Image |
| 3726 |
*image; |
| 3727 |
|
| 3728 |
LayerMethod |
| 3729 |
method; |
| 3730 |
|
| 3731 |
ssize_t |
| 3732 |
i, |
| 3733 |
option; |
| 3734 |
|
| 3735 |
struct PackageInfo |
| 3736 |
*info; |
| 3737 |
|
| 3738 |
SV |
| 3739 |
*av_reference, |
| 3740 |
*perl_exception, |
| 3741 |
*reference, |
| 3742 |
*rv, |
| 3743 |
*sv; |
| 3744 |
|
| 3745 |
PERL_UNUSED_VAR(ref); |
| 3746 |
PERL_UNUSED_VAR(ix); |
| 3747 |
exception=AcquireExceptionInfo(); |
| 3748 |
perl_exception=newSVpv("",0); |
| 3749 |
sv=NULL; |
| 3750 |
if (sv_isobject(ST(0)) == 0) |
| 3751 |
{ |
| 3752 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 3753 |
PackageName); |
| 3754 |
goto PerlException; |
| 3755 |
} |
| 3756 |
reference=SvRV(ST(0)); |
| 3757 |
hv=SvSTASH(reference); |
| 3758 |
av=newAV(); |
| 3759 |
av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv)); |
| 3760 |
SvREFCNT_dec(av); |
| 3761 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 3762 |
if (image == (Image *) NULL) |
| 3763 |
{ |
| 3764 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 3765 |
PackageName); |
| 3766 |
goto PerlException; |
| 3767 |
} |
| 3768 |
method=CompareAnyLayer; |
| 3769 |
for (i=2; i < items; i+=2) |
| 3770 |
{ |
| 3771 |
attribute=(char *) SvPV(ST(i-1),na); |
| 3772 |
switch (*attribute) |
| 3773 |
{ |
| 3774 |
case 'M': |
| 3775 |
case 'm': |
| 3776 |
{ |
| 3777 |
if (LocaleCompare(attribute,"method") == 0) |
| 3778 |
{ |
| 3779 |
option=ParseCommandOption(MagickLayerOptions,MagickFalse, |
| 3780 |
SvPV(ST(i),na)); |
| 3781 |
if (option < 0) |
| 3782 |
{ |
| 3783 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 3784 |
SvPV(ST(i),na)); |
| 3785 |
break; |
| 3786 |
} |
| 3787 |
method=(LayerMethod) option; |
| 3788 |
break; |
| 3789 |
} |
| 3790 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 3791 |
attribute); |
| 3792 |
break; |
| 3793 |
} |
| 3794 |
default: |
| 3795 |
{ |
| 3796 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 3797 |
attribute); |
| 3798 |
break; |
| 3799 |
} |
| 3800 |
} |
| 3801 |
} |
| 3802 |
image=CompareImagesLayers(image,method,exception); |
| 3803 |
if (image == (Image *) NULL) |
| 3804 |
goto PerlException; |
| 3805 |
for ( ; image; image=image->next) |
| 3806 |
{ |
| 3807 |
AddImageToRegistry(sv,image); |
| 3808 |
rv=newRV(sv); |
| 3809 |
av_push(av,sv_bless(rv,hv)); |
| 3810 |
SvREFCNT_dec(sv); |
| 3811 |
} |
| 3812 |
exception=DestroyExceptionInfo(exception); |
| 3813 |
ST(0)=av_reference; |
| 3814 |
SvREFCNT_dec(perl_exception); |
| 3815 |
XSRETURN(1); |
| 3816 |
|
| 3817 |
PerlException: |
| 3818 |
InheritPerlException(exception,perl_exception); |
| 3819 |
exception=DestroyExceptionInfo(exception); |
| 3820 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 3821 |
SvPOK_on(perl_exception); |
| 3822 |
ST(0)=sv_2mortal(perl_exception); |
| 3823 |
XSRETURN(1); |
| 3824 |
} |
| 3825 |
|
| 3826 |
# |
| 3827 |
############################################################################### |
| 3828 |
# # |
| 3829 |
# # |
| 3830 |
# # |
| 3831 |
# D e s t r o y # |
| 3832 |
# # |
| 3833 |
# # |
| 3834 |
# # |
| 3835 |
############################################################################### |
| 3836 |
# |
| 3837 |
# |
| 3838 |
void |
| 3839 |
DESTROY(ref) |
| 3840 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 3841 |
PPCODE: |
| 3842 |
{ |
| 3843 |
SV |
| 3844 |
*reference; |
| 3845 |
|
| 3846 |
PERL_UNUSED_VAR(ref); |
| 3847 |
if (sv_isobject(ST(0)) == 0) |
| 3848 |
croak("ReferenceIsNotMyType"); |
| 3849 |
reference=SvRV(ST(0)); |
| 3850 |
switch (SvTYPE(reference)) |
| 3851 |
{ |
| 3852 |
case SVt_PVAV: |
| 3853 |
{ |
| 3854 |
char |
| 3855 |
message[MagickPathExtent]; |
| 3856 |
|
| 3857 |
const SV |
| 3858 |
*key; |
| 3859 |
|
| 3860 |
HV |
| 3861 |
*hv; |
| 3862 |
|
| 3863 |
GV |
| 3864 |
**gvp; |
| 3865 |
|
| 3866 |
struct PackageInfo |
| 3867 |
*info; |
| 3868 |
|
| 3869 |
SV |
| 3870 |
*sv; |
| 3871 |
|
| 3872 |
/* |
| 3873 |
Array (AV *) reference |
| 3874 |
*/ |
| 3875 |
(void) FormatLocaleString(message,MagickPathExtent,"package%s%p", |
| 3876 |
XS_VERSION,(void *) reference); |
| 3877 |
hv=gv_stashpv(PackageName, FALSE); |
| 3878 |
if (!hv) |
| 3879 |
break; |
| 3880 |
gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE); |
| 3881 |
if (!gvp) |
| 3882 |
break; |
| 3883 |
sv=GvSV(*gvp); |
| 3884 |
if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv)) |
| 3885 |
{ |
| 3886 |
info=INT2PTR(struct PackageInfo *,SvIV(sv)); |
| 3887 |
DestroyPackageInfo(info); |
| 3888 |
} |
| 3889 |
key=hv_delete(hv,message,(long) strlen(message),G_DISCARD); |
| 3890 |
(void) key; |
| 3891 |
break; |
| 3892 |
} |
| 3893 |
case SVt_PVMG: |
| 3894 |
{ |
| 3895 |
Image |
| 3896 |
*image; |
| 3897 |
|
| 3898 |
/* |
| 3899 |
Blessed scalar = (Image *) SvIV(reference) |
| 3900 |
*/ |
| 3901 |
image=INT2PTR(Image *,SvIV(reference)); |
| 3902 |
if (image != (Image *) NULL) |
| 3903 |
DeleteImageFromRegistry(reference,image); |
| 3904 |
break; |
| 3905 |
} |
| 3906 |
default: |
| 3907 |
break; |
| 3908 |
} |
| 3909 |
} |
| 3910 |
|
| 3911 |
# |
| 3912 |
############################################################################### |
| 3913 |
# # |
| 3914 |
# # |
| 3915 |
# # |
| 3916 |
# D i s p l a y # |
| 3917 |
# # |
| 3918 |
# # |
| 3919 |
# # |
| 3920 |
############################################################################### |
| 3921 |
# |
| 3922 |
# |
| 3923 |
void |
| 3924 |
Display(ref,...) |
| 3925 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 3926 |
ALIAS: |
| 3927 |
DisplayImage = 1 |
| 3928 |
display = 2 |
| 3929 |
displayimage = 3 |
| 3930 |
PPCODE: |
| 3931 |
{ |
| 3932 |
ExceptionInfo |
| 3933 |
*exception; |
| 3934 |
|
| 3935 |
Image |
| 3936 |
*image; |
| 3937 |
|
| 3938 |
ssize_t |
| 3939 |
i; |
| 3940 |
|
| 3941 |
struct PackageInfo |
| 3942 |
*info, |
| 3943 |
*package_info; |
| 3944 |
|
| 3945 |
SV |
| 3946 |
*perl_exception, |
| 3947 |
*reference; |
| 3948 |
|
| 3949 |
PERL_UNUSED_VAR(ref); |
| 3950 |
PERL_UNUSED_VAR(ix); |
| 3951 |
exception=AcquireExceptionInfo(); |
| 3952 |
perl_exception=newSVpv("",0); |
| 3953 |
package_info=(struct PackageInfo *) NULL; |
| 3954 |
if (sv_isobject(ST(0)) == 0) |
| 3955 |
{ |
| 3956 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 3957 |
PackageName); |
| 3958 |
goto PerlException; |
| 3959 |
} |
| 3960 |
reference=SvRV(ST(0)); |
| 3961 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 3962 |
if (image == (Image *) NULL) |
| 3963 |
{ |
| 3964 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 3965 |
PackageName); |
| 3966 |
goto PerlException; |
| 3967 |
} |
| 3968 |
package_info=ClonePackageInfo(info,exception); |
| 3969 |
if (items == 2) |
| 3970 |
SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception); |
| 3971 |
else |
| 3972 |
if (items > 2) |
| 3973 |
for (i=2; i < items; i+=2) |
| 3974 |
SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i), |
| 3975 |
exception); |
| 3976 |
(void) DisplayImages(package_info->image_info,image,exception); |
| 3977 |
(void) CatchImageException(image); |
| 3978 |
|
| 3979 |
PerlException: |
| 3980 |
if (package_info != (struct PackageInfo *) NULL) |
| 3981 |
DestroyPackageInfo(package_info); |
| 3982 |
InheritPerlException(exception,perl_exception); |
| 3983 |
exception=DestroyExceptionInfo(exception); |
| 3984 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 3985 |
SvPOK_on(perl_exception); |
| 3986 |
ST(0)=sv_2mortal(perl_exception); |
| 3987 |
XSRETURN(1); |
| 3988 |
} |
| 3989 |
|
| 3990 |
# |
| 3991 |
############################################################################### |
| 3992 |
# # |
| 3993 |
# # |
| 3994 |
# # |
| 3995 |
# E v a l u a t e I m a g e s # |
| 3996 |
# # |
| 3997 |
# # |
| 3998 |
# # |
| 3999 |
############################################################################### |
| 4000 |
# |
| 4001 |
# |
| 4002 |
void |
| 4003 |
EvaluateImages(ref,...) |
| 4004 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 4005 |
ALIAS: |
| 4006 |
EvaluateImages = 1 |
| 4007 |
evaluateimages = 2 |
| 4008 |
PPCODE: |
| 4009 |
{ |
| 4010 |
AV |
| 4011 |
*av; |
| 4012 |
|
| 4013 |
char |
| 4014 |
*attribute, |
| 4015 |
*p; |
| 4016 |
|
| 4017 |
ExceptionInfo |
| 4018 |
*exception; |
| 4019 |
|
| 4020 |
HV |
| 4021 |
*hv; |
| 4022 |
|
| 4023 |
Image |
| 4024 |
*image; |
| 4025 |
|
| 4026 |
MagickEvaluateOperator |
| 4027 |
op; |
| 4028 |
|
| 4029 |
ssize_t |
| 4030 |
i; |
| 4031 |
|
| 4032 |
struct PackageInfo |
| 4033 |
*info; |
| 4034 |
|
| 4035 |
SV |
| 4036 |
*perl_exception, |
| 4037 |
*reference, |
| 4038 |
*rv, |
| 4039 |
*sv; |
| 4040 |
|
| 4041 |
PERL_UNUSED_VAR(ref); |
| 4042 |
PERL_UNUSED_VAR(ix); |
| 4043 |
exception=AcquireExceptionInfo(); |
| 4044 |
perl_exception=newSVpv("",0); |
| 4045 |
sv=NULL; |
| 4046 |
if (sv_isobject(ST(0)) == 0) |
| 4047 |
{ |
| 4048 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 4049 |
PackageName); |
| 4050 |
goto PerlException; |
| 4051 |
} |
| 4052 |
reference=SvRV(ST(0)); |
| 4053 |
hv=SvSTASH(reference); |
| 4054 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 4055 |
if (image == (Image *) NULL) |
| 4056 |
{ |
| 4057 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 4058 |
PackageName); |
| 4059 |
goto PerlException; |
| 4060 |
} |
| 4061 |
op=MeanEvaluateOperator; |
| 4062 |
if (items == 2) |
| 4063 |
{ |
| 4064 |
ssize_t |
| 4065 |
in; |
| 4066 |
|
| 4067 |
in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *) |
| 4068 |
SvPV(ST(1),na)); |
| 4069 |
if (in < 0) |
| 4070 |
{ |
| 4071 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 4072 |
SvPV(ST(1),na)); |
| 4073 |
return; |
| 4074 |
} |
| 4075 |
op=(MagickEvaluateOperator) in; |
| 4076 |
} |
| 4077 |
else |
| 4078 |
for (i=2; i < items; i+=2) |
| 4079 |
{ |
| 4080 |
attribute=(char *) SvPV(ST(i-1),na); |
| 4081 |
switch (*attribute) |
| 4082 |
{ |
| 4083 |
case 'O': |
| 4084 |
case 'o': |
| 4085 |
{ |
| 4086 |
if (LocaleCompare(attribute,"operator") == 0) |
| 4087 |
{ |
| 4088 |
ssize_t |
| 4089 |
in; |
| 4090 |
|
| 4091 |
in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption( |
| 4092 |
MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na)); |
| 4093 |
if (in < 0) |
| 4094 |
{ |
| 4095 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 4096 |
SvPV(ST(i),na)); |
| 4097 |
return; |
| 4098 |
} |
| 4099 |
op=(MagickEvaluateOperator) in; |
| 4100 |
break; |
| 4101 |
} |
| 4102 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 4103 |
attribute); |
| 4104 |
break; |
| 4105 |
} |
| 4106 |
default: |
| 4107 |
{ |
| 4108 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 4109 |
attribute); |
| 4110 |
break; |
| 4111 |
} |
| 4112 |
} |
| 4113 |
} |
| 4114 |
image=EvaluateImages(image,op,exception); |
| 4115 |
if (image == (Image *) NULL) |
| 4116 |
goto PerlException; |
| 4117 |
/* |
| 4118 |
Create blessed Perl array for the returned image. |
| 4119 |
*/ |
| 4120 |
av=newAV(); |
| 4121 |
ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv)); |
| 4122 |
SvREFCNT_dec(av); |
| 4123 |
AddImageToRegistry(sv,image); |
| 4124 |
rv=newRV(sv); |
| 4125 |
av_push(av,sv_bless(rv,hv)); |
| 4126 |
SvREFCNT_dec(sv); |
| 4127 |
info=GetPackageInfo(aTHX_ (void *) av,info,exception); |
| 4128 |
(void) FormatLocaleString(info->image_info->filename,MagickPathExtent, |
| 4129 |
"evaluate-%.*s",(int) (MagickPathExtent-9), |
| 4130 |
((p=strrchr(image->filename,'/')) ? p+1 : image->filename)); |
| 4131 |
(void) CopyMagickString(image->filename,info->image_info->filename, |
| 4132 |
MagickPathExtent); |
| 4133 |
SetImageInfo(info->image_info,0,exception); |
| 4134 |
exception=DestroyExceptionInfo(exception); |
| 4135 |
SvREFCNT_dec(perl_exception); |
| 4136 |
XSRETURN(1); |
| 4137 |
|
| 4138 |
PerlException: |
| 4139 |
InheritPerlException(exception,perl_exception); |
| 4140 |
exception=DestroyExceptionInfo(exception); |
| 4141 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 4142 |
SvPOK_on(perl_exception); |
| 4143 |
ST(0)=sv_2mortal(perl_exception); |
| 4144 |
XSRETURN(1); |
| 4145 |
} |
| 4146 |
|
| 4147 |
# |
| 4148 |
############################################################################### |
| 4149 |
# # |
| 4150 |
# # |
| 4151 |
# # |
| 4152 |
# F e a t u r e s # |
| 4153 |
# # |
| 4154 |
# # |
| 4155 |
# # |
| 4156 |
############################################################################### |
| 4157 |
# |
| 4158 |
# |
| 4159 |
void |
| 4160 |
Features(ref,...) |
| 4161 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 4162 |
ALIAS: |
| 4163 |
FeaturesImage = 1 |
| 4164 |
features = 2 |
| 4165 |
featuresimage = 3 |
| 4166 |
PPCODE: |
| 4167 |
{ |
| 4168 |
#define ChannelFeatures(channel,direction) \ |
| 4169 |
{ \ |
| 4170 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 4171 |
channel_features[channel].angular_second_moment[direction]); \ |
| 4172 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 4173 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 4174 |
channel_features[channel].contrast[direction]); \ |
| 4175 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 4176 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 4177 |
channel_features[channel].contrast[direction]); \ |
| 4178 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 4179 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 4180 |
channel_features[channel].variance_sum_of_squares[direction]); \ |
| 4181 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 4182 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 4183 |
channel_features[channel].inverse_difference_moment[direction]); \ |
| 4184 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 4185 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 4186 |
channel_features[channel].sum_average[direction]); \ |
| 4187 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 4188 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 4189 |
channel_features[channel].sum_variance[direction]); \ |
| 4190 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 4191 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 4192 |
channel_features[channel].sum_entropy[direction]); \ |
| 4193 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 4194 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 4195 |
channel_features[channel].entropy[direction]); \ |
| 4196 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 4197 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 4198 |
channel_features[channel].difference_variance[direction]); \ |
| 4199 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 4200 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 4201 |
channel_features[channel].difference_entropy[direction]); \ |
| 4202 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 4203 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 4204 |
channel_features[channel].measure_of_correlation_1[direction]); \ |
| 4205 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 4206 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 4207 |
channel_features[channel].measure_of_correlation_2[direction]); \ |
| 4208 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 4209 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 4210 |
channel_features[channel].maximum_correlation_coefficient[direction]); \ |
| 4211 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 4212 |
} |
| 4213 |
|
| 4214 |
AV |
| 4215 |
*av; |
| 4216 |
|
| 4217 |
char |
| 4218 |
*attribute, |
| 4219 |
message[MagickPathExtent]; |
| 4220 |
|
| 4221 |
ChannelFeatures |
| 4222 |
*channel_features; |
| 4223 |
|
| 4224 |
double |
| 4225 |
distance; |
| 4226 |
|
| 4227 |
ExceptionInfo |
| 4228 |
*exception; |
| 4229 |
|
| 4230 |
Image |
| 4231 |
*image; |
| 4232 |
|
| 4233 |
ssize_t |
| 4234 |
count, |
| 4235 |
i; |
| 4236 |
|
| 4237 |
struct PackageInfo |
| 4238 |
*info; |
| 4239 |
|
| 4240 |
SV |
| 4241 |
*perl_exception, |
| 4242 |
*reference; |
| 4243 |
|
| 4244 |
PERL_UNUSED_VAR(ref); |
| 4245 |
PERL_UNUSED_VAR(ix); |
| 4246 |
exception=AcquireExceptionInfo(); |
| 4247 |
perl_exception=newSVpv("",0); |
| 4248 |
av=NULL; |
| 4249 |
if (sv_isobject(ST(0)) == 0) |
| 4250 |
{ |
| 4251 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 4252 |
PackageName); |
| 4253 |
goto PerlException; |
| 4254 |
} |
| 4255 |
reference=SvRV(ST(0)); |
| 4256 |
av=newAV(); |
| 4257 |
SvREFCNT_dec(av); |
| 4258 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 4259 |
if (image == (Image *) NULL) |
| 4260 |
{ |
| 4261 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 4262 |
PackageName); |
| 4263 |
goto PerlException; |
| 4264 |
} |
| 4265 |
distance=1.0; |
| 4266 |
for (i=2; i < items; i+=2) |
| 4267 |
{ |
| 4268 |
attribute=(char *) SvPV(ST(i-1),na); |
| 4269 |
switch (*attribute) |
| 4270 |
{ |
| 4271 |
case 'D': |
| 4272 |
case 'd': |
| 4273 |
{ |
| 4274 |
if (LocaleCompare(attribute,"distance") == 0) |
| 4275 |
{ |
| 4276 |
distance=StringToLong((char *) SvPV(ST(1),na)); |
| 4277 |
break; |
| 4278 |
} |
| 4279 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 4280 |
attribute); |
| 4281 |
break; |
| 4282 |
} |
| 4283 |
default: |
| 4284 |
{ |
| 4285 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 4286 |
attribute); |
| 4287 |
break; |
| 4288 |
} |
| 4289 |
} |
| 4290 |
} |
| 4291 |
count=0; |
| 4292 |
for ( ; image; image=image->next) |
| 4293 |
{ |
| 4294 |
ssize_t |
| 4295 |
j; |
| 4296 |
|
| 4297 |
channel_features=GetImageFeatures(image,distance,exception); |
| 4298 |
if (channel_features == (ChannelFeatures *) NULL) |
| 4299 |
continue; |
| 4300 |
count++; |
| 4301 |
for (j=0; j < 4; j++) |
| 4302 |
{ |
| 4303 |
for (i=0; i < (ssize_t) GetPixelChannels(image); i++) |
| 4304 |
{ |
| 4305 |
PixelChannel channel=GetPixelChannelChannel(image,i); |
| 4306 |
PixelTrait traits=GetPixelChannelTraits(image,channel); |
| 4307 |
if (traits == UndefinedPixelTrait) |
| 4308 |
continue; |
| 4309 |
EXTEND(sp,14*(i+1)*count); |
| 4310 |
ChannelFeatures(channel,j); |
| 4311 |
} |
| 4312 |
} |
| 4313 |
channel_features=(ChannelFeatures *) |
| 4314 |
RelinquishMagickMemory(channel_features); |
| 4315 |
} |
| 4316 |
|
| 4317 |
PerlException: |
| 4318 |
InheritPerlException(exception,perl_exception); |
| 4319 |
exception=DestroyExceptionInfo(exception); |
| 4320 |
SvREFCNT_dec(perl_exception); |
| 4321 |
} |
| 4322 |
|
| 4323 |
# |
| 4324 |
############################################################################### |
| 4325 |
# # |
| 4326 |
# # |
| 4327 |
# # |
| 4328 |
# F l a t t e n # |
| 4329 |
# # |
| 4330 |
# # |
| 4331 |
# # |
| 4332 |
############################################################################### |
| 4333 |
# |
| 4334 |
# |
| 4335 |
void |
| 4336 |
Flatten(ref,...) |
| 4337 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 4338 |
ALIAS: |
| 4339 |
FlattenImage = 1 |
| 4340 |
flatten = 2 |
| 4341 |
flattenimage = 3 |
| 4342 |
PPCODE: |
| 4343 |
{ |
| 4344 |
AV |
| 4345 |
*av; |
| 4346 |
|
| 4347 |
char |
| 4348 |
*attribute, |
| 4349 |
*p; |
| 4350 |
|
| 4351 |
ExceptionInfo |
| 4352 |
*exception; |
| 4353 |
|
| 4354 |
HV |
| 4355 |
*hv; |
| 4356 |
|
| 4357 |
Image |
| 4358 |
*image; |
| 4359 |
|
| 4360 |
PixelInfo |
| 4361 |
background_color; |
| 4362 |
|
| 4363 |
ssize_t |
| 4364 |
i; |
| 4365 |
|
| 4366 |
struct PackageInfo |
| 4367 |
*info; |
| 4368 |
|
| 4369 |
SV |
| 4370 |
*perl_exception, |
| 4371 |
*reference, |
| 4372 |
*rv, |
| 4373 |
*sv; |
| 4374 |
|
| 4375 |
PERL_UNUSED_VAR(ref); |
| 4376 |
PERL_UNUSED_VAR(ix); |
| 4377 |
exception=AcquireExceptionInfo(); |
| 4378 |
perl_exception=newSVpv("",0); |
| 4379 |
sv=NULL; |
| 4380 |
if (sv_isobject(ST(0)) == 0) |
| 4381 |
{ |
| 4382 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 4383 |
PackageName); |
| 4384 |
goto PerlException; |
| 4385 |
} |
| 4386 |
reference=SvRV(ST(0)); |
| 4387 |
hv=SvSTASH(reference); |
| 4388 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 4389 |
if (image == (Image *) NULL) |
| 4390 |
{ |
| 4391 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 4392 |
PackageName); |
| 4393 |
goto PerlException; |
| 4394 |
} |
| 4395 |
background_color=image->background_color; |
| 4396 |
if (items == 2) |
| 4397 |
(void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance, |
| 4398 |
&background_color,exception); |
| 4399 |
else |
| 4400 |
for (i=2; i < items; i+=2) |
| 4401 |
{ |
| 4402 |
attribute=(char *) SvPV(ST(i-1),na); |
| 4403 |
switch (*attribute) |
| 4404 |
{ |
| 4405 |
case 'B': |
| 4406 |
case 'b': |
| 4407 |
{ |
| 4408 |
if (LocaleCompare(attribute,"background") == 0) |
| 4409 |
{ |
| 4410 |
(void) QueryColorCompliance((char *) SvPV(ST(1),na), |
| 4411 |
AllCompliance,&background_color,exception); |
| 4412 |
break; |
| 4413 |
} |
| 4414 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 4415 |
attribute); |
| 4416 |
break; |
| 4417 |
} |
| 4418 |
default: |
| 4419 |
{ |
| 4420 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 4421 |
attribute); |
| 4422 |
break; |
| 4423 |
} |
| 4424 |
} |
| 4425 |
} |
| 4426 |
image->background_color=background_color; |
| 4427 |
image=MergeImageLayers(image,FlattenLayer,exception); |
| 4428 |
if (image == (Image *) NULL) |
| 4429 |
goto PerlException; |
| 4430 |
/* |
| 4431 |
Create blessed Perl array for the returned image. |
| 4432 |
*/ |
| 4433 |
av=newAV(); |
| 4434 |
ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv)); |
| 4435 |
SvREFCNT_dec(av); |
| 4436 |
AddImageToRegistry(sv,image); |
| 4437 |
rv=newRV(sv); |
| 4438 |
av_push(av,sv_bless(rv,hv)); |
| 4439 |
SvREFCNT_dec(sv); |
| 4440 |
info=GetPackageInfo(aTHX_ (void *) av,info,exception); |
| 4441 |
(void) FormatLocaleString(info->image_info->filename,MagickPathExtent, |
| 4442 |
"flatten-%.*s",(int) (MagickPathExtent-9), |
| 4443 |
((p=strrchr(image->filename,'/')) ? p+1 : image->filename)); |
| 4444 |
(void) CopyMagickString(image->filename,info->image_info->filename, |
| 4445 |
MagickPathExtent); |
| 4446 |
SetImageInfo(info->image_info,0,exception); |
| 4447 |
exception=DestroyExceptionInfo(exception); |
| 4448 |
SvREFCNT_dec(perl_exception); |
| 4449 |
XSRETURN(1); |
| 4450 |
|
| 4451 |
PerlException: |
| 4452 |
InheritPerlException(exception,perl_exception); |
| 4453 |
exception=DestroyExceptionInfo(exception); |
| 4454 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 4455 |
SvPOK_on(perl_exception); /* return messages in string context */ |
| 4456 |
ST(0)=sv_2mortal(perl_exception); |
| 4457 |
XSRETURN(1); |
| 4458 |
} |
| 4459 |
|
| 4460 |
# |
| 4461 |
############################################################################### |
| 4462 |
# # |
| 4463 |
# # |
| 4464 |
# # |
| 4465 |
# F x # |
| 4466 |
# # |
| 4467 |
# # |
| 4468 |
# # |
| 4469 |
############################################################################### |
| 4470 |
# |
| 4471 |
# |
| 4472 |
void |
| 4473 |
Fx(ref,...) |
| 4474 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 4475 |
ALIAS: |
| 4476 |
FxImage = 1 |
| 4477 |
fx = 2 |
| 4478 |
fximage = 3 |
| 4479 |
PPCODE: |
| 4480 |
{ |
| 4481 |
AV |
| 4482 |
*av; |
| 4483 |
|
| 4484 |
char |
| 4485 |
*attribute, |
| 4486 |
expression[MagickPathExtent]; |
| 4487 |
|
| 4488 |
ChannelType |
| 4489 |
channel, |
| 4490 |
channel_mask; |
| 4491 |
|
| 4492 |
ExceptionInfo |
| 4493 |
*exception; |
| 4494 |
|
| 4495 |
HV |
| 4496 |
*hv; |
| 4497 |
|
| 4498 |
Image |
| 4499 |
*image; |
| 4500 |
|
| 4501 |
ssize_t |
| 4502 |
i; |
| 4503 |
|
| 4504 |
struct PackageInfo |
| 4505 |
*info; |
| 4506 |
|
| 4507 |
SV |
| 4508 |
*av_reference, |
| 4509 |
*perl_exception, |
| 4510 |
*reference, |
| 4511 |
*rv, |
| 4512 |
*sv; |
| 4513 |
|
| 4514 |
PERL_UNUSED_VAR(ref); |
| 4515 |
PERL_UNUSED_VAR(ix); |
| 4516 |
exception=AcquireExceptionInfo(); |
| 4517 |
perl_exception=newSVpv("",0); |
| 4518 |
sv=NULL; |
| 4519 |
attribute=NULL; |
| 4520 |
av=NULL; |
| 4521 |
if (sv_isobject(ST(0)) == 0) |
| 4522 |
{ |
| 4523 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 4524 |
PackageName); |
| 4525 |
goto PerlException; |
| 4526 |
} |
| 4527 |
reference=SvRV(ST(0)); |
| 4528 |
hv=SvSTASH(reference); |
| 4529 |
av=newAV(); |
| 4530 |
av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv)); |
| 4531 |
SvREFCNT_dec(av); |
| 4532 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 4533 |
if (image == (Image *) NULL) |
| 4534 |
{ |
| 4535 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 4536 |
PackageName); |
| 4537 |
goto PerlException; |
| 4538 |
} |
| 4539 |
info=GetPackageInfo(aTHX_ (void *) av,info,exception); |
| 4540 |
/* |
| 4541 |
Get options. |
| 4542 |
*/ |
| 4543 |
channel=DefaultChannels; |
| 4544 |
(void) CopyMagickString(expression,"u",MagickPathExtent); |
| 4545 |
if (items == 2) |
| 4546 |
(void) CopyMagickString(expression,(char *) SvPV(ST(1),na), |
| 4547 |
MagickPathExtent); |
| 4548 |
else |
| 4549 |
for (i=2; i < items; i+=2) |
| 4550 |
{ |
| 4551 |
attribute=(char *) SvPV(ST(i-1),na); |
| 4552 |
switch (*attribute) |
| 4553 |
{ |
| 4554 |
case 'C': |
| 4555 |
case 'c': |
| 4556 |
{ |
| 4557 |
if (LocaleCompare(attribute,"channel") == 0) |
| 4558 |
{ |
| 4559 |
ssize_t |
| 4560 |
option; |
| 4561 |
|
| 4562 |
option=ParseChannelOption(SvPV(ST(i),na)); |
| 4563 |
if (option < 0) |
| 4564 |
{ |
| 4565 |
ThrowPerlException(exception,OptionError, |
| 4566 |
"UnrecognizedType",SvPV(ST(i),na)); |
| 4567 |
return; |
| 4568 |
} |
| 4569 |
channel=(ChannelType) option; |
| 4570 |
break; |
| 4571 |
} |
| 4572 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 4573 |
attribute); |
| 4574 |
break; |
| 4575 |
} |
| 4576 |
case 'E': |
| 4577 |
case 'e': |
| 4578 |
{ |
| 4579 |
if (LocaleCompare(attribute,"expression") == 0) |
| 4580 |
{ |
| 4581 |
(void) CopyMagickString(expression,SvPV(ST(i),na), |
| 4582 |
MagickPathExtent); |
| 4583 |
break; |
| 4584 |
} |
| 4585 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 4586 |
attribute); |
| 4587 |
break; |
| 4588 |
} |
| 4589 |
default: |
| 4590 |
{ |
| 4591 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 4592 |
attribute); |
| 4593 |
break; |
| 4594 |
} |
| 4595 |
} |
| 4596 |
} |
| 4597 |
channel_mask=SetImageChannelMask(image,channel); |
| 4598 |
image=FxImage(image,expression,exception); |
| 4599 |
if (image != (Image *) NULL) |
| 4600 |
(void) SetImageChannelMask(image,channel_mask); |
| 4601 |
if (image == (Image *) NULL) |
| 4602 |
goto PerlException; |
| 4603 |
for ( ; image; image=image->next) |
| 4604 |
{ |
| 4605 |
AddImageToRegistry(sv,image); |
| 4606 |
rv=newRV(sv); |
| 4607 |
av_push(av,sv_bless(rv,hv)); |
| 4608 |
SvREFCNT_dec(sv); |
| 4609 |
} |
| 4610 |
exception=DestroyExceptionInfo(exception); |
| 4611 |
ST(0)=av_reference; |
| 4612 |
SvREFCNT_dec(perl_exception); /* can't return warning messages */ |
| 4613 |
XSRETURN(1); |
| 4614 |
|
| 4615 |
PerlException: |
| 4616 |
InheritPerlException(exception,perl_exception); |
| 4617 |
exception=DestroyExceptionInfo(exception); |
| 4618 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 4619 |
SvPOK_on(perl_exception); |
| 4620 |
ST(0)=sv_2mortal(perl_exception); |
| 4621 |
XSRETURN(1); |
| 4622 |
} |
| 4623 |
|
| 4624 |
# |
| 4625 |
############################################################################### |
| 4626 |
# # |
| 4627 |
# # |
| 4628 |
# # |
| 4629 |
# G e t # |
| 4630 |
# # |
| 4631 |
# # |
| 4632 |
# # |
| 4633 |
############################################################################### |
| 4634 |
# |
| 4635 |
# |
| 4636 |
void |
| 4637 |
Get(ref,...) |
| 4638 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 4639 |
ALIAS: |
| 4640 |
GetAttributes = 1 |
| 4641 |
GetAttribute = 2 |
| 4642 |
get = 3 |
| 4643 |
getattributes = 4 |
| 4644 |
getattribute = 5 |
| 4645 |
PPCODE: |
| 4646 |
{ |
| 4647 |
char |
| 4648 |
*attribute, |
| 4649 |
color[MagickPathExtent]; |
| 4650 |
|
| 4651 |
const char |
| 4652 |
*value; |
| 4653 |
|
| 4654 |
ExceptionInfo |
| 4655 |
*exception; |
| 4656 |
|
| 4657 |
Image |
| 4658 |
*image; |
| 4659 |
|
| 4660 |
long |
| 4661 |
j; |
| 4662 |
|
| 4663 |
ssize_t |
| 4664 |
i; |
| 4665 |
|
| 4666 |
struct PackageInfo |
| 4667 |
*info; |
| 4668 |
|
| 4669 |
SV |
| 4670 |
*perl_exception, |
| 4671 |
*reference, |
| 4672 |
*s; |
| 4673 |
|
| 4674 |
PERL_UNUSED_VAR(ref); |
| 4675 |
PERL_UNUSED_VAR(ix); |
| 4676 |
exception=AcquireExceptionInfo(); |
| 4677 |
perl_exception=newSVpv("",0); |
| 4678 |
if (sv_isobject(ST(0)) == 0) |
| 4679 |
{ |
| 4680 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 4681 |
PackageName); |
| 4682 |
XSRETURN_EMPTY; |
| 4683 |
} |
| 4684 |
reference=SvRV(ST(0)); |
| 4685 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 4686 |
if (image == (Image *) NULL && !info) |
| 4687 |
XSRETURN_EMPTY; |
| 4688 |
EXTEND(sp,items); |
| 4689 |
for (i=1; i < items; i++) |
| 4690 |
{ |
| 4691 |
attribute=(char *) SvPV(ST(i),na); |
| 4692 |
s=NULL; |
| 4693 |
switch (*attribute) |
| 4694 |
{ |
| 4695 |
case 'A': |
| 4696 |
case 'a': |
| 4697 |
{ |
| 4698 |
if (LocaleCompare(attribute,"adjoin") == 0) |
| 4699 |
{ |
| 4700 |
if (info) |
| 4701 |
s=newSViv((ssize_t) info->image_info->adjoin); |
| 4702 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4703 |
continue; |
| 4704 |
} |
| 4705 |
if (LocaleCompare(attribute,"antialias") == 0) |
| 4706 |
{ |
| 4707 |
if (info) |
| 4708 |
s=newSViv((ssize_t) info->image_info->antialias); |
| 4709 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4710 |
continue; |
| 4711 |
} |
| 4712 |
if (LocaleCompare(attribute,"area") == 0) |
| 4713 |
{ |
| 4714 |
s=newSViv((MagickOffsetType) GetMagickResource(AreaResource)); |
| 4715 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4716 |
continue; |
| 4717 |
} |
| 4718 |
if (LocaleCompare(attribute,"attenuate") == 0) |
| 4719 |
{ |
| 4720 |
const char |
| 4721 |
*value; |
| 4722 |
|
| 4723 |
value=GetImageProperty(image,attribute,exception); |
| 4724 |
if (value != (const char *) NULL) |
| 4725 |
s=newSVpv(value,0); |
| 4726 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4727 |
continue; |
| 4728 |
} |
| 4729 |
if (LocaleCompare(attribute,"authenticate") == 0) |
| 4730 |
{ |
| 4731 |
if (info) |
| 4732 |
{ |
| 4733 |
const char |
| 4734 |
*option; |
| 4735 |
|
| 4736 |
option=GetImageOption(info->image_info,attribute); |
| 4737 |
if (option != (const char *) NULL) |
| 4738 |
s=newSVpv(option,0); |
| 4739 |
} |
| 4740 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4741 |
continue; |
| 4742 |
} |
| 4743 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 4744 |
attribute); |
| 4745 |
break; |
| 4746 |
} |
| 4747 |
case 'B': |
| 4748 |
case 'b': |
| 4749 |
{ |
| 4750 |
if (LocaleCompare(attribute,"background") == 0) |
| 4751 |
{ |
| 4752 |
if (image == (Image *) NULL) |
| 4753 |
break; |
| 4754 |
(void) FormatLocaleString(color,MagickPathExtent, |
| 4755 |
"%.20g,%.20g,%.20g,%.20g",(double) image->background_color.red, |
| 4756 |
(double) image->background_color.green, |
| 4757 |
(double) image->background_color.blue, |
| 4758 |
(double) image->background_color.alpha); |
| 4759 |
s=newSVpv(color,0); |
| 4760 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4761 |
continue; |
| 4762 |
} |
| 4763 |
if (LocaleCompare(attribute,"base-columns") == 0) |
| 4764 |
{ |
| 4765 |
if (image != (Image *) NULL) |
| 4766 |
s=newSViv((ssize_t) image->magick_columns); |
| 4767 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4768 |
continue; |
| 4769 |
} |
| 4770 |
if (LocaleCompare(attribute,"base-filename") == 0) |
| 4771 |
{ |
| 4772 |
if (image != (Image *) NULL) |
| 4773 |
s=newSVpv(image->magick_filename,0); |
| 4774 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4775 |
continue; |
| 4776 |
} |
| 4777 |
if (LocaleCompare(attribute,"base-height") == 0) |
| 4778 |
{ |
| 4779 |
if (image != (Image *) NULL) |
| 4780 |
s=newSViv((ssize_t) image->magick_rows); |
| 4781 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4782 |
continue; |
| 4783 |
} |
| 4784 |
if (LocaleCompare(attribute,"base-rows") == 0) |
| 4785 |
{ |
| 4786 |
if (image != (Image *) NULL) |
| 4787 |
s=newSViv((ssize_t) image->magick_rows); |
| 4788 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4789 |
continue; |
| 4790 |
} |
| 4791 |
if (LocaleCompare(attribute,"base-width") == 0) |
| 4792 |
{ |
| 4793 |
if (image != (Image *) NULL) |
| 4794 |
s=newSViv((ssize_t) image->magick_columns); |
| 4795 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4796 |
continue; |
| 4797 |
} |
| 4798 |
if (LocaleCompare(attribute,"blue-primary") == 0) |
| 4799 |
{ |
| 4800 |
if (image == (Image *) NULL) |
| 4801 |
break; |
| 4802 |
(void) FormatLocaleString(color,MagickPathExtent,"%.20g,%.20g", |
| 4803 |
image->chromaticity.blue_primary.x, |
| 4804 |
image->chromaticity.blue_primary.y); |
| 4805 |
s=newSVpv(color,0); |
| 4806 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4807 |
continue; |
| 4808 |
} |
| 4809 |
if (LocaleCompare(attribute,"bordercolor") == 0) |
| 4810 |
{ |
| 4811 |
if (image == (Image *) NULL) |
| 4812 |
break; |
| 4813 |
(void) FormatLocaleString(color,MagickPathExtent, |
| 4814 |
"%.20g,%.20g,%.20g,%.20g",(double) image->border_color.red, |
| 4815 |
(double) image->border_color.green, |
| 4816 |
(double) image->border_color.blue, |
| 4817 |
(double) image->border_color.alpha); |
| 4818 |
s=newSVpv(color,0); |
| 4819 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4820 |
continue; |
| 4821 |
} |
| 4822 |
if (LocaleCompare(attribute,"bounding-box") == 0) |
| 4823 |
{ |
| 4824 |
char |
| 4825 |
geometry[MagickPathExtent]; |
| 4826 |
|
| 4827 |
RectangleInfo |
| 4828 |
page; |
| 4829 |
|
| 4830 |
if (image == (Image *) NULL) |
| 4831 |
break; |
| 4832 |
page=GetImageBoundingBox(image,exception); |
| 4833 |
(void) FormatLocaleString(geometry,MagickPathExtent, |
| 4834 |
"%.20gx%.20g%+.20g%+.20g",(double) page.width,(double) |
| 4835 |
page.height,(double) page.x,(double) page.y); |
| 4836 |
s=newSVpv(geometry,0); |
| 4837 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4838 |
continue; |
| 4839 |
} |
| 4840 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 4841 |
attribute); |
| 4842 |
break; |
| 4843 |
} |
| 4844 |
case 'C': |
| 4845 |
case 'c': |
| 4846 |
{ |
| 4847 |
if (LocaleCompare(attribute,"class") == 0) |
| 4848 |
{ |
| 4849 |
if (image == (Image *) NULL) |
| 4850 |
break; |
| 4851 |
s=newSViv(image->storage_class); |
| 4852 |
(void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions, |
| 4853 |
image->storage_class)); |
| 4854 |
SvIOK_on(s); |
| 4855 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4856 |
continue; |
| 4857 |
} |
| 4858 |
if (LocaleCompare(attribute,"clip-mask") == 0) |
| 4859 |
{ |
| 4860 |
if (image != (Image *) NULL) |
| 4861 |
{ |
| 4862 |
Image |
| 4863 |
*mask_image; |
| 4864 |
|
| 4865 |
SV |
| 4866 |
*sv; |
| 4867 |
|
| 4868 |
sv=NULL; |
| 4869 |
if ((image->channels & WriteMaskChannel) == 0) |
| 4870 |
(void) ClipImage(image,exception); |
| 4871 |
mask_image=GetImageMask(image,ReadPixelMask,exception); |
| 4872 |
if (mask_image != (Image *) NULL) |
| 4873 |
{ |
| 4874 |
AddImageToRegistry(sv,mask_image); |
| 4875 |
s=sv_bless(newRV(sv),SvSTASH(reference)); |
| 4876 |
} |
| 4877 |
} |
| 4878 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4879 |
continue; |
| 4880 |
} |
| 4881 |
if (LocaleCompare(attribute,"clip-path") == 0) |
| 4882 |
{ |
| 4883 |
if (image != (Image *) NULL) |
| 4884 |
{ |
| 4885 |
Image |
| 4886 |
*mask_image; |
| 4887 |
|
| 4888 |
SV |
| 4889 |
*sv; |
| 4890 |
|
| 4891 |
sv=NULL; |
| 4892 |
if ((image->channels & WriteMaskChannel) == 0) |
| 4893 |
(void) ClipImage(image,exception); |
| 4894 |
mask_image=GetImageMask(image,ReadPixelMask,exception); |
| 4895 |
if (mask_image != (Image *) NULL) |
| 4896 |
{ |
| 4897 |
AddImageToRegistry(sv,mask_image); |
| 4898 |
s=sv_bless(newRV(sv),SvSTASH(reference)); |
| 4899 |
} |
| 4900 |
} |
| 4901 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4902 |
continue; |
| 4903 |
} |
| 4904 |
if (LocaleCompare(attribute,"compression") == 0) |
| 4905 |
{ |
| 4906 |
j=info ? info->image_info->compression : image ? |
| 4907 |
image->compression : UndefinedCompression; |
| 4908 |
if (info) |
| 4909 |
if (info->image_info->compression == UndefinedCompression) |
| 4910 |
j=image->compression; |
| 4911 |
s=newSViv(j); |
| 4912 |
(void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions, |
| 4913 |
j)); |
| 4914 |
SvIOK_on(s); |
| 4915 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4916 |
continue; |
| 4917 |
} |
| 4918 |
if (LocaleCompare(attribute,"colorspace") == 0) |
| 4919 |
{ |
| 4920 |
j=image ? image->colorspace : RGBColorspace; |
| 4921 |
s=newSViv(j); |
| 4922 |
(void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions, |
| 4923 |
j)); |
| 4924 |
SvIOK_on(s); |
| 4925 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4926 |
continue; |
| 4927 |
} |
| 4928 |
if (LocaleCompare(attribute,"colors") == 0) |
| 4929 |
{ |
| 4930 |
if (image != (Image *) NULL) |
| 4931 |
s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL, |
| 4932 |
exception)); |
| 4933 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4934 |
continue; |
| 4935 |
} |
| 4936 |
if (LocaleNCompare(attribute,"colormap",8) == 0) |
| 4937 |
{ |
| 4938 |
int |
| 4939 |
items; |
| 4940 |
|
| 4941 |
if (image == (Image *) NULL || !image->colormap) |
| 4942 |
break; |
| 4943 |
j=0; |
| 4944 |
items=sscanf(attribute,"%*[^[][%ld",&j); |
| 4945 |
(void) items; |
| 4946 |
if (j > (ssize_t) image->colors) |
| 4947 |
j%=(ssize_t) image->colors; |
| 4948 |
(void) FormatLocaleString(color,MagickPathExtent, |
| 4949 |
"%.20g,%.20g,%.20g,%.20g",(double) image->colormap[j].red, |
| 4950 |
(double) image->colormap[j].green, |
| 4951 |
(double) image->colormap[j].blue, |
| 4952 |
(double) image->colormap[j].alpha); |
| 4953 |
s=newSVpv(color,0); |
| 4954 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4955 |
continue; |
| 4956 |
} |
| 4957 |
if (LocaleCompare(attribute,"columns") == 0) |
| 4958 |
{ |
| 4959 |
if (image != (Image *) NULL) |
| 4960 |
s=newSViv((ssize_t) image->columns); |
| 4961 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4962 |
continue; |
| 4963 |
} |
| 4964 |
if (LocaleCompare(attribute,"comment") == 0) |
| 4965 |
{ |
| 4966 |
const char |
| 4967 |
*value; |
| 4968 |
|
| 4969 |
value=GetImageProperty(image,attribute,exception); |
| 4970 |
if (value != (const char *) NULL) |
| 4971 |
s=newSVpv(value,0); |
| 4972 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4973 |
continue; |
| 4974 |
} |
| 4975 |
if (LocaleCompare(attribute,"copyright") == 0) |
| 4976 |
{ |
| 4977 |
s=newSVpv(GetMagickCopyright(),0); |
| 4978 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4979 |
continue; |
| 4980 |
} |
| 4981 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 4982 |
attribute); |
| 4983 |
break; |
| 4984 |
} |
| 4985 |
case 'D': |
| 4986 |
case 'd': |
| 4987 |
{ |
| 4988 |
if (LocaleCompare(attribute,"density") == 0) |
| 4989 |
{ |
| 4990 |
char |
| 4991 |
geometry[MagickPathExtent]; |
| 4992 |
|
| 4993 |
if (image == (Image *) NULL) |
| 4994 |
break; |
| 4995 |
(void) FormatLocaleString(geometry,MagickPathExtent,"%.20gx%.20g", |
| 4996 |
image->resolution.x,image->resolution.y); |
| 4997 |
s=newSVpv(geometry,0); |
| 4998 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 4999 |
continue; |
| 5000 |
} |
| 5001 |
if (LocaleCompare(attribute,"delay") == 0) |
| 5002 |
{ |
| 5003 |
if (image != (Image *) NULL) |
| 5004 |
s=newSViv((ssize_t) image->delay); |
| 5005 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5006 |
continue; |
| 5007 |
} |
| 5008 |
if (LocaleCompare(attribute,"depth") == 0) |
| 5009 |
{ |
| 5010 |
s=newSViv(MAGICKCORE_QUANTUM_DEPTH); |
| 5011 |
if (image != (Image *) NULL) |
| 5012 |
s=newSViv((ssize_t) GetImageDepth(image,exception)); |
| 5013 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5014 |
continue; |
| 5015 |
} |
| 5016 |
if (LocaleCompare(attribute,"directory") == 0) |
| 5017 |
{ |
| 5018 |
if (image && image->directory) |
| 5019 |
s=newSVpv(image->directory,0); |
| 5020 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5021 |
continue; |
| 5022 |
} |
| 5023 |
if (LocaleCompare(attribute,"dispose") == 0) |
| 5024 |
{ |
| 5025 |
if (image == (Image *) NULL) |
| 5026 |
break; |
| 5027 |
|
| 5028 |
s=newSViv(image->dispose); |
| 5029 |
(void) sv_setpv(s, |
| 5030 |
CommandOptionToMnemonic(MagickDisposeOptions,image->dispose)); |
| 5031 |
SvIOK_on(s); |
| 5032 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5033 |
continue; |
| 5034 |
} |
| 5035 |
if (LocaleCompare(attribute,"disk") == 0) |
| 5036 |
{ |
| 5037 |
s=newSViv((MagickOffsetType) GetMagickResource(DiskResource)); |
| 5038 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5039 |
continue; |
| 5040 |
} |
| 5041 |
if (LocaleCompare(attribute,"dither") == 0) |
| 5042 |
{ |
| 5043 |
if (info) |
| 5044 |
s=newSViv((ssize_t) info->image_info->dither); |
| 5045 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5046 |
continue; |
| 5047 |
} |
| 5048 |
if (LocaleCompare(attribute,"display") == 0) /* same as server */ |
| 5049 |
{ |
| 5050 |
if (info && info->image_info->server_name) |
| 5051 |
s=newSVpv(info->image_info->server_name,0); |
| 5052 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5053 |
continue; |
| 5054 |
} |
| 5055 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5056 |
attribute); |
| 5057 |
break; |
| 5058 |
} |
| 5059 |
case 'E': |
| 5060 |
case 'e': |
| 5061 |
{ |
| 5062 |
if (LocaleCompare(attribute,"elapsed-time") == 0) |
| 5063 |
{ |
| 5064 |
if (image != (Image *) NULL) |
| 5065 |
s=newSVnv(GetElapsedTime(&image->timer)); |
| 5066 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5067 |
continue; |
| 5068 |
} |
| 5069 |
if (LocaleCompare(attribute,"endian") == 0) |
| 5070 |
{ |
| 5071 |
j=info ? info->image_info->endian : image ? image->endian : |
| 5072 |
UndefinedEndian; |
| 5073 |
if (info) |
| 5074 |
if (info->image_info->endian == UndefinedEndian) |
| 5075 |
j=image->endian; |
| 5076 |
s=newSViv(j); |
| 5077 |
(void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j)); |
| 5078 |
SvIOK_on(s); |
| 5079 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5080 |
continue; |
| 5081 |
} |
| 5082 |
if (LocaleCompare(attribute,"error") == 0) |
| 5083 |
{ |
| 5084 |
if (image != (Image *) NULL) |
| 5085 |
s=newSVnv(image->error.mean_error_per_pixel); |
| 5086 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5087 |
continue; |
| 5088 |
} |
| 5089 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5090 |
attribute); |
| 5091 |
break; |
| 5092 |
} |
| 5093 |
case 'F': |
| 5094 |
case 'f': |
| 5095 |
{ |
| 5096 |
if (LocaleCompare(attribute,"filesize") == 0) |
| 5097 |
{ |
| 5098 |
if (image != (Image *) NULL) |
| 5099 |
s=newSViv((ssize_t) GetBlobSize(image)); |
| 5100 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5101 |
continue; |
| 5102 |
} |
| 5103 |
if (LocaleCompare(attribute,"filename") == 0) |
| 5104 |
{ |
| 5105 |
if (image != (Image *) NULL) |
| 5106 |
s=newSVpv(image->filename,0); |
| 5107 |
else |
| 5108 |
if (info && *info->image_info->filename) |
| 5109 |
s=newSVpv(info->image_info->filename,0); |
| 5110 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5111 |
continue; |
| 5112 |
} |
| 5113 |
if (LocaleCompare(attribute,"filter") == 0) |
| 5114 |
{ |
| 5115 |
s=image ? newSViv(image->filter) : newSViv(0); |
| 5116 |
(void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions, |
| 5117 |
image->filter)); |
| 5118 |
SvIOK_on(s); |
| 5119 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5120 |
continue; |
| 5121 |
} |
| 5122 |
if (LocaleCompare(attribute,"font") == 0) |
| 5123 |
{ |
| 5124 |
if (info && info->image_info->font) |
| 5125 |
s=newSVpv(info->image_info->font,0); |
| 5126 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5127 |
continue; |
| 5128 |
} |
| 5129 |
if (LocaleCompare(attribute,"foreground") == 0) |
| 5130 |
continue; |
| 5131 |
if (LocaleCompare(attribute,"format") == 0) |
| 5132 |
{ |
| 5133 |
const MagickInfo |
| 5134 |
*magick_info; |
| 5135 |
|
| 5136 |
magick_info=(const MagickInfo *) NULL; |
| 5137 |
if (info && (*info->image_info->magick != '\0')) |
| 5138 |
magick_info=GetMagickInfo(info->image_info->magick,exception); |
| 5139 |
if (image != (Image *) NULL) |
| 5140 |
magick_info=GetMagickInfo(image->magick,exception); |
| 5141 |
if ((magick_info != (const MagickInfo *) NULL) && |
| 5142 |
(*magick_info->description != '\0')) |
| 5143 |
s=newSVpv((char *) magick_info->description,0); |
| 5144 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5145 |
continue; |
| 5146 |
} |
| 5147 |
if (LocaleCompare(attribute,"fuzz") == 0) |
| 5148 |
{ |
| 5149 |
if (info) |
| 5150 |
s=newSVnv(info->image_info->fuzz); |
| 5151 |
if (image != (Image *) NULL) |
| 5152 |
s=newSVnv(image->fuzz); |
| 5153 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5154 |
continue; |
| 5155 |
} |
| 5156 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5157 |
attribute); |
| 5158 |
break; |
| 5159 |
} |
| 5160 |
case 'G': |
| 5161 |
case 'g': |
| 5162 |
{ |
| 5163 |
if (LocaleCompare(attribute,"gamma") == 0) |
| 5164 |
{ |
| 5165 |
if (image != (Image *) NULL) |
| 5166 |
s=newSVnv(image->gamma); |
| 5167 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5168 |
continue; |
| 5169 |
} |
| 5170 |
if (LocaleCompare(attribute,"geometry") == 0) |
| 5171 |
{ |
| 5172 |
if (image && image->geometry) |
| 5173 |
s=newSVpv(image->geometry,0); |
| 5174 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5175 |
continue; |
| 5176 |
} |
| 5177 |
if (LocaleCompare(attribute,"gravity") == 0) |
| 5178 |
{ |
| 5179 |
s=image ? newSViv(image->gravity) : newSViv(0); |
| 5180 |
(void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions, |
| 5181 |
image->gravity)); |
| 5182 |
SvIOK_on(s); |
| 5183 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5184 |
continue; |
| 5185 |
} |
| 5186 |
if (LocaleCompare(attribute,"green-primary") == 0) |
| 5187 |
{ |
| 5188 |
if (image == (Image *) NULL) |
| 5189 |
break; |
| 5190 |
(void) FormatLocaleString(color,MagickPathExtent,"%.20g,%.20g", |
| 5191 |
image->chromaticity.green_primary.x, |
| 5192 |
image->chromaticity.green_primary.y); |
| 5193 |
s=newSVpv(color,0); |
| 5194 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5195 |
continue; |
| 5196 |
} |
| 5197 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5198 |
attribute); |
| 5199 |
break; |
| 5200 |
} |
| 5201 |
case 'H': |
| 5202 |
case 'h': |
| 5203 |
{ |
| 5204 |
if (LocaleCompare(attribute,"height") == 0) |
| 5205 |
{ |
| 5206 |
if (image != (Image *) NULL) |
| 5207 |
s=newSViv((ssize_t) image->rows); |
| 5208 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5209 |
continue; |
| 5210 |
} |
| 5211 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5212 |
attribute); |
| 5213 |
break; |
| 5214 |
} |
| 5215 |
case 'I': |
| 5216 |
case 'i': |
| 5217 |
{ |
| 5218 |
if (LocaleCompare(attribute,"icc") == 0) |
| 5219 |
{ |
| 5220 |
if (image != (Image *) NULL) |
| 5221 |
{ |
| 5222 |
const StringInfo |
| 5223 |
*profile; |
| 5224 |
|
| 5225 |
profile=GetImageProfile(image,"icc"); |
| 5226 |
if (profile != (StringInfo *) NULL) |
| 5227 |
s=newSVpv((const char *) GetStringInfoDatum(profile), |
| 5228 |
GetStringInfoLength(profile)); |
| 5229 |
} |
| 5230 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5231 |
continue; |
| 5232 |
} |
| 5233 |
if (LocaleCompare(attribute,"icm") == 0) |
| 5234 |
{ |
| 5235 |
if (image != (Image *) NULL) |
| 5236 |
{ |
| 5237 |
const StringInfo |
| 5238 |
*profile; |
| 5239 |
|
| 5240 |
profile=GetImageProfile(image,"icm"); |
| 5241 |
if (profile != (const StringInfo *) NULL) |
| 5242 |
s=newSVpv((const char *) GetStringInfoDatum(profile), |
| 5243 |
GetStringInfoLength(profile)); |
| 5244 |
} |
| 5245 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5246 |
continue; |
| 5247 |
} |
| 5248 |
if (LocaleCompare(attribute,"id") == 0) |
| 5249 |
{ |
| 5250 |
if (image != (Image *) NULL) |
| 5251 |
{ |
| 5252 |
char |
| 5253 |
key[MagickPathExtent]; |
| 5254 |
|
| 5255 |
MagickBooleanType |
| 5256 |
status; |
| 5257 |
|
| 5258 |
static ssize_t |
| 5259 |
id = 0; |
| 5260 |
|
| 5261 |
(void) FormatLocaleString(key,MagickPathExtent,"%.20g\n",(double) |
| 5262 |
id); |
| 5263 |
status=SetImageRegistry(ImageRegistryType,key,image, |
| 5264 |
exception); |
| 5265 |
(void) status; |
| 5266 |
s=newSViv(id++); |
| 5267 |
} |
| 5268 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5269 |
continue; |
| 5270 |
} |
| 5271 |
if (LocaleNCompare(attribute,"index",5) == 0) |
| 5272 |
{ |
| 5273 |
char |
| 5274 |
name[MagickPathExtent]; |
| 5275 |
|
| 5276 |
int |
| 5277 |
items; |
| 5278 |
|
| 5279 |
long |
| 5280 |
x, |
| 5281 |
y; |
| 5282 |
|
| 5283 |
const Quantum |
| 5284 |
*p; |
| 5285 |
|
| 5286 |
CacheView |
| 5287 |
*image_view; |
| 5288 |
|
| 5289 |
if (image == (Image *) NULL) |
| 5290 |
break; |
| 5291 |
if (image->storage_class != PseudoClass) |
| 5292 |
break; |
| 5293 |
x=0; |
| 5294 |
y=0; |
| 5295 |
items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y); |
| 5296 |
(void) items; |
| 5297 |
image_view=AcquireVirtualCacheView(image,exception); |
| 5298 |
p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception); |
| 5299 |
if (p != (const Quantum *) NULL) |
| 5300 |
{ |
| 5301 |
(void) FormatLocaleString(name,MagickPathExtent,QuantumFormat, |
| 5302 |
GetPixelIndex(image,p)); |
| 5303 |
s=newSVpv(name,0); |
| 5304 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5305 |
} |
| 5306 |
image_view=DestroyCacheView(image_view); |
| 5307 |
continue; |
| 5308 |
} |
| 5309 |
if (LocaleCompare(attribute,"iptc") == 0) |
| 5310 |
{ |
| 5311 |
if (image != (Image *) NULL) |
| 5312 |
{ |
| 5313 |
const StringInfo |
| 5314 |
*profile; |
| 5315 |
|
| 5316 |
profile=GetImageProfile(image,"iptc"); |
| 5317 |
if (profile != (const StringInfo *) NULL) |
| 5318 |
s=newSVpv((const char *) GetStringInfoDatum(profile), |
| 5319 |
GetStringInfoLength(profile)); |
| 5320 |
} |
| 5321 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5322 |
continue; |
| 5323 |
} |
| 5324 |
if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */ |
| 5325 |
{ |
| 5326 |
if (image != (Image *) NULL) |
| 5327 |
s=newSViv((ssize_t) image->iterations); |
| 5328 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5329 |
continue; |
| 5330 |
} |
| 5331 |
if (LocaleCompare(attribute,"interlace") == 0) |
| 5332 |
{ |
| 5333 |
j=info ? info->image_info->interlace : image ? image->interlace : |
| 5334 |
UndefinedInterlace; |
| 5335 |
if (info) |
| 5336 |
if (info->image_info->interlace == UndefinedInterlace) |
| 5337 |
j=image->interlace; |
| 5338 |
s=newSViv(j); |
| 5339 |
(void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions, |
| 5340 |
j)); |
| 5341 |
SvIOK_on(s); |
| 5342 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5343 |
continue; |
| 5344 |
} |
| 5345 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5346 |
attribute); |
| 5347 |
break; |
| 5348 |
} |
| 5349 |
case 'L': |
| 5350 |
case 'l': |
| 5351 |
{ |
| 5352 |
if (LocaleCompare(attribute,"label") == 0) |
| 5353 |
{ |
| 5354 |
const char |
| 5355 |
*value; |
| 5356 |
|
| 5357 |
if (image == (Image *) NULL) |
| 5358 |
break; |
| 5359 |
value=GetImageProperty(image,"Label",exception); |
| 5360 |
if (value != (const char *) NULL) |
| 5361 |
s=newSVpv(value,0); |
| 5362 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5363 |
continue; |
| 5364 |
} |
| 5365 |
if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */ |
| 5366 |
{ |
| 5367 |
if (image != (Image *) NULL) |
| 5368 |
s=newSViv((ssize_t) image->iterations); |
| 5369 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5370 |
continue; |
| 5371 |
} |
| 5372 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5373 |
attribute); |
| 5374 |
break; |
| 5375 |
} |
| 5376 |
case 'M': |
| 5377 |
case 'm': |
| 5378 |
{ |
| 5379 |
if (LocaleCompare(attribute,"magick") == 0) |
| 5380 |
{ |
| 5381 |
if (info && *info->image_info->magick) |
| 5382 |
s=newSVpv(info->image_info->magick,0); |
| 5383 |
if (image != (Image *) NULL) |
| 5384 |
s=newSVpv(image->magick,0); |
| 5385 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5386 |
continue; |
| 5387 |
} |
| 5388 |
if (LocaleCompare(attribute,"map") == 0) |
| 5389 |
{ |
| 5390 |
s=newSViv((MagickOffsetType) GetMagickResource(MapResource)); |
| 5391 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5392 |
continue; |
| 5393 |
} |
| 5394 |
if (LocaleCompare(attribute,"maximum-error") == 0) |
| 5395 |
{ |
| 5396 |
if (image != (Image *) NULL) |
| 5397 |
s=newSVnv(image->error.normalized_maximum_error); |
| 5398 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5399 |
continue; |
| 5400 |
} |
| 5401 |
if (LocaleCompare(attribute,"memory") == 0) |
| 5402 |
{ |
| 5403 |
s=newSViv((MagickOffsetType) GetMagickResource(MemoryResource)); |
| 5404 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5405 |
continue; |
| 5406 |
} |
| 5407 |
if (LocaleCompare(attribute,"mean-error") == 0) |
| 5408 |
{ |
| 5409 |
if (image != (Image *) NULL) |
| 5410 |
s=newSVnv(image->error.normalized_mean_error); |
| 5411 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5412 |
continue; |
| 5413 |
} |
| 5414 |
if (LocaleCompare(attribute,"mime") == 0) |
| 5415 |
{ |
| 5416 |
if (info && *info->image_info->magick) |
| 5417 |
s=newSVpv(MagickToMime(info->image_info->magick),0); |
| 5418 |
if (image != (Image *) NULL) |
| 5419 |
s=newSVpv(MagickToMime(image->magick),0); |
| 5420 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5421 |
continue; |
| 5422 |
} |
| 5423 |
if (LocaleCompare(attribute,"mattecolor") == 0) |
| 5424 |
{ |
| 5425 |
if (image == (Image *) NULL) |
| 5426 |
break; |
| 5427 |
(void) FormatLocaleString(color,MagickPathExtent, |
| 5428 |
"%.20g,%.20g,%.20g,%.20g",(double) image->alpha_color.red, |
| 5429 |
(double) image->alpha_color.green, |
| 5430 |
(double) image->alpha_color.blue, |
| 5431 |
(double) image->alpha_color.alpha); |
| 5432 |
s=newSVpv(color,0); |
| 5433 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5434 |
continue; |
| 5435 |
} |
| 5436 |
if (LocaleCompare(attribute,"matte") == 0) |
| 5437 |
{ |
| 5438 |
if (image != (Image *) NULL) |
| 5439 |
s=newSViv((ssize_t) image->alpha_trait != UndefinedPixelTrait ? |
| 5440 |
1 : 0); |
| 5441 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5442 |
continue; |
| 5443 |
} |
| 5444 |
if (LocaleCompare(attribute,"mime") == 0) |
| 5445 |
{ |
| 5446 |
const char |
| 5447 |
*magick; |
| 5448 |
|
| 5449 |
magick=NULL; |
| 5450 |
if (info && *info->image_info->magick) |
| 5451 |
magick=info->image_info->magick; |
| 5452 |
if (image != (Image *) NULL) |
| 5453 |
magick=image->magick; |
| 5454 |
if (magick) |
| 5455 |
{ |
| 5456 |
char |
| 5457 |
*mime; |
| 5458 |
|
| 5459 |
mime=MagickToMime(magick); |
| 5460 |
s=newSVpv(mime,0); |
| 5461 |
mime=(char *) RelinquishMagickMemory(mime); |
| 5462 |
} |
| 5463 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5464 |
continue; |
| 5465 |
} |
| 5466 |
if (LocaleCompare(attribute,"monochrome") == 0) |
| 5467 |
{ |
| 5468 |
if (image == (Image *) NULL) |
| 5469 |
continue; |
| 5470 |
j=info ? info->image_info->monochrome : |
| 5471 |
SetImageMonochrome(image,exception); |
| 5472 |
s=newSViv(j); |
| 5473 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5474 |
continue; |
| 5475 |
} |
| 5476 |
if (LocaleCompare(attribute,"montage") == 0) |
| 5477 |
{ |
| 5478 |
if (image && image->montage) |
| 5479 |
s=newSVpv(image->montage,0); |
| 5480 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5481 |
continue; |
| 5482 |
} |
| 5483 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5484 |
attribute); |
| 5485 |
break; |
| 5486 |
} |
| 5487 |
case 'O': |
| 5488 |
case 'o': |
| 5489 |
{ |
| 5490 |
if (LocaleCompare(attribute,"orientation") == 0) |
| 5491 |
{ |
| 5492 |
j=info ? info->image_info->orientation : image ? |
| 5493 |
image->orientation : UndefinedOrientation; |
| 5494 |
if (info) |
| 5495 |
if (info->image_info->orientation == UndefinedOrientation) |
| 5496 |
j=image->orientation; |
| 5497 |
s=newSViv(j); |
| 5498 |
(void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions, |
| 5499 |
j)); |
| 5500 |
SvIOK_on(s); |
| 5501 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5502 |
continue; |
| 5503 |
} |
| 5504 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5505 |
attribute); |
| 5506 |
break; |
| 5507 |
} |
| 5508 |
case 'P': |
| 5509 |
case 'p': |
| 5510 |
{ |
| 5511 |
if (LocaleCompare(attribute,"page") == 0) |
| 5512 |
{ |
| 5513 |
if (info && info->image_info->page) |
| 5514 |
s=newSVpv(info->image_info->page,0); |
| 5515 |
if (image != (Image *) NULL) |
| 5516 |
{ |
| 5517 |
char |
| 5518 |
geometry[MagickPathExtent]; |
| 5519 |
|
| 5520 |
(void) FormatLocaleString(geometry,MagickPathExtent, |
| 5521 |
"%.20gx%.20g%+.20g%+.20g",(double) image->page.width, |
| 5522 |
(double) image->page.height,(double) image->page.x,(double) |
| 5523 |
image->page.y); |
| 5524 |
s=newSVpv(geometry,0); |
| 5525 |
} |
| 5526 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5527 |
continue; |
| 5528 |
} |
| 5529 |
if (LocaleCompare(attribute,"page.x") == 0) |
| 5530 |
{ |
| 5531 |
if (image != (Image *) NULL) |
| 5532 |
s=newSViv((ssize_t) image->page.x); |
| 5533 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5534 |
continue; |
| 5535 |
} |
| 5536 |
if (LocaleCompare(attribute,"page.y") == 0) |
| 5537 |
{ |
| 5538 |
if (image != (Image *) NULL) |
| 5539 |
s=newSViv((ssize_t) image->page.y); |
| 5540 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5541 |
continue; |
| 5542 |
} |
| 5543 |
if (LocaleNCompare(attribute,"pixel",5) == 0) |
| 5544 |
{ |
| 5545 |
char |
| 5546 |
tuple[MagickPathExtent]; |
| 5547 |
|
| 5548 |
int |
| 5549 |
items; |
| 5550 |
|
| 5551 |
long |
| 5552 |
x, |
| 5553 |
y; |
| 5554 |
|
| 5555 |
const Quantum |
| 5556 |
*p; |
| 5557 |
|
| 5558 |
if (image == (Image *) NULL) |
| 5559 |
break; |
| 5560 |
x=0; |
| 5561 |
y=0; |
| 5562 |
items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y); |
| 5563 |
(void) items; |
| 5564 |
p=GetVirtualPixels(image,x,y,1,1,exception); |
| 5565 |
if (image->colorspace != CMYKColorspace) |
| 5566 |
(void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat "," |
| 5567 |
QuantumFormat "," QuantumFormat "," QuantumFormat, |
| 5568 |
GetPixelRed(image,p),GetPixelGreen(image,p), |
| 5569 |
GetPixelBlue(image,p),GetPixelAlpha(image,p)); |
| 5570 |
else |
| 5571 |
(void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat "," |
| 5572 |
QuantumFormat "," QuantumFormat "," QuantumFormat "," |
| 5573 |
QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p), |
| 5574 |
GetPixelBlue(image,p),GetPixelBlack(image,p), |
| 5575 |
GetPixelAlpha(image,p)); |
| 5576 |
s=newSVpv(tuple,0); |
| 5577 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5578 |
continue; |
| 5579 |
} |
| 5580 |
if (LocaleCompare(attribute,"pointsize") == 0) |
| 5581 |
{ |
| 5582 |
if (info) |
| 5583 |
s=newSViv((ssize_t) info->image_info->pointsize); |
| 5584 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5585 |
continue; |
| 5586 |
} |
| 5587 |
if (LocaleCompare(attribute,"precision") == 0) |
| 5588 |
{ |
| 5589 |
s=newSViv((ssize_t) GetMagickPrecision()); |
| 5590 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5591 |
continue; |
| 5592 |
} |
| 5593 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5594 |
attribute); |
| 5595 |
break; |
| 5596 |
} |
| 5597 |
case 'Q': |
| 5598 |
case 'q': |
| 5599 |
{ |
| 5600 |
if (LocaleCompare(attribute,"quality") == 0) |
| 5601 |
{ |
| 5602 |
if (info) |
| 5603 |
s=newSViv((ssize_t) info->image_info->quality); |
| 5604 |
if (image != (Image *) NULL) |
| 5605 |
s=newSViv((ssize_t) image->quality); |
| 5606 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5607 |
continue; |
| 5608 |
} |
| 5609 |
if (LocaleCompare(attribute,"quantum") == 0) |
| 5610 |
{ |
| 5611 |
if (info) |
| 5612 |
s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH); |
| 5613 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5614 |
continue; |
| 5615 |
} |
| 5616 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5617 |
attribute); |
| 5618 |
break; |
| 5619 |
} |
| 5620 |
case 'R': |
| 5621 |
case 'r': |
| 5622 |
{ |
| 5623 |
if (LocaleCompare(attribute,"rendering-intent") == 0) |
| 5624 |
{ |
| 5625 |
s=newSViv(image->rendering_intent); |
| 5626 |
(void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions, |
| 5627 |
image->rendering_intent)); |
| 5628 |
SvIOK_on(s); |
| 5629 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5630 |
continue; |
| 5631 |
} |
| 5632 |
if (LocaleCompare(attribute,"red-primary") == 0) |
| 5633 |
{ |
| 5634 |
if (image == (Image *) NULL) |
| 5635 |
break; |
| 5636 |
(void) FormatLocaleString(color,MagickPathExtent,"%.20g,%.20g", |
| 5637 |
image->chromaticity.red_primary.x, |
| 5638 |
image->chromaticity.red_primary.y); |
| 5639 |
s=newSVpv(color,0); |
| 5640 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5641 |
continue; |
| 5642 |
} |
| 5643 |
if (LocaleNCompare(attribute,"registry:",9) == 0) |
| 5644 |
{ |
| 5645 |
const char |
| 5646 |
*value; |
| 5647 |
|
| 5648 |
value=(const char *) GetImageRegistry(StringRegistryType, |
| 5649 |
attribute+9,exception); |
| 5650 |
if (value != (const char *) NULL) |
| 5651 |
s=newSVpv(value,0); |
| 5652 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5653 |
continue; |
| 5654 |
} |
| 5655 |
if (LocaleCompare(attribute,"rows") == 0) |
| 5656 |
{ |
| 5657 |
if (image != (Image *) NULL) |
| 5658 |
s=newSViv((ssize_t) image->rows); |
| 5659 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5660 |
continue; |
| 5661 |
} |
| 5662 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5663 |
attribute); |
| 5664 |
break; |
| 5665 |
} |
| 5666 |
case 'S': |
| 5667 |
case 's': |
| 5668 |
{ |
| 5669 |
if (LocaleCompare(attribute,"sampling-factor") == 0) |
| 5670 |
{ |
| 5671 |
if (info && info->image_info->sampling_factor) |
| 5672 |
s=newSVpv(info->image_info->sampling_factor,0); |
| 5673 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5674 |
continue; |
| 5675 |
} |
| 5676 |
if (LocaleCompare(attribute,"server") == 0) /* same as display */ |
| 5677 |
{ |
| 5678 |
if (info && info->image_info->server_name) |
| 5679 |
s=newSVpv(info->image_info->server_name,0); |
| 5680 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5681 |
continue; |
| 5682 |
} |
| 5683 |
if (LocaleCompare(attribute,"size") == 0) |
| 5684 |
{ |
| 5685 |
if (info && info->image_info->size) |
| 5686 |
s=newSVpv(info->image_info->size,0); |
| 5687 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5688 |
continue; |
| 5689 |
} |
| 5690 |
if (LocaleCompare(attribute,"scene") == 0) |
| 5691 |
{ |
| 5692 |
if (image != (Image *) NULL) |
| 5693 |
s=newSViv((ssize_t) image->scene); |
| 5694 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5695 |
continue; |
| 5696 |
} |
| 5697 |
if (LocaleCompare(attribute,"scenes") == 0) |
| 5698 |
{ |
| 5699 |
if (image != (Image *) NULL) |
| 5700 |
s=newSViv((ssize_t) info->image_info->number_scenes); |
| 5701 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5702 |
continue; |
| 5703 |
} |
| 5704 |
if (LocaleCompare(attribute,"signature") == 0) |
| 5705 |
{ |
| 5706 |
const char |
| 5707 |
*value; |
| 5708 |
|
| 5709 |
if (image == (Image *) NULL) |
| 5710 |
break; |
| 5711 |
(void) SignatureImage(image,exception); |
| 5712 |
value=GetImageProperty(image,"Signature",exception); |
| 5713 |
if (value != (const char *) NULL) |
| 5714 |
s=newSVpv(value,0); |
| 5715 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5716 |
continue; |
| 5717 |
} |
| 5718 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5719 |
attribute); |
| 5720 |
break; |
| 5721 |
} |
| 5722 |
case 'T': |
| 5723 |
case 't': |
| 5724 |
{ |
| 5725 |
if (LocaleCompare(attribute,"taint") == 0) |
| 5726 |
{ |
| 5727 |
if (image != (Image *) NULL) |
| 5728 |
s=newSViv((ssize_t) IsTaintImage(image)); |
| 5729 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5730 |
continue; |
| 5731 |
} |
| 5732 |
if (LocaleCompare(attribute,"texture") == 0) |
| 5733 |
{ |
| 5734 |
if (info && info->image_info->texture) |
| 5735 |
s=newSVpv(info->image_info->texture,0); |
| 5736 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5737 |
continue; |
| 5738 |
} |
| 5739 |
if (LocaleCompare(attribute,"title") == 0) |
| 5740 |
{ |
| 5741 |
if (image != (Image *) NULL) |
| 5742 |
s=newSVpv(image->magick_filename,0); |
| 5743 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5744 |
continue; |
| 5745 |
} |
| 5746 |
if (LocaleCompare(attribute,"total-ink-density") == 0) |
| 5747 |
{ |
| 5748 |
s=newSViv(MAGICKCORE_QUANTUM_DEPTH); |
| 5749 |
if (image != (Image *) NULL) |
| 5750 |
s=newSVnv(GetImageTotalInkDensity(image,exception)); |
| 5751 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5752 |
continue; |
| 5753 |
} |
| 5754 |
if (LocaleCompare(attribute,"transparent-color") == 0) |
| 5755 |
{ |
| 5756 |
if (image == (Image *) NULL) |
| 5757 |
break; |
| 5758 |
(void) FormatLocaleString(color,MagickPathExtent, |
| 5759 |
"%.20g,%.20g,%.20g,%.20g",(double) image->transparent_color.red, |
| 5760 |
(double) image->transparent_color.green, |
| 5761 |
(double) image->transparent_color.blue, |
| 5762 |
(double) image->transparent_color.alpha); |
| 5763 |
s=newSVpv(color,0); |
| 5764 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5765 |
continue; |
| 5766 |
} |
| 5767 |
if (LocaleCompare(attribute,"type") == 0) |
| 5768 |
{ |
| 5769 |
if (image == (Image *) NULL) |
| 5770 |
break; |
| 5771 |
j=(ssize_t) GetImageType(image); |
| 5772 |
s=newSViv(j); |
| 5773 |
(void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j)); |
| 5774 |
SvIOK_on(s); |
| 5775 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5776 |
continue; |
| 5777 |
} |
| 5778 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5779 |
attribute); |
| 5780 |
break; |
| 5781 |
} |
| 5782 |
case 'U': |
| 5783 |
case 'u': |
| 5784 |
{ |
| 5785 |
if (LocaleCompare(attribute,"units") == 0) |
| 5786 |
{ |
| 5787 |
j=info ? info->image_info->units : image ? image->units : |
| 5788 |
UndefinedResolution; |
| 5789 |
if (info) |
| 5790 |
if (info->image_info->units == UndefinedResolution) |
| 5791 |
j=image->units; |
| 5792 |
if (j == UndefinedResolution) |
| 5793 |
s=newSVpv("undefined units",0); |
| 5794 |
else |
| 5795 |
if (j == PixelsPerInchResolution) |
| 5796 |
s=newSVpv("pixels / inch",0); |
| 5797 |
else |
| 5798 |
s=newSVpv("pixels / centimeter",0); |
| 5799 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5800 |
continue; |
| 5801 |
} |
| 5802 |
if (LocaleCompare(attribute,"user-time") == 0) |
| 5803 |
{ |
| 5804 |
if (image != (Image *) NULL) |
| 5805 |
s=newSVnv(GetUserTime(&image->timer)); |
| 5806 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5807 |
continue; |
| 5808 |
} |
| 5809 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5810 |
attribute); |
| 5811 |
break; |
| 5812 |
} |
| 5813 |
case 'V': |
| 5814 |
case 'v': |
| 5815 |
{ |
| 5816 |
if (LocaleCompare(attribute,"verbose") == 0) |
| 5817 |
{ |
| 5818 |
if (info) |
| 5819 |
s=newSViv((ssize_t) info->image_info->verbose); |
| 5820 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5821 |
continue; |
| 5822 |
} |
| 5823 |
if (LocaleCompare(attribute,"version") == 0) |
| 5824 |
{ |
| 5825 |
s=newSVpv(GetMagickVersion((size_t *) NULL),0); |
| 5826 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5827 |
continue; |
| 5828 |
} |
| 5829 |
if (LocaleCompare(attribute,"virtual-pixel") == 0) |
| 5830 |
{ |
| 5831 |
if (image == (Image *) NULL) |
| 5832 |
break; |
| 5833 |
j=(ssize_t) GetImageVirtualPixelMethod(image); |
| 5834 |
s=newSViv(j); |
| 5835 |
(void) sv_setpv(s,CommandOptionToMnemonic( |
| 5836 |
MagickVirtualPixelOptions,j)); |
| 5837 |
SvIOK_on(s); |
| 5838 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5839 |
continue; |
| 5840 |
} |
| 5841 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5842 |
attribute); |
| 5843 |
break; |
| 5844 |
} |
| 5845 |
case 'W': |
| 5846 |
case 'w': |
| 5847 |
{ |
| 5848 |
if (LocaleCompare(attribute,"white-point") == 0) |
| 5849 |
{ |
| 5850 |
if (image == (Image *) NULL) |
| 5851 |
break; |
| 5852 |
(void) FormatLocaleString(color,MagickPathExtent,"%.20g,%.20g", |
| 5853 |
image->chromaticity.white_point.x, |
| 5854 |
image->chromaticity.white_point.y); |
| 5855 |
s=newSVpv(color,0); |
| 5856 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5857 |
continue; |
| 5858 |
} |
| 5859 |
if (LocaleCompare(attribute,"width") == 0) |
| 5860 |
{ |
| 5861 |
if (image != (Image *) NULL) |
| 5862 |
s=newSViv((ssize_t) image->columns); |
| 5863 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5864 |
continue; |
| 5865 |
} |
| 5866 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5867 |
attribute); |
| 5868 |
break; |
| 5869 |
} |
| 5870 |
case 'X': |
| 5871 |
case 'x': |
| 5872 |
{ |
| 5873 |
if (LocaleCompare(attribute,"xmp") == 0) |
| 5874 |
{ |
| 5875 |
if (image != (Image *) NULL) |
| 5876 |
{ |
| 5877 |
const StringInfo |
| 5878 |
*profile; |
| 5879 |
|
| 5880 |
profile=GetImageProfile(image,"xmp"); |
| 5881 |
if (profile != (StringInfo *) NULL) |
| 5882 |
s=newSVpv((const char *) GetStringInfoDatum(profile), |
| 5883 |
GetStringInfoLength(profile)); |
| 5884 |
} |
| 5885 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5886 |
continue; |
| 5887 |
} |
| 5888 |
if (LocaleCompare(attribute,"x-resolution") == 0) |
| 5889 |
{ |
| 5890 |
if (image != (Image *) NULL) |
| 5891 |
s=newSVnv(image->resolution.x); |
| 5892 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5893 |
continue; |
| 5894 |
} |
| 5895 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5896 |
attribute); |
| 5897 |
break; |
| 5898 |
} |
| 5899 |
case 'Y': |
| 5900 |
case 'y': |
| 5901 |
{ |
| 5902 |
if (LocaleCompare(attribute,"y-resolution") == 0) |
| 5903 |
{ |
| 5904 |
if (image != (Image *) NULL) |
| 5905 |
s=newSVnv(image->resolution.y); |
| 5906 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5907 |
continue; |
| 5908 |
} |
| 5909 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5910 |
attribute); |
| 5911 |
break; |
| 5912 |
} |
| 5913 |
default: |
| 5914 |
break; |
| 5915 |
} |
| 5916 |
if (image == (Image *) NULL) |
| 5917 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5918 |
attribute) |
| 5919 |
else |
| 5920 |
{ |
| 5921 |
value=GetImageProperty(image,attribute,exception); |
| 5922 |
if (value != (const char *) NULL) |
| 5923 |
{ |
| 5924 |
s=newSVpv(value,0); |
| 5925 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5926 |
} |
| 5927 |
else |
| 5928 |
if (*attribute != '%') |
| 5929 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 5930 |
attribute) |
| 5931 |
else |
| 5932 |
{ |
| 5933 |
char |
| 5934 |
*meta; |
| 5935 |
|
| 5936 |
meta=InterpretImageProperties(info ? info->image_info : |
| 5937 |
(ImageInfo *) NULL,image,attribute,exception); |
| 5938 |
s=newSVpv(meta,0); |
| 5939 |
PUSHs(s ? sv_2mortal(s) : &sv_undef); |
| 5940 |
meta=(char *) RelinquishMagickMemory(meta); |
| 5941 |
} |
| 5942 |
} |
| 5943 |
} |
| 5944 |
exception=DestroyExceptionInfo(exception); |
| 5945 |
SvREFCNT_dec(perl_exception); /* can't return warning messages */ |
| 5946 |
} |
| 5947 |
|
| 5948 |
# |
| 5949 |
############################################################################### |
| 5950 |
# # |
| 5951 |
# # |
| 5952 |
# # |
| 5953 |
# G e t A u t h e n t i c P i x e l s # |
| 5954 |
# # |
| 5955 |
# # |
| 5956 |
# # |
| 5957 |
############################################################################### |
| 5958 |
# |
| 5959 |
# |
| 5960 |
void * |
| 5961 |
GetAuthenticPixels(ref,...) |
| 5962 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 5963 |
ALIAS: |
| 5964 |
getauthenticpixels = 1 |
| 5965 |
GetImagePixels = 2 |
| 5966 |
getimagepixels = 3 |
| 5967 |
CODE: |
| 5968 |
{ |
| 5969 |
char |
| 5970 |
*attribute; |
| 5971 |
|
| 5972 |
ExceptionInfo |
| 5973 |
*exception; |
| 5974 |
|
| 5975 |
Image |
| 5976 |
*image; |
| 5977 |
|
| 5978 |
RectangleInfo |
| 5979 |
region; |
| 5980 |
|
| 5981 |
ssize_t |
| 5982 |
i; |
| 5983 |
|
| 5984 |
struct PackageInfo |
| 5985 |
*info; |
| 5986 |
|
| 5987 |
SV |
| 5988 |
*perl_exception, |
| 5989 |
*reference; |
| 5990 |
|
| 5991 |
void |
| 5992 |
*blob = NULL; |
| 5993 |
|
| 5994 |
PERL_UNUSED_VAR(ref); |
| 5995 |
PERL_UNUSED_VAR(ix); |
| 5996 |
exception=AcquireExceptionInfo(); |
| 5997 |
perl_exception=newSVpv("",0); |
| 5998 |
if (sv_isobject(ST(0)) == 0) |
| 5999 |
{ |
| 6000 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 6001 |
PackageName); |
| 6002 |
goto PerlException; |
| 6003 |
} |
| 6004 |
reference=SvRV(ST(0)); |
| 6005 |
|
| 6006 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 6007 |
if (image == (Image *) NULL) |
| 6008 |
{ |
| 6009 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 6010 |
PackageName); |
| 6011 |
goto PerlException; |
| 6012 |
} |
| 6013 |
|
| 6014 |
region.x=0; |
| 6015 |
region.y=0; |
| 6016 |
region.width=image->columns; |
| 6017 |
region.height=1; |
| 6018 |
if (items == 1) |
| 6019 |
(void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion); |
| 6020 |
for (i=2; i < items; i+=2) |
| 6021 |
{ |
| 6022 |
attribute=(char *) SvPV(ST(i-1),na); |
| 6023 |
switch (*attribute) |
| 6024 |
{ |
| 6025 |
case 'g': |
| 6026 |
case 'G': |
| 6027 |
{ |
| 6028 |
if (LocaleCompare(attribute,"geometry") == 0) |
| 6029 |
{ |
| 6030 |
(void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion); |
| 6031 |
break; |
| 6032 |
} |
| 6033 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 6034 |
attribute); |
| 6035 |
break; |
| 6036 |
} |
| 6037 |
case 'H': |
| 6038 |
case 'h': |
| 6039 |
{ |
| 6040 |
if (LocaleCompare(attribute,"height") == 0) |
| 6041 |
{ |
| 6042 |
region.height=(size_t) SvIV(ST(i)); |
| 6043 |
continue; |
| 6044 |
} |
| 6045 |
ThrowPerlException(exception,OptionError,"UnrecognizedOption", |
| 6046 |
attribute); |
| 6047 |
break; |
| 6048 |
} |
| 6049 |
case 'X': |
| 6050 |
case 'x': |
| 6051 |
{ |
| 6052 |
if (LocaleCompare(attribute,"x") == 0) |
| 6053 |
{ |
| 6054 |
region.x=SvIV(ST(i)); |
| 6055 |
continue; |
| 6056 |
} |
| 6057 |
ThrowPerlException(exception,OptionError,"UnrecognizedOption", |
| 6058 |
attribute); |
| 6059 |
break; |
| 6060 |
} |
| 6061 |
case 'Y': |
| 6062 |
case 'y': |
| 6063 |
{ |
| 6064 |
if (LocaleCompare(attribute,"y") == 0) |
| 6065 |
{ |
| 6066 |
region.y=SvIV(ST(i)); |
| 6067 |
continue; |
| 6068 |
} |
| 6069 |
ThrowPerlException(exception,OptionError,"UnrecognizedOption", |
| 6070 |
attribute); |
| 6071 |
break; |
| 6072 |
} |
| 6073 |
case 'W': |
| 6074 |
case 'w': |
| 6075 |
{ |
| 6076 |
if (LocaleCompare(attribute,"width") == 0) |
| 6077 |
{ |
| 6078 |
region.width=(size_t) SvIV(ST(i)); |
| 6079 |
continue; |
| 6080 |
} |
| 6081 |
ThrowPerlException(exception,OptionError,"UnrecognizedOption", |
| 6082 |
attribute); |
| 6083 |
break; |
| 6084 |
} |
| 6085 |
} |
| 6086 |
} |
| 6087 |
blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width, |
| 6088 |
region.height,exception); |
| 6089 |
if (blob != (void *) NULL) |
| 6090 |
goto PerlEnd; |
| 6091 |
|
| 6092 |
PerlException: |
| 6093 |
InheritPerlException(exception,perl_exception); |
| 6094 |
exception=DestroyExceptionInfo(exception); |
| 6095 |
SvREFCNT_dec(perl_exception); /* throw away all errors */ |
| 6096 |
|
| 6097 |
PerlEnd: |
| 6098 |
RETVAL = blob; |
| 6099 |
} |
| 6100 |
OUTPUT: |
| 6101 |
RETVAL |
| 6102 |
|
| 6103 |
# |
| 6104 |
############################################################################### |
| 6105 |
# # |
| 6106 |
# # |
| 6107 |
# # |
| 6108 |
# G e t V i r t u a l P i x e l s # |
| 6109 |
# # |
| 6110 |
# # |
| 6111 |
# # |
| 6112 |
############################################################################### |
| 6113 |
# |
| 6114 |
# |
| 6115 |
void * |
| 6116 |
GetVirtualPixels(ref,...) |
| 6117 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 6118 |
ALIAS: |
| 6119 |
getvirtualpixels = 1 |
| 6120 |
AcquireImagePixels = 2 |
| 6121 |
acquireimagepixels = 3 |
| 6122 |
CODE: |
| 6123 |
{ |
| 6124 |
char |
| 6125 |
*attribute; |
| 6126 |
|
| 6127 |
const void |
| 6128 |
*blob = NULL; |
| 6129 |
|
| 6130 |
ExceptionInfo |
| 6131 |
*exception; |
| 6132 |
|
| 6133 |
Image |
| 6134 |
*image; |
| 6135 |
|
| 6136 |
RectangleInfo |
| 6137 |
region; |
| 6138 |
|
| 6139 |
ssize_t |
| 6140 |
i; |
| 6141 |
|
| 6142 |
struct PackageInfo |
| 6143 |
*info; |
| 6144 |
|
| 6145 |
SV |
| 6146 |
*perl_exception, |
| 6147 |
*reference; |
| 6148 |
|
| 6149 |
PERL_UNUSED_VAR(ref); |
| 6150 |
PERL_UNUSED_VAR(ix); |
| 6151 |
exception=AcquireExceptionInfo(); |
| 6152 |
perl_exception=newSVpv("",0); |
| 6153 |
if (sv_isobject(ST(0)) == 0) |
| 6154 |
{ |
| 6155 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 6156 |
PackageName); |
| 6157 |
goto PerlException; |
| 6158 |
} |
| 6159 |
reference=SvRV(ST(0)); |
| 6160 |
|
| 6161 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 6162 |
if (image == (Image *) NULL) |
| 6163 |
{ |
| 6164 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 6165 |
PackageName); |
| 6166 |
goto PerlException; |
| 6167 |
} |
| 6168 |
|
| 6169 |
region.x=0; |
| 6170 |
region.y=0; |
| 6171 |
region.width=image->columns; |
| 6172 |
region.height=1; |
| 6173 |
if (items == 1) |
| 6174 |
(void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion); |
| 6175 |
for (i=2; i < items; i+=2) |
| 6176 |
{ |
| 6177 |
attribute=(char *) SvPV(ST(i-1),na); |
| 6178 |
switch (*attribute) |
| 6179 |
{ |
| 6180 |
case 'g': |
| 6181 |
case 'G': |
| 6182 |
{ |
| 6183 |
if (LocaleCompare(attribute,"geometry") == 0) |
| 6184 |
{ |
| 6185 |
(void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion); |
| 6186 |
break; |
| 6187 |
} |
| 6188 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 6189 |
attribute); |
| 6190 |
break; |
| 6191 |
} |
| 6192 |
case 'H': |
| 6193 |
case 'h': |
| 6194 |
{ |
| 6195 |
if (LocaleCompare(attribute,"height") == 0) |
| 6196 |
{ |
| 6197 |
region.height=(size_t) SvIV(ST(i)); |
| 6198 |
continue; |
| 6199 |
} |
| 6200 |
ThrowPerlException(exception,OptionError,"UnrecognizedOption", |
| 6201 |
attribute); |
| 6202 |
break; |
| 6203 |
} |
| 6204 |
case 'X': |
| 6205 |
case 'x': |
| 6206 |
{ |
| 6207 |
if (LocaleCompare(attribute,"x") == 0) |
| 6208 |
{ |
| 6209 |
region.x=SvIV(ST(i)); |
| 6210 |
continue; |
| 6211 |
} |
| 6212 |
ThrowPerlException(exception,OptionError,"UnrecognizedOption", |
| 6213 |
attribute); |
| 6214 |
break; |
| 6215 |
} |
| 6216 |
case 'Y': |
| 6217 |
case 'y': |
| 6218 |
{ |
| 6219 |
if (LocaleCompare(attribute,"y") == 0) |
| 6220 |
{ |
| 6221 |
region.y=SvIV(ST(i)); |
| 6222 |
continue; |
| 6223 |
} |
| 6224 |
ThrowPerlException(exception,OptionError,"UnrecognizedOption", |
| 6225 |
attribute); |
| 6226 |
break; |
| 6227 |
} |
| 6228 |
case 'W': |
| 6229 |
case 'w': |
| 6230 |
{ |
| 6231 |
if (LocaleCompare(attribute,"width") == 0) |
| 6232 |
{ |
| 6233 |
region.width=(size_t) SvIV(ST(i)); |
| 6234 |
continue; |
| 6235 |
} |
| 6236 |
ThrowPerlException(exception,OptionError,"UnrecognizedOption", |
| 6237 |
attribute); |
| 6238 |
break; |
| 6239 |
} |
| 6240 |
} |
| 6241 |
} |
| 6242 |
blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width, |
| 6243 |
region.height,exception); |
| 6244 |
if (blob != (void *) NULL) |
| 6245 |
goto PerlEnd; |
| 6246 |
|
| 6247 |
PerlException: |
| 6248 |
InheritPerlException(exception,perl_exception); |
| 6249 |
exception=DestroyExceptionInfo(exception); |
| 6250 |
SvREFCNT_dec(perl_exception); /* throw away all errors */ |
| 6251 |
|
| 6252 |
PerlEnd: |
| 6253 |
RETVAL = (void *) blob; |
| 6254 |
} |
| 6255 |
OUTPUT: |
| 6256 |
RETVAL |
| 6257 |
|
| 6258 |
# |
| 6259 |
############################################################################### |
| 6260 |
# # |
| 6261 |
# # |
| 6262 |
# # |
| 6263 |
# G e t A u t h e n t i c M e t a c o n t e n t # |
| 6264 |
# # |
| 6265 |
# # |
| 6266 |
# # |
| 6267 |
############################################################################### |
| 6268 |
# |
| 6269 |
# |
| 6270 |
void * |
| 6271 |
GetAuthenticMetacontent(ref,...) |
| 6272 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 6273 |
ALIAS: |
| 6274 |
getauthenticmetacontent = 1 |
| 6275 |
GetMetacontent = 2 |
| 6276 |
getmetacontent = 3 |
| 6277 |
CODE: |
| 6278 |
{ |
| 6279 |
ExceptionInfo |
| 6280 |
*exception; |
| 6281 |
|
| 6282 |
Image |
| 6283 |
*image; |
| 6284 |
|
| 6285 |
struct PackageInfo |
| 6286 |
*info; |
| 6287 |
|
| 6288 |
SV |
| 6289 |
*perl_exception, |
| 6290 |
*reference; |
| 6291 |
|
| 6292 |
void |
| 6293 |
*blob = NULL; |
| 6294 |
|
| 6295 |
PERL_UNUSED_VAR(ref); |
| 6296 |
PERL_UNUSED_VAR(ix); |
| 6297 |
exception=AcquireExceptionInfo(); |
| 6298 |
perl_exception=newSVpv("",0); |
| 6299 |
if (sv_isobject(ST(0)) == 0) |
| 6300 |
{ |
| 6301 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 6302 |
PackageName); |
| 6303 |
goto PerlException; |
| 6304 |
} |
| 6305 |
reference=SvRV(ST(0)); |
| 6306 |
|
| 6307 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 6308 |
if (image == (Image *) NULL) |
| 6309 |
{ |
| 6310 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 6311 |
PackageName); |
| 6312 |
goto PerlException; |
| 6313 |
} |
| 6314 |
|
| 6315 |
blob=(void *) GetAuthenticMetacontent(image); |
| 6316 |
if (blob != (void *) NULL) |
| 6317 |
goto PerlEnd; |
| 6318 |
|
| 6319 |
PerlException: |
| 6320 |
InheritPerlException(exception,perl_exception); |
| 6321 |
exception=DestroyExceptionInfo(exception); |
| 6322 |
SvREFCNT_dec(perl_exception); /* throw away all errors */ |
| 6323 |
|
| 6324 |
PerlEnd: |
| 6325 |
RETVAL = blob; |
| 6326 |
} |
| 6327 |
OUTPUT: |
| 6328 |
RETVAL |
| 6329 |
|
| 6330 |
# |
| 6331 |
############################################################################### |
| 6332 |
# # |
| 6333 |
# # |
| 6334 |
# # |
| 6335 |
# G e t V i r t u a l M e t a c o n t e n t # |
| 6336 |
# # |
| 6337 |
# # |
| 6338 |
# # |
| 6339 |
############################################################################### |
| 6340 |
# |
| 6341 |
# |
| 6342 |
void * |
| 6343 |
GetVirtualMetacontent(ref,...) |
| 6344 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 6345 |
ALIAS: |
| 6346 |
getvirtualmetacontent = 1 |
| 6347 |
CODE: |
| 6348 |
{ |
| 6349 |
ExceptionInfo |
| 6350 |
*exception; |
| 6351 |
|
| 6352 |
Image |
| 6353 |
*image; |
| 6354 |
|
| 6355 |
struct PackageInfo |
| 6356 |
*info; |
| 6357 |
|
| 6358 |
SV |
| 6359 |
*perl_exception, |
| 6360 |
*reference; |
| 6361 |
|
| 6362 |
void |
| 6363 |
*blob = NULL; |
| 6364 |
|
| 6365 |
PERL_UNUSED_VAR(ref); |
| 6366 |
PERL_UNUSED_VAR(ix); |
| 6367 |
exception=AcquireExceptionInfo(); |
| 6368 |
perl_exception=newSVpv("",0); |
| 6369 |
if (sv_isobject(ST(0)) == 0) |
| 6370 |
{ |
| 6371 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 6372 |
PackageName); |
| 6373 |
goto PerlException; |
| 6374 |
} |
| 6375 |
reference=SvRV(ST(0)); |
| 6376 |
|
| 6377 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 6378 |
if (image == (Image *) NULL) |
| 6379 |
{ |
| 6380 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 6381 |
PackageName); |
| 6382 |
goto PerlException; |
| 6383 |
} |
| 6384 |
|
| 6385 |
blob=(void *) GetVirtualMetacontent(image); |
| 6386 |
if (blob != (void *) NULL) |
| 6387 |
goto PerlEnd; |
| 6388 |
|
| 6389 |
PerlException: |
| 6390 |
InheritPerlException(exception,perl_exception); |
| 6391 |
exception=DestroyExceptionInfo(exception); |
| 6392 |
SvREFCNT_dec(perl_exception); /* throw away all errors */ |
| 6393 |
|
| 6394 |
PerlEnd: |
| 6395 |
RETVAL = blob; |
| 6396 |
} |
| 6397 |
OUTPUT: |
| 6398 |
RETVAL |
| 6399 |
|
| 6400 |
# |
| 6401 |
############################################################################### |
| 6402 |
# # |
| 6403 |
# # |
| 6404 |
# # |
| 6405 |
# H i s t o g r a m # |
| 6406 |
# # |
| 6407 |
# # |
| 6408 |
# # |
| 6409 |
############################################################################### |
| 6410 |
# |
| 6411 |
# |
| 6412 |
void |
| 6413 |
Histogram(ref,...) |
| 6414 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 6415 |
ALIAS: |
| 6416 |
HistogramImage = 1 |
| 6417 |
histogram = 2 |
| 6418 |
histogramimage = 3 |
| 6419 |
PPCODE: |
| 6420 |
{ |
| 6421 |
AV |
| 6422 |
*av; |
| 6423 |
|
| 6424 |
char |
| 6425 |
message[MagickPathExtent]; |
| 6426 |
|
| 6427 |
PixelInfo |
| 6428 |
*histogram; |
| 6429 |
|
| 6430 |
ExceptionInfo |
| 6431 |
*exception; |
| 6432 |
|
| 6433 |
Image |
| 6434 |
*image; |
| 6435 |
|
| 6436 |
ssize_t |
| 6437 |
i; |
| 6438 |
|
| 6439 |
ssize_t |
| 6440 |
count; |
| 6441 |
|
| 6442 |
struct PackageInfo |
| 6443 |
*info; |
| 6444 |
|
| 6445 |
SV |
| 6446 |
*perl_exception, |
| 6447 |
*reference; |
| 6448 |
|
| 6449 |
size_t |
| 6450 |
number_colors; |
| 6451 |
|
| 6452 |
PERL_UNUSED_VAR(ref); |
| 6453 |
PERL_UNUSED_VAR(ix); |
| 6454 |
exception=AcquireExceptionInfo(); |
| 6455 |
perl_exception=newSVpv("",0); |
| 6456 |
av=NULL; |
| 6457 |
if (sv_isobject(ST(0)) == 0) |
| 6458 |
{ |
| 6459 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 6460 |
PackageName); |
| 6461 |
goto PerlException; |
| 6462 |
} |
| 6463 |
reference=SvRV(ST(0)); |
| 6464 |
av=newAV(); |
| 6465 |
SvREFCNT_dec(av); |
| 6466 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 6467 |
if (image == (Image *) NULL) |
| 6468 |
{ |
| 6469 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 6470 |
PackageName); |
| 6471 |
goto PerlException; |
| 6472 |
} |
| 6473 |
count=0; |
| 6474 |
for ( ; image; image=image->next) |
| 6475 |
{ |
| 6476 |
histogram=GetImageHistogram(image,&number_colors,exception); |
| 6477 |
if (histogram == (PixelInfo *) NULL) |
| 6478 |
continue; |
| 6479 |
count+=(ssize_t) number_colors; |
| 6480 |
EXTEND(sp,6*count); |
| 6481 |
for (i=0; i < (ssize_t) number_colors; i++) |
| 6482 |
{ |
| 6483 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", |
| 6484 |
histogram[i].red); |
| 6485 |
PUSHs(sv_2mortal(newSVpv(message,0))); |
| 6486 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", |
| 6487 |
histogram[i].green); |
| 6488 |
PUSHs(sv_2mortal(newSVpv(message,0))); |
| 6489 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", |
| 6490 |
histogram[i].blue); |
| 6491 |
PUSHs(sv_2mortal(newSVpv(message,0))); |
| 6492 |
if (image->colorspace == CMYKColorspace) |
| 6493 |
{ |
| 6494 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", |
| 6495 |
histogram[i].black); |
| 6496 |
PUSHs(sv_2mortal(newSVpv(message,0))); |
| 6497 |
} |
| 6498 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", |
| 6499 |
histogram[i].alpha); |
| 6500 |
PUSHs(sv_2mortal(newSVpv(message,0))); |
| 6501 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double) |
| 6502 |
histogram[i].count); |
| 6503 |
PUSHs(sv_2mortal(newSVpv(message,0))); |
| 6504 |
} |
| 6505 |
histogram=(PixelInfo *) RelinquishMagickMemory(histogram); |
| 6506 |
} |
| 6507 |
|
| 6508 |
PerlException: |
| 6509 |
InheritPerlException(exception,perl_exception); |
| 6510 |
exception=DestroyExceptionInfo(exception); |
| 6511 |
SvREFCNT_dec(perl_exception); |
| 6512 |
} |
| 6513 |
|
| 6514 |
# |
| 6515 |
############################################################################### |
| 6516 |
# # |
| 6517 |
# # |
| 6518 |
# # |
| 6519 |
# G e t P i x e l # |
| 6520 |
# # |
| 6521 |
# # |
| 6522 |
# # |
| 6523 |
############################################################################### |
| 6524 |
# |
| 6525 |
# |
| 6526 |
void |
| 6527 |
GetPixel(ref,...) |
| 6528 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 6529 |
ALIAS: |
| 6530 |
getpixel = 1 |
| 6531 |
getPixel = 2 |
| 6532 |
PPCODE: |
| 6533 |
{ |
| 6534 |
AV |
| 6535 |
*av; |
| 6536 |
|
| 6537 |
char |
| 6538 |
*attribute; |
| 6539 |
|
| 6540 |
const Quantum |
| 6541 |
*p; |
| 6542 |
|
| 6543 |
ExceptionInfo |
| 6544 |
*exception; |
| 6545 |
|
| 6546 |
Image |
| 6547 |
*image; |
| 6548 |
|
| 6549 |
MagickBooleanType |
| 6550 |
normalize; |
| 6551 |
|
| 6552 |
RectangleInfo |
| 6553 |
region; |
| 6554 |
|
| 6555 |
ssize_t |
| 6556 |
i, |
| 6557 |
option; |
| 6558 |
|
| 6559 |
struct PackageInfo |
| 6560 |
*info; |
| 6561 |
|
| 6562 |
SV |
| 6563 |
*perl_exception, |
| 6564 |
*reference; /* reference is the SV* of ref=SvIV(reference) */ |
| 6565 |
|
| 6566 |
PERL_UNUSED_VAR(ref); |
| 6567 |
PERL_UNUSED_VAR(ix); |
| 6568 |
exception=AcquireExceptionInfo(); |
| 6569 |
perl_exception=newSVpv("",0); |
| 6570 |
reference=SvRV(ST(0)); |
| 6571 |
av=(AV *) reference; |
| 6572 |
info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL, |
| 6573 |
exception); |
| 6574 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 6575 |
if (image == (Image *) NULL) |
| 6576 |
{ |
| 6577 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 6578 |
PackageName); |
| 6579 |
goto PerlException; |
| 6580 |
} |
| 6581 |
normalize=MagickTrue; |
| 6582 |
region.x=0; |
| 6583 |
region.y=0; |
| 6584 |
region.width=image->columns; |
| 6585 |
region.height=1; |
| 6586 |
if (items == 1) |
| 6587 |
(void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion); |
| 6588 |
for (i=2; i < items; i+=2) |
| 6589 |
{ |
| 6590 |
attribute=(char *) SvPV(ST(i-1),na); |
| 6591 |
switch (*attribute) |
| 6592 |
{ |
| 6593 |
case 'C': |
| 6594 |
case 'c': |
| 6595 |
{ |
| 6596 |
if (LocaleCompare(attribute,"channel") == 0) |
| 6597 |
{ |
| 6598 |
ssize_t |
| 6599 |
option; |
| 6600 |
|
| 6601 |
option=ParseChannelOption(SvPV(ST(i),na)); |
| 6602 |
if (option < 0) |
| 6603 |
{ |
| 6604 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 6605 |
SvPV(ST(i),na)); |
| 6606 |
return; |
| 6607 |
} |
| 6608 |
(void) SetPixelChannelMask(image,(ChannelType) option); |
| 6609 |
break; |
| 6610 |
} |
| 6611 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 6612 |
attribute); |
| 6613 |
break; |
| 6614 |
} |
| 6615 |
case 'g': |
| 6616 |
case 'G': |
| 6617 |
{ |
| 6618 |
if (LocaleCompare(attribute,"geometry") == 0) |
| 6619 |
{ |
| 6620 |
(void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion); |
| 6621 |
break; |
| 6622 |
} |
| 6623 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 6624 |
attribute); |
| 6625 |
break; |
| 6626 |
} |
| 6627 |
case 'N': |
| 6628 |
case 'n': |
| 6629 |
{ |
| 6630 |
if (LocaleCompare(attribute,"normalize") == 0) |
| 6631 |
{ |
| 6632 |
option=ParseCommandOption(MagickBooleanOptions,MagickFalse, |
| 6633 |
SvPV(ST(i),na)); |
| 6634 |
if (option < 0) |
| 6635 |
{ |
| 6636 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 6637 |
SvPV(ST(i),na)); |
| 6638 |
break; |
| 6639 |
} |
| 6640 |
normalize=option != 0 ? MagickTrue : MagickFalse; |
| 6641 |
break; |
| 6642 |
} |
| 6643 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 6644 |
attribute); |
| 6645 |
break; |
| 6646 |
} |
| 6647 |
case 'x': |
| 6648 |
case 'X': |
| 6649 |
{ |
| 6650 |
if (LocaleCompare(attribute,"x") == 0) |
| 6651 |
{ |
| 6652 |
region.x=SvIV(ST(i)); |
| 6653 |
break; |
| 6654 |
} |
| 6655 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 6656 |
attribute); |
| 6657 |
break; |
| 6658 |
} |
| 6659 |
case 'y': |
| 6660 |
case 'Y': |
| 6661 |
{ |
| 6662 |
if (LocaleCompare(attribute,"y") == 0) |
| 6663 |
{ |
| 6664 |
region.y=SvIV(ST(i)); |
| 6665 |
break; |
| 6666 |
} |
| 6667 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 6668 |
attribute); |
| 6669 |
break; |
| 6670 |
} |
| 6671 |
default: |
| 6672 |
{ |
| 6673 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 6674 |
attribute); |
| 6675 |
break; |
| 6676 |
} |
| 6677 |
} |
| 6678 |
} |
| 6679 |
p=GetVirtualPixels(image,region.x,region.y,1,1,exception); |
| 6680 |
if (p == (const Quantum *) NULL) |
| 6681 |
PUSHs(&sv_undef); |
| 6682 |
else |
| 6683 |
{ |
| 6684 |
double |
| 6685 |
scale; |
| 6686 |
|
| 6687 |
scale=1.0; |
| 6688 |
if (normalize != MagickFalse) |
| 6689 |
scale=1.0/QuantumRange; |
| 6690 |
if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) |
| 6691 |
PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p)))); |
| 6692 |
if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) |
| 6693 |
PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p)))); |
| 6694 |
if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) |
| 6695 |
PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p)))); |
| 6696 |
if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 6697 |
(image->colorspace == CMYKColorspace)) |
| 6698 |
PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p)))); |
| 6699 |
if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) |
| 6700 |
PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p)))); |
| 6701 |
} |
| 6702 |
|
| 6703 |
PerlException: |
| 6704 |
InheritPerlException(exception,perl_exception); |
| 6705 |
exception=DestroyExceptionInfo(exception); |
| 6706 |
SvREFCNT_dec(perl_exception); |
| 6707 |
} |
| 6708 |
|
| 6709 |
# |
| 6710 |
############################################################################### |
| 6711 |
# # |
| 6712 |
# # |
| 6713 |
# # |
| 6714 |
# G e t P i x e l s # |
| 6715 |
# # |
| 6716 |
# # |
| 6717 |
# # |
| 6718 |
############################################################################### |
| 6719 |
# |
| 6720 |
# |
| 6721 |
void |
| 6722 |
GetPixels(ref,...) |
| 6723 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 6724 |
ALIAS: |
| 6725 |
getpixels = 1 |
| 6726 |
getPixels = 2 |
| 6727 |
PPCODE: |
| 6728 |
{ |
| 6729 |
AV |
| 6730 |
*av; |
| 6731 |
|
| 6732 |
char |
| 6733 |
*attribute; |
| 6734 |
|
| 6735 |
const char |
| 6736 |
*map; |
| 6737 |
|
| 6738 |
ExceptionInfo |
| 6739 |
*exception; |
| 6740 |
|
| 6741 |
Image |
| 6742 |
*image; |
| 6743 |
|
| 6744 |
MagickBooleanType |
| 6745 |
normalize, |
| 6746 |
status; |
| 6747 |
|
| 6748 |
RectangleInfo |
| 6749 |
region; |
| 6750 |
|
| 6751 |
ssize_t |
| 6752 |
i, |
| 6753 |
option; |
| 6754 |
|
| 6755 |
struct PackageInfo |
| 6756 |
*info; |
| 6757 |
|
| 6758 |
SV |
| 6759 |
*perl_exception, |
| 6760 |
*reference; /* reference is the SV* of ref=SvIV(reference) */ |
| 6761 |
|
| 6762 |
PERL_UNUSED_VAR(ref); |
| 6763 |
PERL_UNUSED_VAR(ix); |
| 6764 |
exception=AcquireExceptionInfo(); |
| 6765 |
perl_exception=newSVpv("",0); |
| 6766 |
reference=SvRV(ST(0)); |
| 6767 |
av=(AV *) reference; |
| 6768 |
info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL, |
| 6769 |
exception); |
| 6770 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 6771 |
if (image == (Image *) NULL) |
| 6772 |
{ |
| 6773 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 6774 |
PackageName); |
| 6775 |
goto PerlException; |
| 6776 |
} |
| 6777 |
map="RGB"; |
| 6778 |
if (image->alpha_trait != UndefinedPixelTrait) |
| 6779 |
map="RGBA"; |
| 6780 |
if (image->colorspace == CMYKColorspace) |
| 6781 |
{ |
| 6782 |
map="CMYK"; |
| 6783 |
if (image->alpha_trait != UndefinedPixelTrait) |
| 6784 |
map="CMYKA"; |
| 6785 |
} |
| 6786 |
normalize=MagickFalse; |
| 6787 |
region.x=0; |
| 6788 |
region.y=0; |
| 6789 |
region.width=image->columns; |
| 6790 |
region.height=1; |
| 6791 |
if (items == 1) |
| 6792 |
(void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion); |
| 6793 |
for (i=2; i < items; i+=2) |
| 6794 |
{ |
| 6795 |
attribute=(char *) SvPV(ST(i-1),na); |
| 6796 |
switch (*attribute) |
| 6797 |
{ |
| 6798 |
case 'g': |
| 6799 |
case 'G': |
| 6800 |
{ |
| 6801 |
if (LocaleCompare(attribute,"geometry") == 0) |
| 6802 |
{ |
| 6803 |
(void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion); |
| 6804 |
break; |
| 6805 |
} |
| 6806 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 6807 |
attribute); |
| 6808 |
break; |
| 6809 |
} |
| 6810 |
case 'H': |
| 6811 |
case 'h': |
| 6812 |
{ |
| 6813 |
if (LocaleCompare(attribute,"height") == 0) |
| 6814 |
{ |
| 6815 |
region.height=(size_t) SvIV(ST(i)); |
| 6816 |
break; |
| 6817 |
} |
| 6818 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 6819 |
attribute); |
| 6820 |
break; |
| 6821 |
} |
| 6822 |
case 'M': |
| 6823 |
case 'm': |
| 6824 |
{ |
| 6825 |
if (LocaleCompare(attribute,"map") == 0) |
| 6826 |
{ |
| 6827 |
map=SvPV(ST(i),na); |
| 6828 |
break; |
| 6829 |
} |
| 6830 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 6831 |
attribute); |
| 6832 |
break; |
| 6833 |
} |
| 6834 |
case 'N': |
| 6835 |
case 'n': |
| 6836 |
{ |
| 6837 |
if (LocaleCompare(attribute,"normalize") == 0) |
| 6838 |
{ |
| 6839 |
option=ParseCommandOption(MagickBooleanOptions,MagickFalse, |
| 6840 |
SvPV(ST(i),na)); |
| 6841 |
if (option < 0) |
| 6842 |
{ |
| 6843 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 6844 |
SvPV(ST(i),na)); |
| 6845 |
break; |
| 6846 |
} |
| 6847 |
normalize=option != 0 ? MagickTrue : MagickFalse; |
| 6848 |
break; |
| 6849 |
} |
| 6850 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 6851 |
attribute); |
| 6852 |
break; |
| 6853 |
} |
| 6854 |
case 'W': |
| 6855 |
case 'w': |
| 6856 |
{ |
| 6857 |
if (LocaleCompare(attribute,"width") == 0) |
| 6858 |
{ |
| 6859 |
region.width=(size_t) SvIV(ST(i)); |
| 6860 |
break; |
| 6861 |
} |
| 6862 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 6863 |
attribute); |
| 6864 |
break; |
| 6865 |
} |
| 6866 |
case 'x': |
| 6867 |
case 'X': |
| 6868 |
{ |
| 6869 |
if (LocaleCompare(attribute,"x") == 0) |
| 6870 |
{ |
| 6871 |
region.x=SvIV(ST(i)); |
| 6872 |
break; |
| 6873 |
} |
| 6874 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 6875 |
attribute); |
| 6876 |
break; |
| 6877 |
} |
| 6878 |
case 'y': |
| 6879 |
case 'Y': |
| 6880 |
{ |
| 6881 |
if (LocaleCompare(attribute,"y") == 0) |
| 6882 |
{ |
| 6883 |
region.y=SvIV(ST(i)); |
| 6884 |
break; |
| 6885 |
} |
| 6886 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 6887 |
attribute); |
| 6888 |
break; |
| 6889 |
} |
| 6890 |
default: |
| 6891 |
{ |
| 6892 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 6893 |
attribute); |
| 6894 |
break; |
| 6895 |
} |
| 6896 |
} |
| 6897 |
} |
| 6898 |
if (normalize != MagickFalse) |
| 6899 |
{ |
| 6900 |
float |
| 6901 |
*pixels; |
| 6902 |
|
| 6903 |
MemoryInfo |
| 6904 |
*pixels_info; |
| 6905 |
|
| 6906 |
pixels_info=AcquireVirtualMemory(strlen(map)*region.width, |
| 6907 |
region.height*sizeof(*pixels)); |
| 6908 |
if (pixels_info == (MemoryInfo *) NULL) |
| 6909 |
{ |
| 6910 |
ThrowPerlException(exception,ResourceLimitError, |
| 6911 |
"MemoryAllocationFailed",PackageName); |
| 6912 |
goto PerlException; |
| 6913 |
} |
| 6914 |
pixels=(float *) GetVirtualMemoryBlob(pixels_info); |
| 6915 |
status=ExportImagePixels(image,region.x,region.y,region.width, |
| 6916 |
region.height,map,FloatPixel,pixels,exception); |
| 6917 |
if (status == MagickFalse) |
| 6918 |
PUSHs(&sv_undef); |
| 6919 |
else |
| 6920 |
{ |
| 6921 |
EXTEND(sp,(ssize_t) (strlen(map)*region.width*region.height)); |
| 6922 |
for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++) |
| 6923 |
PUSHs(sv_2mortal(newSVnv(pixels[i]))); |
| 6924 |
} |
| 6925 |
pixels_info=RelinquishVirtualMemory(pixels_info); |
| 6926 |
} |
| 6927 |
else |
| 6928 |
{ |
| 6929 |
MemoryInfo |
| 6930 |
*pixels_info; |
| 6931 |
|
| 6932 |
Quantum |
| 6933 |
*pixels; |
| 6934 |
|
| 6935 |
pixels_info=AcquireVirtualMemory(strlen(map)*region.width, |
| 6936 |
region.height*sizeof(*pixels)); |
| 6937 |
if (pixels_info == (MemoryInfo *) NULL) |
| 6938 |
{ |
| 6939 |
ThrowPerlException(exception,ResourceLimitError, |
| 6940 |
"MemoryAllocationFailed",PackageName); |
| 6941 |
goto PerlException; |
| 6942 |
} |
| 6943 |
pixels=(Quantum *) GetVirtualMemoryBlob(pixels_info); |
| 6944 |
status=ExportImagePixels(image,region.x,region.y,region.width, |
| 6945 |
region.height,map,QuantumPixel,pixels,exception); |
| 6946 |
if (status == MagickFalse) |
| 6947 |
PUSHs(&sv_undef); |
| 6948 |
else |
| 6949 |
{ |
| 6950 |
EXTEND(sp,(ssize_t) (strlen(map)*region.width*region.height)); |
| 6951 |
for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++) |
| 6952 |
PUSHs(sv_2mortal(newSViv(pixels[i]))); |
| 6953 |
} |
| 6954 |
pixels_info=RelinquishVirtualMemory(pixels_info); |
| 6955 |
} |
| 6956 |
|
| 6957 |
PerlException: |
| 6958 |
InheritPerlException(exception,perl_exception); |
| 6959 |
exception=DestroyExceptionInfo(exception); |
| 6960 |
SvREFCNT_dec(perl_exception); |
| 6961 |
} |
| 6962 |
|
| 6963 |
# |
| 6964 |
############################################################################### |
| 6965 |
# # |
| 6966 |
# # |
| 6967 |
# # |
| 6968 |
# I m a g e T o B l o b # |
| 6969 |
# # |
| 6970 |
# # |
| 6971 |
# # |
| 6972 |
############################################################################### |
| 6973 |
# |
| 6974 |
# |
| 6975 |
void |
| 6976 |
ImageToBlob(ref,...) |
| 6977 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 6978 |
ALIAS: |
| 6979 |
ImageToBlob = 1 |
| 6980 |
imagetoblob = 2 |
| 6981 |
toblob = 3 |
| 6982 |
blob = 4 |
| 6983 |
PPCODE: |
| 6984 |
{ |
| 6985 |
char |
| 6986 |
filename[MagickPathExtent]; |
| 6987 |
|
| 6988 |
ExceptionInfo |
| 6989 |
*exception; |
| 6990 |
|
| 6991 |
Image |
| 6992 |
*image, |
| 6993 |
*next; |
| 6994 |
|
| 6995 |
ssize_t |
| 6996 |
i; |
| 6997 |
|
| 6998 |
struct PackageInfo |
| 6999 |
*info, |
| 7000 |
*package_info; |
| 7001 |
|
| 7002 |
size_t |
| 7003 |
length; |
| 7004 |
|
| 7005 |
ssize_t |
| 7006 |
scene; |
| 7007 |
|
| 7008 |
SV |
| 7009 |
*perl_exception, |
| 7010 |
*reference; |
| 7011 |
|
| 7012 |
void |
| 7013 |
*blob; |
| 7014 |
|
| 7015 |
PERL_UNUSED_VAR(ref); |
| 7016 |
PERL_UNUSED_VAR(ix); |
| 7017 |
exception=AcquireExceptionInfo(); |
| 7018 |
perl_exception=newSVpv("",0); |
| 7019 |
package_info=(struct PackageInfo *) NULL; |
| 7020 |
if (sv_isobject(ST(0)) == 0) |
| 7021 |
{ |
| 7022 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 7023 |
PackageName); |
| 7024 |
goto PerlException; |
| 7025 |
} |
| 7026 |
reference=SvRV(ST(0)); |
| 7027 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 7028 |
if (image == (Image *) NULL) |
| 7029 |
{ |
| 7030 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 7031 |
PackageName); |
| 7032 |
goto PerlException; |
| 7033 |
} |
| 7034 |
package_info=ClonePackageInfo(info,exception); |
| 7035 |
for (i=2; i < items; i+=2) |
| 7036 |
SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception); |
| 7037 |
(void) CopyMagickString(filename,package_info->image_info->filename, |
| 7038 |
MagickPathExtent); |
| 7039 |
scene=0; |
| 7040 |
for (next=image; next; next=next->next) |
| 7041 |
{ |
| 7042 |
(void) CopyMagickString(next->filename,filename,MagickPathExtent); |
| 7043 |
next->scene=(size_t) scene++; |
| 7044 |
} |
| 7045 |
SetImageInfo(package_info->image_info,(unsigned int) |
| 7046 |
GetImageListLength(image),exception); |
| 7047 |
EXTEND(sp,(ssize_t) GetImageListLength(image)); |
| 7048 |
for ( ; image; image=image->next) |
| 7049 |
{ |
| 7050 |
length=0; |
| 7051 |
blob=ImagesToBlob(package_info->image_info,image,&length,exception); |
| 7052 |
if (blob != (char *) NULL) |
| 7053 |
{ |
| 7054 |
PUSHs(sv_2mortal(newSVpv((const char *) blob,length))); |
| 7055 |
blob=(unsigned char *) RelinquishMagickMemory(blob); |
| 7056 |
} |
| 7057 |
if (package_info->image_info->adjoin) |
| 7058 |
break; |
| 7059 |
} |
| 7060 |
|
| 7061 |
PerlException: |
| 7062 |
if (package_info != (struct PackageInfo *) NULL) |
| 7063 |
DestroyPackageInfo(package_info); |
| 7064 |
InheritPerlException(exception,perl_exception); |
| 7065 |
exception=DestroyExceptionInfo(exception); |
| 7066 |
SvREFCNT_dec(perl_exception); /* throw away all errors */ |
| 7067 |
} |
| 7068 |
|
| 7069 |
# |
| 7070 |
############################################################################### |
| 7071 |
# # |
| 7072 |
# # |
| 7073 |
# # |
| 7074 |
# L a y e r s # |
| 7075 |
# # |
| 7076 |
# # |
| 7077 |
# # |
| 7078 |
############################################################################### |
| 7079 |
# |
| 7080 |
# |
| 7081 |
void |
| 7082 |
Layers(ref,...) |
| 7083 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 7084 |
ALIAS: |
| 7085 |
Layers = 1 |
| 7086 |
layers = 2 |
| 7087 |
OptimizeImageLayers = 3 |
| 7088 |
optimizelayers = 4 |
| 7089 |
optimizeimagelayers = 5 |
| 7090 |
PPCODE: |
| 7091 |
{ |
| 7092 |
AV |
| 7093 |
*av; |
| 7094 |
|
| 7095 |
char |
| 7096 |
*attribute; |
| 7097 |
|
| 7098 |
CompositeOperator |
| 7099 |
compose; |
| 7100 |
|
| 7101 |
ExceptionInfo |
| 7102 |
*exception; |
| 7103 |
|
| 7104 |
HV |
| 7105 |
*hv; |
| 7106 |
|
| 7107 |
Image |
| 7108 |
*image, |
| 7109 |
*layers; |
| 7110 |
|
| 7111 |
LayerMethod |
| 7112 |
method; |
| 7113 |
|
| 7114 |
ssize_t |
| 7115 |
i, |
| 7116 |
option, |
| 7117 |
sp; |
| 7118 |
|
| 7119 |
struct PackageInfo |
| 7120 |
*info; |
| 7121 |
|
| 7122 |
SV |
| 7123 |
*av_reference, |
| 7124 |
*perl_exception, |
| 7125 |
*reference, |
| 7126 |
*rv, |
| 7127 |
*sv; |
| 7128 |
|
| 7129 |
PERL_UNUSED_VAR(ref); |
| 7130 |
PERL_UNUSED_VAR(ix); |
| 7131 |
exception=AcquireExceptionInfo(); |
| 7132 |
perl_exception=newSVpv("",0); |
| 7133 |
sv=NULL; |
| 7134 |
if (sv_isobject(ST(0)) == 0) |
| 7135 |
{ |
| 7136 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 7137 |
PackageName); |
| 7138 |
goto PerlException; |
| 7139 |
} |
| 7140 |
reference=SvRV(ST(0)); |
| 7141 |
hv=SvSTASH(reference); |
| 7142 |
av=newAV(); |
| 7143 |
av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv)); |
| 7144 |
SvREFCNT_dec(av); |
| 7145 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 7146 |
if (image == (Image *) NULL) |
| 7147 |
{ |
| 7148 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 7149 |
PackageName); |
| 7150 |
goto PerlException; |
| 7151 |
} |
| 7152 |
compose=image->compose; |
| 7153 |
method=OptimizeLayer; |
| 7154 |
for (i=2; i < items; i+=2) |
| 7155 |
{ |
| 7156 |
attribute=(char *) SvPV(ST(i-1),na); |
| 7157 |
switch (*attribute) |
| 7158 |
{ |
| 7159 |
case 'C': |
| 7160 |
case 'c': |
| 7161 |
{ |
| 7162 |
if (LocaleCompare(attribute,"compose") == 0) |
| 7163 |
{ |
| 7164 |
sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption( |
| 7165 |
MagickComposeOptions,MagickFalse,SvPV(ST(i),na)); |
| 7166 |
if (sp < 0) |
| 7167 |
{ |
| 7168 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 7169 |
SvPV(ST(i),na)); |
| 7170 |
break; |
| 7171 |
} |
| 7172 |
compose=(CompositeOperator) sp; |
| 7173 |
break; |
| 7174 |
} |
| 7175 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 7176 |
attribute); |
| 7177 |
break; |
| 7178 |
} |
| 7179 |
case 'M': |
| 7180 |
case 'm': |
| 7181 |
{ |
| 7182 |
if (LocaleCompare(attribute,"method") == 0) |
| 7183 |
{ |
| 7184 |
option=ParseCommandOption(MagickLayerOptions,MagickFalse, |
| 7185 |
SvPV(ST(i),na)); |
| 7186 |
if (option < 0) |
| 7187 |
{ |
| 7188 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 7189 |
SvPV(ST(i),na)); |
| 7190 |
break; |
| 7191 |
} |
| 7192 |
method=(LayerMethod) option; |
| 7193 |
break; |
| 7194 |
} |
| 7195 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 7196 |
attribute); |
| 7197 |
break; |
| 7198 |
} |
| 7199 |
default: |
| 7200 |
{ |
| 7201 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 7202 |
attribute); |
| 7203 |
break; |
| 7204 |
} |
| 7205 |
} |
| 7206 |
} |
| 7207 |
layers=(Image *) NULL; |
| 7208 |
switch (method) |
| 7209 |
{ |
| 7210 |
case CompareAnyLayer: |
| 7211 |
case CompareClearLayer: |
| 7212 |
case CompareOverlayLayer: |
| 7213 |
default: |
| 7214 |
{ |
| 7215 |
layers=CompareImagesLayers(image,method,exception); |
| 7216 |
break; |
| 7217 |
} |
| 7218 |
case MergeLayer: |
| 7219 |
case FlattenLayer: |
| 7220 |
case MosaicLayer: |
| 7221 |
{ |
| 7222 |
layers=MergeImageLayers(image,method,exception); |
| 7223 |
break; |
| 7224 |
} |
| 7225 |
case DisposeLayer: |
| 7226 |
{ |
| 7227 |
layers=DisposeImages(image,exception); |
| 7228 |
break; |
| 7229 |
} |
| 7230 |
case OptimizeImageLayer: |
| 7231 |
{ |
| 7232 |
layers=OptimizeImageLayers(image,exception); |
| 7233 |
break; |
| 7234 |
} |
| 7235 |
case OptimizePlusLayer: |
| 7236 |
{ |
| 7237 |
layers=OptimizePlusImageLayers(image,exception); |
| 7238 |
break; |
| 7239 |
} |
| 7240 |
case OptimizeTransLayer: |
| 7241 |
{ |
| 7242 |
OptimizeImageTransparency(image,exception); |
| 7243 |
break; |
| 7244 |
} |
| 7245 |
case RemoveDupsLayer: |
| 7246 |
{ |
| 7247 |
RemoveDuplicateLayers(&image,exception); |
| 7248 |
break; |
| 7249 |
} |
| 7250 |
case RemoveZeroLayer: |
| 7251 |
{ |
| 7252 |
RemoveZeroDelayLayers(&image,exception); |
| 7253 |
break; |
| 7254 |
} |
| 7255 |
case OptimizeLayer: |
| 7256 |
{ |
| 7257 |
QuantizeInfo |
| 7258 |
*quantize_info; |
| 7259 |
|
| 7260 |
/* |
| 7261 |
General Purpose, GIF Animation Optimizer. |
| 7262 |
*/ |
| 7263 |
layers=CoalesceImages(image,exception); |
| 7264 |
if (layers == (Image *) NULL) |
| 7265 |
break; |
| 7266 |
image=layers; |
| 7267 |
layers=OptimizeImageLayers(image,exception); |
| 7268 |
if (layers == (Image *) NULL) |
| 7269 |
break; |
| 7270 |
image=DestroyImageList(image); |
| 7271 |
image=layers; |
| 7272 |
layers=(Image *) NULL; |
| 7273 |
OptimizeImageTransparency(image,exception); |
| 7274 |
quantize_info=AcquireQuantizeInfo(info->image_info); |
| 7275 |
(void) RemapImages(quantize_info,image,(Image *) NULL,exception); |
| 7276 |
quantize_info=DestroyQuantizeInfo(quantize_info); |
| 7277 |
break; |
| 7278 |
} |
| 7279 |
case CompositeLayer: |
| 7280 |
{ |
| 7281 |
Image |
| 7282 |
*source; |
| 7283 |
|
| 7284 |
RectangleInfo |
| 7285 |
geometry; |
| 7286 |
|
| 7287 |
/* |
| 7288 |
Split image sequence at the first 'NULL:' image. |
| 7289 |
*/ |
| 7290 |
source=image; |
| 7291 |
while (source != (Image *) NULL) |
| 7292 |
{ |
| 7293 |
source=GetNextImageInList(source); |
| 7294 |
if ((source != (Image *) NULL) && |
| 7295 |
(LocaleCompare(source->magick,"NULL") == 0)) |
| 7296 |
break; |
| 7297 |
} |
| 7298 |
if (source != (Image *) NULL) |
| 7299 |
{ |
| 7300 |
if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7301 |
(GetNextImageInList(source) == (Image *) NULL)) |
| 7302 |
source=(Image *) NULL; |
| 7303 |
else |
| 7304 |
{ |
| 7305 |
/* |
| 7306 |
Separate the two lists, junk the null: image. |
| 7307 |
*/ |
| 7308 |
source=SplitImageList(source->previous); |
| 7309 |
DeleteImageFromList(&source); |
| 7310 |
} |
| 7311 |
} |
| 7312 |
if (source == (Image *) NULL) |
| 7313 |
{ |
| 7314 |
(void) ThrowMagickException(exception,GetMagickModule(), |
| 7315 |
OptionError,"MissingNullSeparator","layers Composite"); |
| 7316 |
break; |
| 7317 |
} |
| 7318 |
/* |
| 7319 |
Adjust offset with gravity and virtual canvas. |
| 7320 |
*/ |
| 7321 |
SetGeometry(image,&geometry); |
| 7322 |
(void) ParseAbsoluteGeometry(image->geometry,&geometry); |
| 7323 |
geometry.width=source->page.width != 0 ? source->page.width : |
| 7324 |
source->columns; |
| 7325 |
geometry.height=source->page.height != 0 ? source->page.height : |
| 7326 |
source->rows; |
| 7327 |
GravityAdjustGeometry(image->page.width != 0 ? image->page.width : |
| 7328 |
image->columns,image->page.height != 0 ? image->page.height : |
| 7329 |
image->rows,image->gravity,&geometry); |
| 7330 |
CompositeLayers(image,compose,source,geometry.x,geometry.y,exception); |
| 7331 |
source=DestroyImageList(source); |
| 7332 |
break; |
| 7333 |
} |
| 7334 |
} |
| 7335 |
if (layers != (Image *) NULL) |
| 7336 |
image=layers; |
| 7337 |
else |
| 7338 |
image=CloneImage(image,0,0,MagickTrue,exception); |
| 7339 |
if (image == (Image *) NULL) |
| 7340 |
goto PerlException; |
| 7341 |
for ( ; image; image=image->next) |
| 7342 |
{ |
| 7343 |
AddImageToRegistry(sv,image); |
| 7344 |
rv=newRV(sv); |
| 7345 |
av_push(av,sv_bless(rv,hv)); |
| 7346 |
SvREFCNT_dec(sv); |
| 7347 |
} |
| 7348 |
exception=DestroyExceptionInfo(exception); |
| 7349 |
ST(0)=av_reference; |
| 7350 |
SvREFCNT_dec(perl_exception); |
| 7351 |
XSRETURN(1); |
| 7352 |
|
| 7353 |
PerlException: |
| 7354 |
InheritPerlException(exception,perl_exception); |
| 7355 |
exception=DestroyExceptionInfo(exception); |
| 7356 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 7357 |
SvPOK_on(perl_exception); |
| 7358 |
ST(0)=sv_2mortal(perl_exception); |
| 7359 |
XSRETURN(1); |
| 7360 |
} |
| 7361 |
|
| 7362 |
# |
| 7363 |
############################################################################### |
| 7364 |
# # |
| 7365 |
# # |
| 7366 |
# # |
| 7367 |
# M a g i c k T o M i m e # |
| 7368 |
# # |
| 7369 |
# # |
| 7370 |
# # |
| 7371 |
############################################################################### |
| 7372 |
# |
| 7373 |
# |
| 7374 |
SV * |
| 7375 |
MagickToMime(ref,name) |
| 7376 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 7377 |
char *name |
| 7378 |
ALIAS: |
| 7379 |
magicktomime = 1 |
| 7380 |
CODE: |
| 7381 |
{ |
| 7382 |
char |
| 7383 |
*mime; |
| 7384 |
|
| 7385 |
PERL_UNUSED_VAR(ref); |
| 7386 |
PERL_UNUSED_VAR(ix); |
| 7387 |
mime=MagickToMime(name); |
| 7388 |
RETVAL=newSVpv(mime,0); |
| 7389 |
mime=(char *) RelinquishMagickMemory(mime); |
| 7390 |
} |
| 7391 |
OUTPUT: |
| 7392 |
RETVAL |
| 7393 |
|
| 7394 |
# |
| 7395 |
############################################################################### |
| 7396 |
# # |
| 7397 |
# # |
| 7398 |
# # |
| 7399 |
# M o g r i f y # |
| 7400 |
# # |
| 7401 |
# # |
| 7402 |
# # |
| 7403 |
############################################################################### |
| 7404 |
# |
| 7405 |
# |
| 7406 |
void |
| 7407 |
Mogrify(ref,...) |
| 7408 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 7409 |
ALIAS: |
| 7410 |
Comment = 1 |
| 7411 |
CommentImage = 2 |
| 7412 |
Label = 3 |
| 7413 |
LabelImage = 4 |
| 7414 |
AddNoise = 5 |
| 7415 |
AddNoiseImage = 6 |
| 7416 |
Colorize = 7 |
| 7417 |
ColorizeImage = 8 |
| 7418 |
Border = 9 |
| 7419 |
BorderImage = 10 |
| 7420 |
Blur = 11 |
| 7421 |
BlurImage = 12 |
| 7422 |
Chop = 13 |
| 7423 |
ChopImage = 14 |
| 7424 |
Crop = 15 |
| 7425 |
CropImage = 16 |
| 7426 |
Despeckle = 17 |
| 7427 |
DespeckleImage = 18 |
| 7428 |
Edge = 19 |
| 7429 |
EdgeImage = 20 |
| 7430 |
Emboss = 21 |
| 7431 |
EmbossImage = 22 |
| 7432 |
Enhance = 23 |
| 7433 |
EnhanceImage = 24 |
| 7434 |
Flip = 25 |
| 7435 |
FlipImage = 26 |
| 7436 |
Flop = 27 |
| 7437 |
FlopImage = 28 |
| 7438 |
Frame = 29 |
| 7439 |
FrameImage = 30 |
| 7440 |
Implode = 31 |
| 7441 |
ImplodeImage = 32 |
| 7442 |
Magnify = 33 |
| 7443 |
MagnifyImage = 34 |
| 7444 |
MedianFilter = 35 |
| 7445 |
MedianConvolveImage = 36 |
| 7446 |
Minify = 37 |
| 7447 |
MinifyImage = 38 |
| 7448 |
OilPaint = 39 |
| 7449 |
OilPaintImage = 40 |
| 7450 |
ReduceNoise = 41 |
| 7451 |
ReduceNoiseImage = 42 |
| 7452 |
Roll = 43 |
| 7453 |
RollImage = 44 |
| 7454 |
Rotate = 45 |
| 7455 |
RotateImage = 46 |
| 7456 |
Sample = 47 |
| 7457 |
SampleImage = 48 |
| 7458 |
Scale = 49 |
| 7459 |
ScaleImage = 50 |
| 7460 |
Shade = 51 |
| 7461 |
ShadeImage = 52 |
| 7462 |
Sharpen = 53 |
| 7463 |
SharpenImage = 54 |
| 7464 |
Shear = 55 |
| 7465 |
ShearImage = 56 |
| 7466 |
Spread = 57 |
| 7467 |
SpreadImage = 58 |
| 7468 |
Swirl = 59 |
| 7469 |
SwirlImage = 60 |
| 7470 |
Resize = 61 |
| 7471 |
ResizeImage = 62 |
| 7472 |
Zoom = 63 |
| 7473 |
ZoomImage = 64 |
| 7474 |
Annotate = 65 |
| 7475 |
AnnotateImage = 66 |
| 7476 |
ColorFloodfill = 67 |
| 7477 |
ColorFloodfillImage= 68 |
| 7478 |
Composite = 69 |
| 7479 |
CompositeImage = 70 |
| 7480 |
Contrast = 71 |
| 7481 |
ContrastImage = 72 |
| 7482 |
CycleColormap = 73 |
| 7483 |
CycleColormapImage = 74 |
| 7484 |
Draw = 75 |
| 7485 |
DrawImage = 76 |
| 7486 |
Equalize = 77 |
| 7487 |
EqualizeImage = 78 |
| 7488 |
Gamma = 79 |
| 7489 |
GammaImage = 80 |
| 7490 |
Map = 81 |
| 7491 |
MapImage = 82 |
| 7492 |
MatteFloodfill = 83 |
| 7493 |
MatteFloodfillImage= 84 |
| 7494 |
Modulate = 85 |
| 7495 |
ModulateImage = 86 |
| 7496 |
Negate = 87 |
| 7497 |
NegateImage = 88 |
| 7498 |
Normalize = 89 |
| 7499 |
NormalizeImage = 90 |
| 7500 |
NumberColors = 91 |
| 7501 |
NumberColorsImage = 92 |
| 7502 |
Opaque = 93 |
| 7503 |
OpaqueImage = 94 |
| 7504 |
Quantize = 95 |
| 7505 |
QuantizeImage = 96 |
| 7506 |
Raise = 97 |
| 7507 |
RaiseImage = 98 |
| 7508 |
Segment = 99 |
| 7509 |
SegmentImage = 100 |
| 7510 |
Signature = 101 |
| 7511 |
SignatureImage = 102 |
| 7512 |
Solarize = 103 |
| 7513 |
SolarizeImage = 104 |
| 7514 |
Sync = 105 |
| 7515 |
SyncImage = 106 |
| 7516 |
Texture = 107 |
| 7517 |
TextureImage = 108 |
| 7518 |
Evaluate = 109 |
| 7519 |
EvaluateImage = 110 |
| 7520 |
Transparent = 111 |
| 7521 |
TransparentImage = 112 |
| 7522 |
Threshold = 113 |
| 7523 |
ThresholdImage = 114 |
| 7524 |
Charcoal = 115 |
| 7525 |
CharcoalImage = 116 |
| 7526 |
Trim = 117 |
| 7527 |
TrimImage = 118 |
| 7528 |
Wave = 119 |
| 7529 |
WaveImage = 120 |
| 7530 |
Separate = 121 |
| 7531 |
SeparateImage = 122 |
| 7532 |
Stereo = 125 |
| 7533 |
StereoImage = 126 |
| 7534 |
Stegano = 127 |
| 7535 |
SteganoImage = 128 |
| 7536 |
Deconstruct = 129 |
| 7537 |
DeconstructImage = 130 |
| 7538 |
GaussianBlur = 131 |
| 7539 |
GaussianBlurImage = 132 |
| 7540 |
Convolve = 133 |
| 7541 |
ConvolveImage = 134 |
| 7542 |
Profile = 135 |
| 7543 |
ProfileImage = 136 |
| 7544 |
UnsharpMask = 137 |
| 7545 |
UnsharpMaskImage = 138 |
| 7546 |
MotionBlur = 139 |
| 7547 |
MotionBlurImage = 140 |
| 7548 |
OrderedDither = 141 |
| 7549 |
OrderedDitherImage = 142 |
| 7550 |
Shave = 143 |
| 7551 |
ShaveImage = 144 |
| 7552 |
Level = 145 |
| 7553 |
LevelImage = 146 |
| 7554 |
Clip = 147 |
| 7555 |
ClipImage = 148 |
| 7556 |
AffineTransform = 149 |
| 7557 |
AffineTransformImage = 150 |
| 7558 |
Difference = 151 |
| 7559 |
DifferenceImage = 152 |
| 7560 |
AdaptiveThreshold = 153 |
| 7561 |
AdaptiveThresholdImage = 154 |
| 7562 |
Resample = 155 |
| 7563 |
ResampleImage = 156 |
| 7564 |
Describe = 157 |
| 7565 |
DescribeImage = 158 |
| 7566 |
BlackThreshold = 159 |
| 7567 |
BlackThresholdImage= 160 |
| 7568 |
WhiteThreshold = 161 |
| 7569 |
WhiteThresholdImage= 162 |
| 7570 |
RotationalBlur = 163 |
| 7571 |
RotationalBlurImage= 164 |
| 7572 |
Thumbnail = 165 |
| 7573 |
ThumbnailImage = 166 |
| 7574 |
Strip = 167 |
| 7575 |
StripImage = 168 |
| 7576 |
Tint = 169 |
| 7577 |
TintImage = 170 |
| 7578 |
Channel = 171 |
| 7579 |
ChannelImage = 172 |
| 7580 |
Splice = 173 |
| 7581 |
SpliceImage = 174 |
| 7582 |
Posterize = 175 |
| 7583 |
PosterizeImage = 176 |
| 7584 |
Shadow = 177 |
| 7585 |
ShadowImage = 178 |
| 7586 |
Identify = 179 |
| 7587 |
IdentifyImage = 180 |
| 7588 |
SepiaTone = 181 |
| 7589 |
SepiaToneImage = 182 |
| 7590 |
SigmoidalContrast = 183 |
| 7591 |
SigmoidalContrastImage = 184 |
| 7592 |
Extent = 185 |
| 7593 |
ExtentImage = 186 |
| 7594 |
Vignette = 187 |
| 7595 |
VignetteImage = 188 |
| 7596 |
ContrastStretch = 189 |
| 7597 |
ContrastStretchImage = 190 |
| 7598 |
Sans0 = 191 |
| 7599 |
Sans0Image = 192 |
| 7600 |
Sans1 = 193 |
| 7601 |
Sans1Image = 194 |
| 7602 |
AdaptiveSharpen = 195 |
| 7603 |
AdaptiveSharpenImage = 196 |
| 7604 |
Transpose = 197 |
| 7605 |
TransposeImage = 198 |
| 7606 |
Transverse = 199 |
| 7607 |
TransverseImage = 200 |
| 7608 |
AutoOrient = 201 |
| 7609 |
AutoOrientImage = 202 |
| 7610 |
AdaptiveBlur = 203 |
| 7611 |
AdaptiveBlurImage = 204 |
| 7612 |
Sketch = 205 |
| 7613 |
SketchImage = 206 |
| 7614 |
UniqueColors = 207 |
| 7615 |
UniqueColorsImage = 208 |
| 7616 |
AdaptiveResize = 209 |
| 7617 |
AdaptiveResizeImage= 210 |
| 7618 |
ClipMask = 211 |
| 7619 |
ClipMaskImage = 212 |
| 7620 |
LinearStretch = 213 |
| 7621 |
LinearStretchImage = 214 |
| 7622 |
ColorMatrix = 215 |
| 7623 |
ColorMatrixImage = 216 |
| 7624 |
Mask = 217 |
| 7625 |
MaskImage = 218 |
| 7626 |
Polaroid = 219 |
| 7627 |
PolaroidImage = 220 |
| 7628 |
FloodfillPaint = 221 |
| 7629 |
FloodfillPaintImage= 222 |
| 7630 |
Distort = 223 |
| 7631 |
DistortImage = 224 |
| 7632 |
Clut = 225 |
| 7633 |
ClutImage = 226 |
| 7634 |
LiquidRescale = 227 |
| 7635 |
LiquidRescaleImage = 228 |
| 7636 |
Encipher = 229 |
| 7637 |
EncipherImage = 230 |
| 7638 |
Decipher = 231 |
| 7639 |
DecipherImage = 232 |
| 7640 |
Deskew = 233 |
| 7641 |
DeskewImage = 234 |
| 7642 |
Remap = 235 |
| 7643 |
RemapImage = 236 |
| 7644 |
SparseColor = 237 |
| 7645 |
SparseColorImage = 238 |
| 7646 |
Function = 239 |
| 7647 |
FunctionImage = 240 |
| 7648 |
SelectiveBlur = 241 |
| 7649 |
SelectiveBlurImage = 242 |
| 7650 |
HaldClut = 243 |
| 7651 |
HaldClutImage = 244 |
| 7652 |
BlueShift = 245 |
| 7653 |
BlueShiftImage = 246 |
| 7654 |
ForwardFourierTransform = 247 |
| 7655 |
ForwardFourierTransformImage = 248 |
| 7656 |
InverseFourierTransform = 249 |
| 7657 |
InverseFourierTransformImage = 250 |
| 7658 |
ColorDecisionList = 251 |
| 7659 |
ColorDecisionListImage = 252 |
| 7660 |
AutoGamma = 253 |
| 7661 |
AutoGammaImage = 254 |
| 7662 |
AutoLevel = 255 |
| 7663 |
AutoLevelImage = 256 |
| 7664 |
LevelColors = 257 |
| 7665 |
LevelImageColors = 258 |
| 7666 |
Clamp = 259 |
| 7667 |
ClampImage = 260 |
| 7668 |
BrightnessContrast = 261 |
| 7669 |
BrightnessContrastImage = 262 |
| 7670 |
Morphology = 263 |
| 7671 |
MorphologyImage = 264 |
| 7672 |
Mode = 265 |
| 7673 |
ModeImage = 266 |
| 7674 |
Statistic = 267 |
| 7675 |
StatisticImage = 268 |
| 7676 |
Perceptible = 269 |
| 7677 |
PerceptibleImage = 270 |
| 7678 |
Poly = 271 |
| 7679 |
PolyImage = 272 |
| 7680 |
Grayscale = 273 |
| 7681 |
GrayscaleImage = 274 |
| 7682 |
CannyEdge = 275 |
| 7683 |
CannyEdgeImage = 276 |
| 7684 |
HoughLine = 277 |
| 7685 |
HoughLineImage = 278 |
| 7686 |
MeanShift = 279 |
| 7687 |
MeanShiftImage = 280 |
| 7688 |
Kuwahara = 281 |
| 7689 |
KuwaharaImage = 282 |
| 7690 |
ConnectedComponents = 283 |
| 7691 |
ConnectedComponentsImage = 284 |
| 7692 |
CopyPixels = 285 |
| 7693 |
CopyImagePixels = 286 |
| 7694 |
Color = 287 |
| 7695 |
ColorImage = 288 |
| 7696 |
WaveletDenoise = 289 |
| 7697 |
WaveletDenoiseImage= 290 |
| 7698 |
Colorspace = 291 |
| 7699 |
ColorspaceImage = 292 |
| 7700 |
AutoThreshold = 293 |
| 7701 |
AutoThresholdImage = 294 |
| 7702 |
RangeThreshold = 295 |
| 7703 |
RangeThresholdImage= 296 |
| 7704 |
CLAHE = 297 |
| 7705 |
CLAHEImage = 298 |
| 7706 |
Kmeans = 299 |
| 7707 |
KMeansImage = 300 |
| 7708 |
ColorThreshold = 301 |
| 7709 |
ColorThresholdImage= 302 |
| 7710 |
WhiteBalance = 303 |
| 7711 |
WhiteBalanceImage = 304 |
| 7712 |
BilateralBlur = 305 |
| 7713 |
BilateralBlurImage = 306 |
| 7714 |
SortPixels = 307 |
| 7715 |
SortPixelsImage = 308 |
| 7716 |
Integral = 309 |
| 7717 |
IntegralImage = 310 |
| 7718 |
MogrifyRegion = 666 |
| 7719 |
PPCODE: |
| 7720 |
{ |
| 7721 |
AffineMatrix |
| 7722 |
affine, |
| 7723 |
current; |
| 7724 |
|
| 7725 |
char |
| 7726 |
attribute_flag[MaxArguments], |
| 7727 |
message[MagickPathExtent]; |
| 7728 |
|
| 7729 |
ChannelType |
| 7730 |
channel, |
| 7731 |
channel_mask; |
| 7732 |
|
| 7733 |
CompositeOperator |
| 7734 |
compose; |
| 7735 |
|
| 7736 |
const char |
| 7737 |
*attribute, |
| 7738 |
*value; |
| 7739 |
|
| 7740 |
double |
| 7741 |
angle; |
| 7742 |
|
| 7743 |
ExceptionInfo |
| 7744 |
*exception; |
| 7745 |
|
| 7746 |
GeometryInfo |
| 7747 |
geometry_info; |
| 7748 |
|
| 7749 |
Image |
| 7750 |
*image, |
| 7751 |
*next; |
| 7752 |
|
| 7753 |
MagickStatusType |
| 7754 |
flags; |
| 7755 |
|
| 7756 |
PixelInfo |
| 7757 |
fill_color; |
| 7758 |
|
| 7759 |
RectangleInfo |
| 7760 |
geometry, |
| 7761 |
region_info; |
| 7762 |
|
| 7763 |
ssize_t |
| 7764 |
base, |
| 7765 |
i, |
| 7766 |
j, |
| 7767 |
number_images; |
| 7768 |
|
| 7769 |
struct Methods |
| 7770 |
*rp; |
| 7771 |
|
| 7772 |
struct PackageInfo |
| 7773 |
*info; |
| 7774 |
|
| 7775 |
SV |
| 7776 |
*perl_exception, |
| 7777 |
**pv, |
| 7778 |
*reference, |
| 7779 |
**reference_vector; |
| 7780 |
|
| 7781 |
struct ArgumentList |
| 7782 |
argument_list[MaxArguments]; |
| 7783 |
|
| 7784 |
PERL_UNUSED_VAR(ref); |
| 7785 |
PERL_UNUSED_VAR(ix); |
| 7786 |
exception=AcquireExceptionInfo(); |
| 7787 |
perl_exception=newSVpv("",0); |
| 7788 |
reference_vector=NULL; |
| 7789 |
number_images=0; |
| 7790 |
base=2; |
| 7791 |
if (sv_isobject(ST(0)) == 0) |
| 7792 |
{ |
| 7793 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 7794 |
PackageName); |
| 7795 |
goto PerlException; |
| 7796 |
} |
| 7797 |
reference=SvRV(ST(0)); |
| 7798 |
region_info.width=0; |
| 7799 |
region_info.height=0; |
| 7800 |
region_info.x=0; |
| 7801 |
region_info.y=0; |
| 7802 |
image=SetupList(aTHX_ reference,&info,&reference_vector,exception); |
| 7803 |
if (ix && (ix != 666)) |
| 7804 |
{ |
| 7805 |
/* |
| 7806 |
Called as Method(...) |
| 7807 |
*/ |
| 7808 |
ix=(ix+1)/2; |
| 7809 |
rp=(&Methods[ix-1]); |
| 7810 |
attribute=rp->name; |
| 7811 |
} |
| 7812 |
else |
| 7813 |
{ |
| 7814 |
/* |
| 7815 |
Called as Mogrify("Method",...) |
| 7816 |
*/ |
| 7817 |
attribute=(char *) SvPV(ST(1),na); |
| 7818 |
if (ix) |
| 7819 |
{ |
| 7820 |
flags=ParseGravityGeometry(image,attribute,®ion_info,exception); |
| 7821 |
attribute=(char *) SvPV(ST(2),na); |
| 7822 |
base++; |
| 7823 |
} |
| 7824 |
for (rp=Methods; ; rp++) |
| 7825 |
{ |
| 7826 |
if (rp >= EndOf(Methods)) |
| 7827 |
{ |
| 7828 |
ThrowPerlException(exception,OptionError, |
| 7829 |
"UnrecognizedPerlMagickMethod",attribute); |
| 7830 |
goto PerlException; |
| 7831 |
} |
| 7832 |
if (strEQcase(attribute,rp->name)) |
| 7833 |
break; |
| 7834 |
} |
| 7835 |
ix=rp-Methods+1; |
| 7836 |
base++; |
| 7837 |
} |
| 7838 |
if (image == (Image *) NULL) |
| 7839 |
{ |
| 7840 |
ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute); |
| 7841 |
goto PerlException; |
| 7842 |
} |
| 7843 |
Zero(&argument_list,NumberOf(argument_list),struct ArgumentList); |
| 7844 |
Zero(&attribute_flag,NumberOf(attribute_flag),char); |
| 7845 |
for (i=base; (i < items) || ((i == items) && (base == items)); i+=2) |
| 7846 |
{ |
| 7847 |
Arguments |
| 7848 |
*pp, |
| 7849 |
*qq; |
| 7850 |
|
| 7851 |
ssize_t |
| 7852 |
ssize_test; |
| 7853 |
|
| 7854 |
struct ArgumentList |
| 7855 |
*al; |
| 7856 |
|
| 7857 |
SV |
| 7858 |
*sv; |
| 7859 |
|
| 7860 |
sv=NULL; |
| 7861 |
ssize_test=0; |
| 7862 |
pp=(Arguments *) NULL; |
| 7863 |
qq=rp->arguments; |
| 7864 |
if (i == items) |
| 7865 |
{ |
| 7866 |
pp=rp->arguments, |
| 7867 |
sv=ST(i-1); |
| 7868 |
} |
| 7869 |
else |
| 7870 |
for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++) |
| 7871 |
{ |
| 7872 |
if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL)) |
| 7873 |
break; |
| 7874 |
if (strEQcase(attribute,qq->method) > ssize_test) |
| 7875 |
{ |
| 7876 |
pp=qq; |
| 7877 |
ssize_test=strEQcase(attribute,qq->method); |
| 7878 |
} |
| 7879 |
} |
| 7880 |
if (pp == (Arguments *) NULL) |
| 7881 |
{ |
| 7882 |
ThrowPerlException(exception,OptionError,"UnrecognizedOption", |
| 7883 |
attribute); |
| 7884 |
goto continue_outer_loop; |
| 7885 |
} |
| 7886 |
al=(&argument_list[pp-rp->arguments]); |
| 7887 |
switch (pp->type) |
| 7888 |
{ |
| 7889 |
case ArrayReference: |
| 7890 |
{ |
| 7891 |
if (SvTYPE(sv) != SVt_RV) |
| 7892 |
{ |
| 7893 |
(void) FormatLocaleString(message,MagickPathExtent, |
| 7894 |
"invalid %.60s value",pp->method); |
| 7895 |
ThrowPerlException(exception,OptionError,message,SvPV(sv,na)); |
| 7896 |
goto continue_outer_loop; |
| 7897 |
} |
| 7898 |
al->array_reference=SvRV(sv); |
| 7899 |
break; |
| 7900 |
} |
| 7901 |
case RealReference: |
| 7902 |
{ |
| 7903 |
al->real_reference=SvNV(sv); |
| 7904 |
break; |
| 7905 |
} |
| 7906 |
case FileReference: |
| 7907 |
{ |
| 7908 |
al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv))); |
| 7909 |
break; |
| 7910 |
} |
| 7911 |
case ImageReference: |
| 7912 |
{ |
| 7913 |
if (!sv_isobject(sv) || |
| 7914 |
!(al->image_reference=SetupList(aTHX_ SvRV(sv), |
| 7915 |
(struct PackageInfo **) NULL,(SV ***) NULL,exception))) |
| 7916 |
{ |
| 7917 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 7918 |
PackageName); |
| 7919 |
goto PerlException; |
| 7920 |
} |
| 7921 |
break; |
| 7922 |
} |
| 7923 |
case IntegerReference: |
| 7924 |
{ |
| 7925 |
al->integer_reference=SvIV(sv); |
| 7926 |
break; |
| 7927 |
} |
| 7928 |
case StringReference: |
| 7929 |
{ |
| 7930 |
al->string_reference=(char *) SvPV(sv,al->length); |
| 7931 |
if (sv_isobject(sv)) |
| 7932 |
al->image_reference=SetupList(aTHX_ SvRV(sv), |
| 7933 |
(struct PackageInfo **) NULL,(SV ***) NULL,exception); |
| 7934 |
break; |
| 7935 |
} |
| 7936 |
default: |
| 7937 |
{ |
| 7938 |
/* |
| 7939 |
Is a string; look up name. |
| 7940 |
*/ |
| 7941 |
if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@')) |
| 7942 |
{ |
| 7943 |
al->string_reference=(char *) SvPV(sv,al->length); |
| 7944 |
al->integer_reference=(-1); |
| 7945 |
break; |
| 7946 |
} |
| 7947 |
al->integer_reference=ParseCommandOption((CommandOption) pp->type, |
| 7948 |
MagickFalse,SvPV(sv,na)); |
| 7949 |
if (pp->type == MagickChannelOptions) |
| 7950 |
al->integer_reference=ParseChannelOption(SvPV(sv,na)); |
| 7951 |
if ((al->integer_reference < 0) && |
| 7952 |
((al->integer_reference=SvIV(sv)) <= 0)) |
| 7953 |
{ |
| 7954 |
(void) FormatLocaleString(message,MagickPathExtent, |
| 7955 |
"invalid %.60s value",pp->method); |
| 7956 |
ThrowPerlException(exception,OptionError,message,SvPV(sv,na)); |
| 7957 |
goto continue_outer_loop; |
| 7958 |
} |
| 7959 |
break; |
| 7960 |
} |
| 7961 |
} |
| 7962 |
attribute_flag[pp-rp->arguments]++; |
| 7963 |
continue_outer_loop: ; |
| 7964 |
} |
| 7965 |
(void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color)); |
| 7966 |
pv=reference_vector; |
| 7967 |
SetGeometryInfo(&geometry_info); |
| 7968 |
channel=DefaultChannels; |
| 7969 |
for (next=image; next; next=next->next) |
| 7970 |
{ |
| 7971 |
image=next; |
| 7972 |
SetGeometry(image,&geometry); |
| 7973 |
if ((region_info.width*region_info.height) != 0) |
| 7974 |
(void) SetImageRegionMask(image,WritePixelMask,®ion_info,exception); |
| 7975 |
switch (ix) |
| 7976 |
{ |
| 7977 |
default: |
| 7978 |
{ |
| 7979 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double) |
| 7980 |
ix); |
| 7981 |
ThrowPerlException(exception,OptionError, |
| 7982 |
"UnrecognizedPerlMagickMethod",message); |
| 7983 |
goto PerlException; |
| 7984 |
} |
| 7985 |
case 1: /* Comment */ |
| 7986 |
{ |
| 7987 |
if (attribute_flag[0] == 0) |
| 7988 |
argument_list[0].string_reference=(char *) NULL; |
| 7989 |
(void) SetImageProperty(image,"comment",InterpretImageProperties( |
| 7990 |
info ? info->image_info : (ImageInfo *) NULL,image, |
| 7991 |
argument_list[0].string_reference,exception),exception); |
| 7992 |
break; |
| 7993 |
} |
| 7994 |
case 2: /* Label */ |
| 7995 |
{ |
| 7996 |
if (attribute_flag[0] == 0) |
| 7997 |
argument_list[0].string_reference=(char *) NULL; |
| 7998 |
(void) SetImageProperty(image,"label",InterpretImageProperties( |
| 7999 |
info ? info->image_info : (ImageInfo *) NULL,image, |
| 8000 |
argument_list[0].string_reference,exception),exception); |
| 8001 |
break; |
| 8002 |
} |
| 8003 |
case 3: /* AddNoise */ |
| 8004 |
{ |
| 8005 |
double |
| 8006 |
attenuate; |
| 8007 |
|
| 8008 |
if (attribute_flag[0] == 0) |
| 8009 |
argument_list[0].integer_reference=UniformNoise; |
| 8010 |
attenuate=1.0; |
| 8011 |
if (attribute_flag[1] != 0) |
| 8012 |
attenuate=argument_list[1].real_reference; |
| 8013 |
if (attribute_flag[2] != 0) |
| 8014 |
channel=(ChannelType) argument_list[2].integer_reference; |
| 8015 |
channel_mask=SetImageChannelMask(image,channel); |
| 8016 |
image=AddNoiseImage(image,(NoiseType) |
| 8017 |
argument_list[0].integer_reference,attenuate,exception); |
| 8018 |
if (image != (Image *) NULL) |
| 8019 |
(void) SetImageChannelMask(image,channel_mask); |
| 8020 |
break; |
| 8021 |
} |
| 8022 |
case 4: /* Colorize */ |
| 8023 |
{ |
| 8024 |
PixelInfo |
| 8025 |
target; |
| 8026 |
|
| 8027 |
(void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,0,0, |
| 8028 |
&target,exception); |
| 8029 |
if (attribute_flag[0] != 0) |
| 8030 |
(void) QueryColorCompliance(argument_list[0].string_reference, |
| 8031 |
AllCompliance,&target,exception); |
| 8032 |
if (attribute_flag[1] == 0) |
| 8033 |
argument_list[1].string_reference="100%"; |
| 8034 |
image=ColorizeImage(image,argument_list[1].string_reference,&target, |
| 8035 |
exception); |
| 8036 |
break; |
| 8037 |
} |
| 8038 |
case 5: /* Border */ |
| 8039 |
{ |
| 8040 |
CompositeOperator |
| 8041 |
compose; |
| 8042 |
|
| 8043 |
geometry.width=0; |
| 8044 |
geometry.height=0; |
| 8045 |
if (attribute_flag[0] != 0) |
| 8046 |
flags=ParsePageGeometry(image,argument_list[0].string_reference, |
| 8047 |
&geometry,exception); |
| 8048 |
if (attribute_flag[1] != 0) |
| 8049 |
geometry.width=(size_t) argument_list[1].integer_reference; |
| 8050 |
if (attribute_flag[2] != 0) |
| 8051 |
geometry.height=(size_t) argument_list[2].integer_reference; |
| 8052 |
if (attribute_flag[3] != 0) |
| 8053 |
QueryColorCompliance(argument_list[3].string_reference, |
| 8054 |
AllCompliance,&image->border_color,exception); |
| 8055 |
if (attribute_flag[4] != 0) |
| 8056 |
QueryColorCompliance(argument_list[4].string_reference, |
| 8057 |
AllCompliance,&image->border_color,exception); |
| 8058 |
if (attribute_flag[5] != 0) |
| 8059 |
QueryColorCompliance(argument_list[5].string_reference, |
| 8060 |
AllCompliance,&image->border_color,exception); |
| 8061 |
compose=image->compose; |
| 8062 |
if (attribute_flag[6] != 0) |
| 8063 |
compose=(CompositeOperator) argument_list[6].integer_reference; |
| 8064 |
image=BorderImage(image,&geometry,compose,exception); |
| 8065 |
break; |
| 8066 |
} |
| 8067 |
case 6: /* Blur */ |
| 8068 |
{ |
| 8069 |
if (attribute_flag[0] != 0) |
| 8070 |
{ |
| 8071 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 8072 |
&geometry_info); |
| 8073 |
if ((flags & SigmaValue) == 0) |
| 8074 |
geometry_info.sigma=1.0; |
| 8075 |
} |
| 8076 |
if (attribute_flag[1] != 0) |
| 8077 |
geometry_info.rho=argument_list[1].real_reference; |
| 8078 |
if (attribute_flag[2] != 0) |
| 8079 |
geometry_info.sigma=argument_list[2].real_reference; |
| 8080 |
if (attribute_flag[3] != 0) |
| 8081 |
channel=(ChannelType) argument_list[3].integer_reference; |
| 8082 |
channel_mask=SetImageChannelMask(image,channel); |
| 8083 |
image=BlurImage(image,geometry_info.rho,geometry_info.sigma, |
| 8084 |
exception); |
| 8085 |
if (image != (Image *) NULL) |
| 8086 |
(void) SetImageChannelMask(image,channel_mask); |
| 8087 |
break; |
| 8088 |
} |
| 8089 |
case 7: /* Chop */ |
| 8090 |
{ |
| 8091 |
if (attribute_flag[5] != 0) |
| 8092 |
image->gravity=(GravityType) argument_list[5].integer_reference; |
| 8093 |
if (attribute_flag[0] != 0) |
| 8094 |
flags=ParseGravityGeometry(image,argument_list[0].string_reference, |
| 8095 |
&geometry,exception); |
| 8096 |
if (attribute_flag[1] != 0) |
| 8097 |
geometry.width=(size_t) argument_list[1].integer_reference; |
| 8098 |
if (attribute_flag[2] != 0) |
| 8099 |
geometry.height=(size_t) argument_list[2].integer_reference; |
| 8100 |
if (attribute_flag[3] != 0) |
| 8101 |
geometry.x=argument_list[3].integer_reference; |
| 8102 |
if (attribute_flag[4] != 0) |
| 8103 |
geometry.y=argument_list[4].integer_reference; |
| 8104 |
image=ChopImage(image,&geometry,exception); |
| 8105 |
break; |
| 8106 |
} |
| 8107 |
case 8: /* Crop */ |
| 8108 |
{ |
| 8109 |
if (attribute_flag[6] != 0) |
| 8110 |
image->gravity=(GravityType) argument_list[6].integer_reference; |
| 8111 |
if (attribute_flag[0] != 0) |
| 8112 |
flags=ParseGravityGeometry(image,argument_list[0].string_reference, |
| 8113 |
&geometry,exception); |
| 8114 |
if (attribute_flag[1] != 0) |
| 8115 |
geometry.width=(size_t) argument_list[1].integer_reference; |
| 8116 |
if (attribute_flag[2] != 0) |
| 8117 |
geometry.height=(size_t) argument_list[2].integer_reference; |
| 8118 |
if (attribute_flag[3] != 0) |
| 8119 |
geometry.x=argument_list[3].integer_reference; |
| 8120 |
if (attribute_flag[4] != 0) |
| 8121 |
geometry.y=argument_list[4].integer_reference; |
| 8122 |
if (attribute_flag[5] != 0) |
| 8123 |
image->fuzz=StringToDoubleInterval( |
| 8124 |
argument_list[5].string_reference,(double) QuantumRange+1.0); |
| 8125 |
image=CropImage(image,&geometry,exception); |
| 8126 |
break; |
| 8127 |
} |
| 8128 |
case 9: /* Despeckle */ |
| 8129 |
{ |
| 8130 |
image=DespeckleImage(image,exception); |
| 8131 |
break; |
| 8132 |
} |
| 8133 |
case 10: /* Edge */ |
| 8134 |
{ |
| 8135 |
if (attribute_flag[0] != 0) |
| 8136 |
geometry_info.rho=argument_list[0].real_reference; |
| 8137 |
image=EdgeImage(image,geometry_info.rho,exception); |
| 8138 |
break; |
| 8139 |
} |
| 8140 |
case 11: /* Emboss */ |
| 8141 |
{ |
| 8142 |
if (attribute_flag[0] != 0) |
| 8143 |
{ |
| 8144 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 8145 |
&geometry_info); |
| 8146 |
if ((flags & SigmaValue) == 0) |
| 8147 |
geometry_info.sigma=1.0; |
| 8148 |
} |
| 8149 |
if (attribute_flag[1] != 0) |
| 8150 |
geometry_info.rho=argument_list[1].real_reference; |
| 8151 |
if (attribute_flag[2] != 0) |
| 8152 |
geometry_info.sigma=argument_list[2].real_reference; |
| 8153 |
image=EmbossImage(image,geometry_info.rho,geometry_info.sigma, |
| 8154 |
exception); |
| 8155 |
break; |
| 8156 |
} |
| 8157 |
case 12: /* Enhance */ |
| 8158 |
{ |
| 8159 |
image=EnhanceImage(image,exception); |
| 8160 |
break; |
| 8161 |
} |
| 8162 |
case 13: /* Flip */ |
| 8163 |
{ |
| 8164 |
image=FlipImage(image,exception); |
| 8165 |
break; |
| 8166 |
} |
| 8167 |
case 14: /* Flop */ |
| 8168 |
{ |
| 8169 |
image=FlopImage(image,exception); |
| 8170 |
break; |
| 8171 |
} |
| 8172 |
case 15: /* Frame */ |
| 8173 |
{ |
| 8174 |
CompositeOperator |
| 8175 |
compose; |
| 8176 |
|
| 8177 |
FrameInfo |
| 8178 |
frame_info; |
| 8179 |
|
| 8180 |
if (attribute_flag[0] != 0) |
| 8181 |
{ |
| 8182 |
flags=ParsePageGeometry(image,argument_list[0].string_reference, |
| 8183 |
&geometry,exception); |
| 8184 |
frame_info.width=geometry.width; |
| 8185 |
frame_info.height=geometry.height; |
| 8186 |
frame_info.outer_bevel=geometry.x; |
| 8187 |
frame_info.inner_bevel=geometry.y; |
| 8188 |
} |
| 8189 |
if (attribute_flag[1] != 0) |
| 8190 |
frame_info.width=(size_t) argument_list[1].integer_reference; |
| 8191 |
if (attribute_flag[2] != 0) |
| 8192 |
frame_info.height=(size_t) argument_list[2].integer_reference; |
| 8193 |
if (attribute_flag[3] != 0) |
| 8194 |
frame_info.inner_bevel=argument_list[3].integer_reference; |
| 8195 |
if (attribute_flag[4] != 0) |
| 8196 |
frame_info.outer_bevel=argument_list[4].integer_reference; |
| 8197 |
if (attribute_flag[5] != 0) |
| 8198 |
QueryColorCompliance(argument_list[5].string_reference, |
| 8199 |
AllCompliance,&fill_color,exception); |
| 8200 |
if (attribute_flag[6] != 0) |
| 8201 |
QueryColorCompliance(argument_list[6].string_reference, |
| 8202 |
AllCompliance,&fill_color,exception); |
| 8203 |
frame_info.x=(ssize_t) frame_info.width; |
| 8204 |
frame_info.y=(ssize_t) frame_info.height; |
| 8205 |
frame_info.width=(size_t) ((ssize_t) image->columns+2*frame_info.x); |
| 8206 |
frame_info.height=(size_t) ((ssize_t) image->rows+2*frame_info.y); |
| 8207 |
if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0)) |
| 8208 |
image->alpha_color=fill_color; |
| 8209 |
compose=image->compose; |
| 8210 |
if (attribute_flag[7] != 0) |
| 8211 |
compose=(CompositeOperator) argument_list[7].integer_reference; |
| 8212 |
image=FrameImage(image,&frame_info,compose,exception); |
| 8213 |
break; |
| 8214 |
} |
| 8215 |
case 16: /* Implode */ |
| 8216 |
{ |
| 8217 |
PixelInterpolateMethod |
| 8218 |
method; |
| 8219 |
|
| 8220 |
if (attribute_flag[0] == 0) |
| 8221 |
argument_list[0].real_reference=0.5; |
| 8222 |
method=UndefinedInterpolatePixel; |
| 8223 |
if (attribute_flag[1] != 0) |
| 8224 |
method=(PixelInterpolateMethod) argument_list[1].integer_reference; |
| 8225 |
image=ImplodeImage(image,argument_list[0].real_reference, |
| 8226 |
method,exception); |
| 8227 |
break; |
| 8228 |
} |
| 8229 |
case 17: /* Magnify */ |
| 8230 |
{ |
| 8231 |
image=MagnifyImage(image,exception); |
| 8232 |
break; |
| 8233 |
} |
| 8234 |
case 18: /* MedianFilter */ |
| 8235 |
{ |
| 8236 |
if (attribute_flag[0] != 0) |
| 8237 |
{ |
| 8238 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 8239 |
&geometry_info); |
| 8240 |
if ((flags & SigmaValue) == 0) |
| 8241 |
geometry_info.sigma=geometry_info.rho; |
| 8242 |
} |
| 8243 |
if (attribute_flag[1] != 0) |
| 8244 |
geometry_info.rho=argument_list[1].real_reference; |
| 8245 |
if (attribute_flag[2] != 0) |
| 8246 |
geometry_info.sigma=argument_list[2].real_reference; |
| 8247 |
if (attribute_flag[3] != 0) |
| 8248 |
channel=(ChannelType) argument_list[3].integer_reference; |
| 8249 |
channel_mask=SetImageChannelMask(image,channel); |
| 8250 |
image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho, |
| 8251 |
(size_t) geometry_info.sigma,exception); |
| 8252 |
if (image != (Image *) NULL) |
| 8253 |
(void) SetImageChannelMask(image,channel_mask); |
| 8254 |
break; |
| 8255 |
} |
| 8256 |
case 19: /* Minify */ |
| 8257 |
{ |
| 8258 |
image=MinifyImage(image,exception); |
| 8259 |
break; |
| 8260 |
} |
| 8261 |
case 20: /* OilPaint */ |
| 8262 |
{ |
| 8263 |
if (attribute_flag[0] == 0) |
| 8264 |
argument_list[0].real_reference=0.0; |
| 8265 |
if (attribute_flag[1] == 0) |
| 8266 |
argument_list[1].real_reference=1.0; |
| 8267 |
image=OilPaintImage(image,argument_list[0].real_reference, |
| 8268 |
argument_list[1].real_reference,exception); |
| 8269 |
break; |
| 8270 |
} |
| 8271 |
case 21: /* ReduceNoise */ |
| 8272 |
{ |
| 8273 |
if (attribute_flag[0] != 0) |
| 8274 |
{ |
| 8275 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 8276 |
&geometry_info); |
| 8277 |
if ((flags & SigmaValue) == 0) |
| 8278 |
geometry_info.sigma=1.0; |
| 8279 |
} |
| 8280 |
if (attribute_flag[1] != 0) |
| 8281 |
geometry_info.rho=argument_list[1].real_reference; |
| 8282 |
if (attribute_flag[2] != 0) |
| 8283 |
geometry_info.sigma=argument_list[2].real_reference; |
| 8284 |
if (attribute_flag[3] != 0) |
| 8285 |
channel=(ChannelType) argument_list[3].integer_reference; |
| 8286 |
channel_mask=SetImageChannelMask(image,channel); |
| 8287 |
image=StatisticImage(image,NonpeakStatistic,(size_t) |
| 8288 |
geometry_info.rho,(size_t) geometry_info.sigma,exception); |
| 8289 |
if (image != (Image *) NULL) |
| 8290 |
(void) SetImageChannelMask(image,channel_mask); |
| 8291 |
break; |
| 8292 |
} |
| 8293 |
case 22: /* Roll */ |
| 8294 |
{ |
| 8295 |
if (attribute_flag[0] != 0) |
| 8296 |
{ |
| 8297 |
flags=ParsePageGeometry(image,argument_list[0].string_reference, |
| 8298 |
&geometry,exception); |
| 8299 |
if ((flags & PercentValue) != 0) |
| 8300 |
{ |
| 8301 |
geometry.x*=(double) image->columns/100.0; |
| 8302 |
geometry.y*=(double) image->rows/100.0; |
| 8303 |
} |
| 8304 |
} |
| 8305 |
if (attribute_flag[1] != 0) |
| 8306 |
geometry.x=argument_list[1].integer_reference; |
| 8307 |
if (attribute_flag[2] != 0) |
| 8308 |
geometry.y=argument_list[2].integer_reference; |
| 8309 |
image=RollImage(image,geometry.x,geometry.y,exception); |
| 8310 |
break; |
| 8311 |
} |
| 8312 |
case 23: /* Rotate */ |
| 8313 |
{ |
| 8314 |
if (attribute_flag[0] == 0) |
| 8315 |
argument_list[0].real_reference=90.0; |
| 8316 |
if (attribute_flag[1] != 0) |
| 8317 |
{ |
| 8318 |
QueryColorCompliance(argument_list[1].string_reference, |
| 8319 |
AllCompliance,&image->background_color,exception); |
| 8320 |
if ((image->background_color.alpha_trait != UndefinedPixelTrait) && |
| 8321 |
(image->alpha_trait == UndefinedPixelTrait)) |
| 8322 |
(void) SetImageAlpha(image,OpaqueAlpha,exception); |
| 8323 |
} |
| 8324 |
image=RotateImage(image,argument_list[0].real_reference,exception); |
| 8325 |
break; |
| 8326 |
} |
| 8327 |
case 24: /* Sample */ |
| 8328 |
{ |
| 8329 |
if (attribute_flag[0] != 0) |
| 8330 |
flags=ParseRegionGeometry(image,argument_list[0].string_reference, |
| 8331 |
&geometry,exception); |
| 8332 |
if (attribute_flag[1] != 0) |
| 8333 |
geometry.width=(size_t) argument_list[1].integer_reference; |
| 8334 |
if (attribute_flag[2] != 0) |
| 8335 |
geometry.height=(size_t) argument_list[2].integer_reference; |
| 8336 |
image=SampleImage(image,geometry.width,geometry.height,exception); |
| 8337 |
break; |
| 8338 |
} |
| 8339 |
case 25: /* Scale */ |
| 8340 |
{ |
| 8341 |
if (attribute_flag[0] != 0) |
| 8342 |
flags=ParseRegionGeometry(image,argument_list[0].string_reference, |
| 8343 |
&geometry,exception); |
| 8344 |
if (attribute_flag[1] != 0) |
| 8345 |
geometry.width=(size_t) argument_list[1].integer_reference; |
| 8346 |
if (attribute_flag[2] != 0) |
| 8347 |
geometry.height=(size_t) argument_list[2].integer_reference; |
| 8348 |
image=ScaleImage(image,geometry.width,geometry.height,exception); |
| 8349 |
break; |
| 8350 |
} |
| 8351 |
case 26: /* Shade */ |
| 8352 |
{ |
| 8353 |
if (attribute_flag[0] != 0) |
| 8354 |
{ |
| 8355 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 8356 |
&geometry_info); |
| 8357 |
if ((flags & SigmaValue) == 0) |
| 8358 |
geometry_info.sigma=0.0; |
| 8359 |
} |
| 8360 |
if (attribute_flag[1] != 0) |
| 8361 |
geometry_info.rho=argument_list[1].real_reference; |
| 8362 |
if (attribute_flag[2] != 0) |
| 8363 |
geometry_info.sigma=argument_list[2].real_reference; |
| 8364 |
image=ShadeImage(image, |
| 8365 |
argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse, |
| 8366 |
geometry_info.rho,geometry_info.sigma,exception); |
| 8367 |
break; |
| 8368 |
} |
| 8369 |
case 27: /* Sharpen */ |
| 8370 |
{ |
| 8371 |
if (attribute_flag[0] != 0) |
| 8372 |
{ |
| 8373 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 8374 |
&geometry_info); |
| 8375 |
if ((flags & SigmaValue) == 0) |
| 8376 |
geometry_info.sigma=1.0; |
| 8377 |
} |
| 8378 |
if (attribute_flag[1] != 0) |
| 8379 |
geometry_info.rho=argument_list[1].real_reference; |
| 8380 |
if (attribute_flag[2] != 0) |
| 8381 |
geometry_info.sigma=argument_list[2].real_reference; |
| 8382 |
if (attribute_flag[3] != 0) |
| 8383 |
channel=(ChannelType) argument_list[3].integer_reference; |
| 8384 |
channel_mask=SetImageChannelMask(image,channel); |
| 8385 |
image=SharpenImage(image,geometry_info.rho,geometry_info.sigma, |
| 8386 |
exception); |
| 8387 |
if (image != (Image *) NULL) |
| 8388 |
(void) SetImageChannelMask(image,channel_mask); |
| 8389 |
break; |
| 8390 |
} |
| 8391 |
case 28: /* Shear */ |
| 8392 |
{ |
| 8393 |
if (attribute_flag[0] != 0) |
| 8394 |
{ |
| 8395 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 8396 |
&geometry_info); |
| 8397 |
if ((flags & SigmaValue) == 0) |
| 8398 |
geometry_info.sigma=geometry_info.rho; |
| 8399 |
} |
| 8400 |
if (attribute_flag[1] != 0) |
| 8401 |
geometry_info.rho=argument_list[1].real_reference; |
| 8402 |
if (attribute_flag[2] != 0) |
| 8403 |
geometry_info.sigma=argument_list[2].real_reference; |
| 8404 |
if (attribute_flag[3] != 0) |
| 8405 |
QueryColorCompliance(argument_list[3].string_reference, |
| 8406 |
AllCompliance,&image->background_color,exception); |
| 8407 |
if (attribute_flag[4] != 0) |
| 8408 |
QueryColorCompliance(argument_list[4].string_reference, |
| 8409 |
AllCompliance,&image->background_color,exception); |
| 8410 |
image=ShearImage(image,geometry_info.rho,geometry_info.sigma, |
| 8411 |
exception); |
| 8412 |
break; |
| 8413 |
} |
| 8414 |
case 29: /* Spread */ |
| 8415 |
{ |
| 8416 |
PixelInterpolateMethod |
| 8417 |
method; |
| 8418 |
|
| 8419 |
if (attribute_flag[0] == 0) |
| 8420 |
argument_list[0].real_reference=1.0; |
| 8421 |
method=UndefinedInterpolatePixel; |
| 8422 |
if (attribute_flag[1] != 0) |
| 8423 |
method=(PixelInterpolateMethod) argument_list[1].integer_reference; |
| 8424 |
image=SpreadImage(image,method,argument_list[0].real_reference, |
| 8425 |
exception); |
| 8426 |
break; |
| 8427 |
} |
| 8428 |
case 30: /* Swirl */ |
| 8429 |
{ |
| 8430 |
PixelInterpolateMethod |
| 8431 |
method; |
| 8432 |
|
| 8433 |
if (attribute_flag[0] == 0) |
| 8434 |
argument_list[0].real_reference=50.0; |
| 8435 |
method=UndefinedInterpolatePixel; |
| 8436 |
if (attribute_flag[1] != 0) |
| 8437 |
method=(PixelInterpolateMethod) argument_list[1].integer_reference; |
| 8438 |
image=SwirlImage(image,argument_list[0].real_reference, |
| 8439 |
method,exception); |
| 8440 |
break; |
| 8441 |
} |
| 8442 |
case 31: /* Resize */ |
| 8443 |
case 32: /* Zoom */ |
| 8444 |
{ |
| 8445 |
if (attribute_flag[0] != 0) |
| 8446 |
flags=ParseRegionGeometry(image,argument_list[0].string_reference, |
| 8447 |
&geometry,exception); |
| 8448 |
if (attribute_flag[1] != 0) |
| 8449 |
geometry.width=(size_t) argument_list[1].integer_reference; |
| 8450 |
if (attribute_flag[2] != 0) |
| 8451 |
geometry.height=(size_t) argument_list[2].integer_reference; |
| 8452 |
if (attribute_flag[3] == 0) |
| 8453 |
argument_list[3].integer_reference=(ssize_t) UndefinedFilter; |
| 8454 |
if (attribute_flag[4] != 0) |
| 8455 |
SetImageArtifact(image,"filter:support", |
| 8456 |
argument_list[4].string_reference); |
| 8457 |
image=ResizeImage(image,geometry.width,geometry.height, |
| 8458 |
(FilterType) argument_list[3].integer_reference, |
| 8459 |
exception); |
| 8460 |
break; |
| 8461 |
} |
| 8462 |
case 33: /* Annotate */ |
| 8463 |
{ |
| 8464 |
DrawInfo |
| 8465 |
*draw_info; |
| 8466 |
|
| 8467 |
draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL, |
| 8468 |
(DrawInfo *) NULL); |
| 8469 |
if (attribute_flag[0] != 0) |
| 8470 |
{ |
| 8471 |
char |
| 8472 |
*text; |
| 8473 |
|
| 8474 |
text=InterpretImageProperties(info ? info->image_info : |
| 8475 |
(ImageInfo *) NULL,image,argument_list[0].string_reference, |
| 8476 |
exception); |
| 8477 |
(void) CloneString(&draw_info->text,text); |
| 8478 |
text=DestroyString(text); |
| 8479 |
} |
| 8480 |
if (attribute_flag[1] != 0) |
| 8481 |
(void) CloneString(&draw_info->font, |
| 8482 |
argument_list[1].string_reference); |
| 8483 |
if (attribute_flag[2] != 0) |
| 8484 |
draw_info->pointsize=argument_list[2].real_reference; |
| 8485 |
if (attribute_flag[3] != 0) |
| 8486 |
(void) CloneString(&draw_info->density, |
| 8487 |
argument_list[3].string_reference); |
| 8488 |
if (attribute_flag[4] != 0) |
| 8489 |
(void) QueryColorCompliance(argument_list[4].string_reference, |
| 8490 |
AllCompliance,&draw_info->undercolor,exception); |
| 8491 |
if (attribute_flag[5] != 0) |
| 8492 |
{ |
| 8493 |
(void) QueryColorCompliance(argument_list[5].string_reference, |
| 8494 |
AllCompliance,&draw_info->stroke,exception); |
| 8495 |
if (argument_list[5].image_reference != (Image *) NULL) |
| 8496 |
draw_info->stroke_pattern=CloneImage( |
| 8497 |
argument_list[5].image_reference,0,0,MagickTrue,exception); |
| 8498 |
} |
| 8499 |
if (attribute_flag[6] != 0) |
| 8500 |
{ |
| 8501 |
(void) QueryColorCompliance(argument_list[6].string_reference, |
| 8502 |
AllCompliance,&draw_info->fill,exception); |
| 8503 |
if (argument_list[6].image_reference != (Image *) NULL) |
| 8504 |
draw_info->fill_pattern=CloneImage( |
| 8505 |
argument_list[6].image_reference,0,0,MagickTrue,exception); |
| 8506 |
} |
| 8507 |
if (attribute_flag[7] != 0) |
| 8508 |
{ |
| 8509 |
(void) CloneString(&draw_info->geometry, |
| 8510 |
argument_list[7].string_reference); |
| 8511 |
flags=ParsePageGeometry(image,argument_list[7].string_reference, |
| 8512 |
&geometry,exception); |
| 8513 |
if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0)) |
| 8514 |
geometry_info.sigma=geometry_info.xi; |
| 8515 |
} |
| 8516 |
if (attribute_flag[8] != 0) |
| 8517 |
(void) QueryColorCompliance(argument_list[8].string_reference, |
| 8518 |
AllCompliance,&draw_info->fill,exception); |
| 8519 |
if (attribute_flag[11] != 0) |
| 8520 |
draw_info->gravity=(GravityType) |
| 8521 |
argument_list[11].integer_reference; |
| 8522 |
if (attribute_flag[25] != 0) |
| 8523 |
{ |
| 8524 |
AV |
| 8525 |
*av; |
| 8526 |
|
| 8527 |
av=(AV *) argument_list[25].array_reference; |
| 8528 |
if ((av_len(av) != 3) && (av_len(av) != 5)) |
| 8529 |
{ |
| 8530 |
ThrowPerlException(exception,OptionError, |
| 8531 |
"affine matrix must have 4 or 6 elements",PackageName); |
| 8532 |
goto PerlException; |
| 8533 |
} |
| 8534 |
draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0))); |
| 8535 |
draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0))); |
| 8536 |
draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0))); |
| 8537 |
draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0))); |
| 8538 |
if (fabs(draw_info->affine.sx*draw_info->affine.sy- |
| 8539 |
draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon) |
| 8540 |
{ |
| 8541 |
ThrowPerlException(exception,OptionError, |
| 8542 |
"affine matrix is singular",PackageName); |
| 8543 |
goto PerlException; |
| 8544 |
} |
| 8545 |
if (av_len(av) == 5) |
| 8546 |
{ |
| 8547 |
draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0))); |
| 8548 |
draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0))); |
| 8549 |
} |
| 8550 |
} |
| 8551 |
for (j=12; j < 17; j++) |
| 8552 |
{ |
| 8553 |
if (attribute_flag[j] == 0) |
| 8554 |
continue; |
| 8555 |
value=argument_list[j].string_reference; |
| 8556 |
angle=argument_list[j].real_reference; |
| 8557 |
current=draw_info->affine; |
| 8558 |
GetAffineMatrix(&affine); |
| 8559 |
switch (j) |
| 8560 |
{ |
| 8561 |
case 12: |
| 8562 |
{ |
| 8563 |
/* |
| 8564 |
Translate. |
| 8565 |
*/ |
| 8566 |
flags=ParseGeometry(value,&geometry_info); |
| 8567 |
affine.tx=geometry_info.xi; |
| 8568 |
affine.ty=geometry_info.psi; |
| 8569 |
if ((flags & PsiValue) == 0) |
| 8570 |
affine.ty=affine.tx; |
| 8571 |
break; |
| 8572 |
} |
| 8573 |
case 13: |
| 8574 |
{ |
| 8575 |
/* |
| 8576 |
Scale. |
| 8577 |
*/ |
| 8578 |
flags=ParseGeometry(value,&geometry_info); |
| 8579 |
affine.sx=geometry_info.rho; |
| 8580 |
affine.sy=geometry_info.sigma; |
| 8581 |
if ((flags & SigmaValue) == 0) |
| 8582 |
affine.sy=affine.sx; |
| 8583 |
break; |
| 8584 |
} |
| 8585 |
case 14: |
| 8586 |
{ |
| 8587 |
/* |
| 8588 |
Rotate. |
| 8589 |
*/ |
| 8590 |
if (angle == 0.0) |
| 8591 |
break; |
| 8592 |
affine.sx=cos(DegreesToRadians(fmod(angle,360.0))); |
| 8593 |
affine.rx=sin(DegreesToRadians(fmod(angle,360.0))); |
| 8594 |
affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0)))); |
| 8595 |
affine.sy=cos(DegreesToRadians(fmod(angle,360.0))); |
| 8596 |
break; |
| 8597 |
} |
| 8598 |
case 15: |
| 8599 |
{ |
| 8600 |
/* |
| 8601 |
SkewX. |
| 8602 |
*/ |
| 8603 |
affine.ry=tan(DegreesToRadians(fmod(angle,360.0))); |
| 8604 |
break; |
| 8605 |
} |
| 8606 |
case 16: |
| 8607 |
{ |
| 8608 |
/* |
| 8609 |
SkewY. |
| 8610 |
*/ |
| 8611 |
affine.rx=tan(DegreesToRadians(fmod(angle,360.0))); |
| 8612 |
break; |
| 8613 |
} |
| 8614 |
} |
| 8615 |
draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx; |
| 8616 |
draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx; |
| 8617 |
draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy; |
| 8618 |
draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy; |
| 8619 |
draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+ |
| 8620 |
current.tx; |
| 8621 |
draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+ |
| 8622 |
current.ty; |
| 8623 |
} |
| 8624 |
if (attribute_flag[9] == 0) |
| 8625 |
argument_list[9].real_reference=0.0; |
| 8626 |
if (attribute_flag[10] == 0) |
| 8627 |
argument_list[10].real_reference=0.0; |
| 8628 |
if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0)) |
| 8629 |
{ |
| 8630 |
char |
| 8631 |
geometry[MagickPathExtent]; |
| 8632 |
|
| 8633 |
(void) FormatLocaleString(geometry,MagickPathExtent,"%+f%+f", |
| 8634 |
(double) argument_list[9].real_reference+draw_info->affine.tx, |
| 8635 |
(double) argument_list[10].real_reference+draw_info->affine.ty); |
| 8636 |
(void) CloneString(&draw_info->geometry,geometry); |
| 8637 |
} |
| 8638 |
if (attribute_flag[17] != 0) |
| 8639 |
draw_info->stroke_width=(size_t) argument_list[17].real_reference; |
| 8640 |
if (attribute_flag[18] != 0) |
| 8641 |
{ |
| 8642 |
draw_info->text_antialias= |
| 8643 |
argument_list[18].integer_reference != 0 ? MagickTrue : |
| 8644 |
MagickFalse; |
| 8645 |
draw_info->stroke_antialias=draw_info->text_antialias; |
| 8646 |
} |
| 8647 |
if (attribute_flag[19] != 0) |
| 8648 |
(void) CloneString(&draw_info->family, |
| 8649 |
argument_list[19].string_reference); |
| 8650 |
if (attribute_flag[20] != 0) |
| 8651 |
draw_info->style=(StyleType) argument_list[20].integer_reference; |
| 8652 |
if (attribute_flag[21] != 0) |
| 8653 |
draw_info->stretch=(StretchType) |
| 8654 |
argument_list[21].integer_reference; |
| 8655 |
if (attribute_flag[22] != 0) |
| 8656 |
draw_info->weight=(size_t) argument_list[22].integer_reference; |
| 8657 |
if (attribute_flag[23] != 0) |
| 8658 |
draw_info->align=(AlignType) argument_list[23].integer_reference; |
| 8659 |
if (attribute_flag[24] != 0) |
| 8660 |
(void) CloneString(&draw_info->encoding, |
| 8661 |
argument_list[24].string_reference); |
| 8662 |
if (attribute_flag[25] != 0) |
| 8663 |
draw_info->fill_pattern=CloneImage( |
| 8664 |
argument_list[25].image_reference,0,0,MagickTrue,exception); |
| 8665 |
if (attribute_flag[26] != 0) |
| 8666 |
draw_info->fill_pattern=CloneImage( |
| 8667 |
argument_list[26].image_reference,0,0,MagickTrue,exception); |
| 8668 |
if (attribute_flag[27] != 0) |
| 8669 |
draw_info->stroke_pattern=CloneImage( |
| 8670 |
argument_list[27].image_reference,0,0,MagickTrue,exception); |
| 8671 |
if (attribute_flag[29] != 0) |
| 8672 |
draw_info->kerning=argument_list[29].real_reference; |
| 8673 |
if (attribute_flag[30] != 0) |
| 8674 |
draw_info->interline_spacing=argument_list[30].real_reference; |
| 8675 |
if (attribute_flag[31] != 0) |
| 8676 |
draw_info->interword_spacing=argument_list[31].real_reference; |
| 8677 |
if (attribute_flag[32] != 0) |
| 8678 |
draw_info->direction=(DirectionType) |
| 8679 |
argument_list[32].integer_reference; |
| 8680 |
if (attribute_flag[33] != 0) |
| 8681 |
draw_info->decorate=(DecorationType) |
| 8682 |
argument_list[33].integer_reference; |
| 8683 |
if (attribute_flag[34] != 0) |
| 8684 |
draw_info->word_break=(WordBreakType) |
| 8685 |
argument_list[34].integer_reference; |
| 8686 |
(void) AnnotateImage(image,draw_info,exception); |
| 8687 |
draw_info=DestroyDrawInfo(draw_info); |
| 8688 |
break; |
| 8689 |
} |
| 8690 |
case 34: /* ColorFloodfill */ |
| 8691 |
{ |
| 8692 |
DrawInfo |
| 8693 |
*draw_info; |
| 8694 |
|
| 8695 |
MagickBooleanType |
| 8696 |
invert; |
| 8697 |
|
| 8698 |
PixelInfo |
| 8699 |
target; |
| 8700 |
|
| 8701 |
draw_info=CloneDrawInfo(info ? info->image_info : |
| 8702 |
(ImageInfo *) NULL,(DrawInfo *) NULL); |
| 8703 |
if (attribute_flag[0] != 0) |
| 8704 |
flags=ParsePageGeometry(image,argument_list[0].string_reference, |
| 8705 |
&geometry,exception); |
| 8706 |
if (attribute_flag[1] != 0) |
| 8707 |
geometry.x=argument_list[1].integer_reference; |
| 8708 |
if (attribute_flag[2] != 0) |
| 8709 |
geometry.y=argument_list[2].integer_reference; |
| 8710 |
if (attribute_flag[3] != 0) |
| 8711 |
(void) QueryColorCompliance(argument_list[3].string_reference, |
| 8712 |
AllCompliance,&draw_info->fill,exception); |
| 8713 |
(void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod, |
| 8714 |
geometry.x,geometry.y,&target,exception); |
| 8715 |
invert=MagickFalse; |
| 8716 |
if (attribute_flag[4] != 0) |
| 8717 |
{ |
| 8718 |
QueryColorCompliance(argument_list[4].string_reference, |
| 8719 |
AllCompliance,&target,exception); |
| 8720 |
invert=MagickTrue; |
| 8721 |
} |
| 8722 |
if (attribute_flag[5] != 0) |
| 8723 |
image->fuzz=StringToDoubleInterval( |
| 8724 |
argument_list[5].string_reference,(double) QuantumRange+1.0); |
| 8725 |
if (attribute_flag[6] != 0) |
| 8726 |
invert=(MagickBooleanType) argument_list[6].integer_reference; |
| 8727 |
(void) FloodfillPaintImage(image,draw_info,&target,geometry.x, |
| 8728 |
geometry.y,invert,exception); |
| 8729 |
draw_info=DestroyDrawInfo(draw_info); |
| 8730 |
break; |
| 8731 |
} |
| 8732 |
case 35: /* Composite */ |
| 8733 |
{ |
| 8734 |
char |
| 8735 |
composite_geometry[MagickPathExtent]; |
| 8736 |
|
| 8737 |
Image |
| 8738 |
*composite_image, |
| 8739 |
*rotate_image; |
| 8740 |
|
| 8741 |
MagickBooleanType |
| 8742 |
clip_to_self; |
| 8743 |
|
| 8744 |
compose=OverCompositeOp; |
| 8745 |
if (attribute_flag[0] != 0) |
| 8746 |
composite_image=argument_list[0].image_reference; |
| 8747 |
else |
| 8748 |
{ |
| 8749 |
ThrowPerlException(exception,OptionError, |
| 8750 |
"CompositeImageRequired",PackageName); |
| 8751 |
goto PerlException; |
| 8752 |
} |
| 8753 |
/* |
| 8754 |
Parameter Handling used for BOTH normal and tiled composition. |
| 8755 |
*/ |
| 8756 |
if (attribute_flag[1] != 0) /* compose */ |
| 8757 |
compose=(CompositeOperator) argument_list[1].integer_reference; |
| 8758 |
if (attribute_flag[6] != 0) /* opacity */ |
| 8759 |
{ |
| 8760 |
if (compose != DissolveCompositeOp) |
| 8761 |
(void) SetImageAlpha(composite_image,(Quantum) |
| 8762 |
StringToDoubleInterval(argument_list[6].string_reference, |
| 8763 |
(double) QuantumRange+1.0),exception); |
| 8764 |
else |
| 8765 |
{ |
| 8766 |
CacheView |
| 8767 |
*composite_view; |
| 8768 |
|
| 8769 |
double |
| 8770 |
opacity; |
| 8771 |
|
| 8772 |
MagickBooleanType |
| 8773 |
sync; |
| 8774 |
|
| 8775 |
Quantum |
| 8776 |
*q; |
| 8777 |
|
| 8778 |
ssize_t |
| 8779 |
x, |
| 8780 |
y; |
| 8781 |
|
| 8782 |
/* |
| 8783 |
Handle dissolve composite operator (patch by |
| 8784 |
Kevin A. McGrail). |
| 8785 |
*/ |
| 8786 |
(void) CloneString(&image->geometry, |
| 8787 |
argument_list[6].string_reference); |
| 8788 |
opacity=(Quantum) StringToDoubleInterval( |
| 8789 |
argument_list[6].string_reference,(double) QuantumRange+ |
| 8790 |
1.0); |
| 8791 |
if (composite_image->alpha_trait != UndefinedPixelTrait) |
| 8792 |
(void) SetImageAlpha(composite_image,OpaqueAlpha,exception); |
| 8793 |
composite_view=AcquireAuthenticCacheView(composite_image, |
| 8794 |
exception); |
| 8795 |
for (y=0; y < (ssize_t) composite_image->rows ; y++) |
| 8796 |
{ |
| 8797 |
q=GetCacheViewAuthenticPixels(composite_view,0,y, |
| 8798 |
composite_image->columns,1,exception); |
| 8799 |
for (x=0; x < (ssize_t) composite_image->columns; x++) |
| 8800 |
{ |
| 8801 |
if (GetPixelAlpha(image,q) == OpaqueAlpha) |
| 8802 |
SetPixelAlpha(composite_image,ClampToQuantum(opacity), |
| 8803 |
q); |
| 8804 |
q+=GetPixelChannels(composite_image); |
| 8805 |
} |
| 8806 |
sync=SyncCacheViewAuthenticPixels(composite_view,exception); |
| 8807 |
if (sync == MagickFalse) |
| 8808 |
break; |
| 8809 |
} |
| 8810 |
composite_view=DestroyCacheView(composite_view); |
| 8811 |
} |
| 8812 |
} |
| 8813 |
if (attribute_flag[9] != 0) /* "color=>" */ |
| 8814 |
QueryColorCompliance(argument_list[9].string_reference, |
| 8815 |
AllCompliance,&composite_image->background_color,exception); |
| 8816 |
if (attribute_flag[12] != 0) /* "interpolate=>" */ |
| 8817 |
image->interpolate=(PixelInterpolateMethod) |
| 8818 |
argument_list[12].integer_reference; |
| 8819 |
if (attribute_flag[13] != 0) /* "args=>" */ |
| 8820 |
(void) SetImageArtifact(image,"compose:args", |
| 8821 |
argument_list[13].string_reference); |
| 8822 |
if (attribute_flag[14] != 0) /* "blend=>" depreciated */ |
| 8823 |
(void) SetImageArtifact(image,"compose:args", |
| 8824 |
argument_list[14].string_reference); |
| 8825 |
clip_to_self=MagickTrue; |
| 8826 |
if (attribute_flag[15] != 0) |
| 8827 |
clip_to_self=(MagickBooleanType) |
| 8828 |
argument_list[15].integer_reference; |
| 8829 |
/* |
| 8830 |
Tiling Composition (with orthogonal rotate). |
| 8831 |
*/ |
| 8832 |
rotate_image=(Image *) NULL; |
| 8833 |
if (attribute_flag[8] != 0) /* "rotate=>" */ |
| 8834 |
{ |
| 8835 |
/* |
| 8836 |
Rotate image. |
| 8837 |
*/ |
| 8838 |
rotate_image=RotateImage(composite_image, |
| 8839 |
argument_list[8].real_reference,exception); |
| 8840 |
if (rotate_image == (Image *) NULL) |
| 8841 |
break; |
| 8842 |
} |
| 8843 |
if ((attribute_flag[7] != 0) && |
| 8844 |
(argument_list[7].integer_reference != 0)) /* tile */ |
| 8845 |
{ |
| 8846 |
ssize_t |
| 8847 |
x, |
| 8848 |
y; |
| 8849 |
|
| 8850 |
/* |
| 8851 |
Tile the composite image. |
| 8852 |
*/ |
| 8853 |
for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows) |
| 8854 |
for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns) |
| 8855 |
{ |
| 8856 |
if (attribute_flag[8] != 0) /* rotate */ |
| 8857 |
(void) CompositeImage(image,rotate_image,compose, |
| 8858 |
MagickTrue,x,y,exception); |
| 8859 |
else |
| 8860 |
(void) CompositeImage(image,composite_image,compose, |
| 8861 |
MagickTrue,x,y,exception); |
| 8862 |
} |
| 8863 |
if (attribute_flag[8] != 0) /* rotate */ |
| 8864 |
rotate_image=DestroyImage(rotate_image); |
| 8865 |
break; |
| 8866 |
} |
| 8867 |
/* |
| 8868 |
Parameter Handling used ONLY for normal composition. |
| 8869 |
*/ |
| 8870 |
if (attribute_flag[5] != 0) /* gravity */ |
| 8871 |
image->gravity=(GravityType) argument_list[5].integer_reference; |
| 8872 |
if (attribute_flag[2] != 0) /* geometry offset */ |
| 8873 |
{ |
| 8874 |
SetGeometry(image,&geometry); |
| 8875 |
(void) ParseAbsoluteGeometry(argument_list[2].string_reference, |
| 8876 |
&geometry); |
| 8877 |
GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 8878 |
&geometry); |
| 8879 |
} |
| 8880 |
if (attribute_flag[3] != 0) /* x offset */ |
| 8881 |
geometry.x=argument_list[3].integer_reference; |
| 8882 |
if (attribute_flag[4] != 0) /* y offset */ |
| 8883 |
geometry.y=argument_list[4].integer_reference; |
| 8884 |
if (attribute_flag[10] != 0) /* mask */ |
| 8885 |
{ |
| 8886 |
if ((image->compose == DisplaceCompositeOp) || |
| 8887 |
(image->compose == DistortCompositeOp)) |
| 8888 |
{ |
| 8889 |
/* |
| 8890 |
Merge Y displacement into X displacement image. |
| 8891 |
*/ |
| 8892 |
composite_image=CloneImage(composite_image,0,0,MagickTrue, |
| 8893 |
exception); |
| 8894 |
(void) CompositeImage(composite_image, |
| 8895 |
argument_list[10].image_reference,CopyGreenCompositeOp, |
| 8896 |
clip_to_self,0,0,exception); |
| 8897 |
(void) SetImageColorspace(composite_image,sRGBColorspace, |
| 8898 |
exception); |
| 8899 |
} |
| 8900 |
else |
| 8901 |
{ |
| 8902 |
Image |
| 8903 |
*mask_image; |
| 8904 |
|
| 8905 |
/* |
| 8906 |
Set a blending mask for the composition. |
| 8907 |
*/ |
| 8908 |
mask_image=CloneImage(argument_list[10].image_reference,0,0, |
| 8909 |
MagickTrue,exception); |
| 8910 |
(void) CompositeImage(composite_image,mask_image, |
| 8911 |
CopyAlphaCompositeOp,clip_to_self,0,0,exception); |
| 8912 |
mask_image=DestroyImage(mask_image); |
| 8913 |
} |
| 8914 |
} |
| 8915 |
if (attribute_flag[11] != 0) /* channel */ |
| 8916 |
channel=(ChannelType) argument_list[11].integer_reference; |
| 8917 |
/* |
| 8918 |
Composite two images (normal composition). |
| 8919 |
*/ |
| 8920 |
(void) FormatLocaleString(composite_geometry,MagickPathExtent, |
| 8921 |
"%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns, |
| 8922 |
(double) composite_image->rows,(double) geometry.x,(double) |
| 8923 |
geometry.y); |
| 8924 |
flags=ParseGravityGeometry(image,composite_geometry,&geometry, |
| 8925 |
exception); |
| 8926 |
channel_mask=SetImageChannelMask(image,channel); |
| 8927 |
if (attribute_flag[8] == 0) /* no rotate */ |
| 8928 |
CompositeImage(image,composite_image,compose,clip_to_self, |
| 8929 |
geometry.x,geometry.y,exception); |
| 8930 |
else |
| 8931 |
{ |
| 8932 |
/* |
| 8933 |
Position adjust rotated image then composite. |
| 8934 |
*/ |
| 8935 |
geometry.x-=(ssize_t) (rotate_image->columns- |
| 8936 |
composite_image->columns)/2; |
| 8937 |
geometry.y-=(ssize_t) (rotate_image->rows- |
| 8938 |
composite_image->rows)/2; |
| 8939 |
CompositeImage(image,rotate_image,compose,clip_to_self,geometry.x, |
| 8940 |
geometry.y,exception); |
| 8941 |
rotate_image=DestroyImage(rotate_image); |
| 8942 |
} |
| 8943 |
if (attribute_flag[10] != 0) /* mask */ |
| 8944 |
{ |
| 8945 |
if ((image->compose == DisplaceCompositeOp) || |
| 8946 |
(image->compose == DistortCompositeOp)) |
| 8947 |
composite_image=DestroyImage(composite_image); |
| 8948 |
else |
| 8949 |
(void) SetImageMask(image,ReadPixelMask,(Image *) NULL, |
| 8950 |
exception); |
| 8951 |
} |
| 8952 |
(void) SetImageChannelMask(image,channel_mask); |
| 8953 |
break; |
| 8954 |
} |
| 8955 |
case 36: /* Contrast */ |
| 8956 |
{ |
| 8957 |
if (attribute_flag[0] == 0) |
| 8958 |
argument_list[0].integer_reference=0; |
| 8959 |
(void) ContrastImage(image,argument_list[0].integer_reference != 0 ? |
| 8960 |
MagickTrue : MagickFalse,exception); |
| 8961 |
break; |
| 8962 |
} |
| 8963 |
case 37: /* CycleColormap */ |
| 8964 |
{ |
| 8965 |
if (attribute_flag[0] == 0) |
| 8966 |
argument_list[0].integer_reference=6; |
| 8967 |
(void) CycleColormapImage(image,argument_list[0].integer_reference, |
| 8968 |
exception); |
| 8969 |
break; |
| 8970 |
} |
| 8971 |
case 38: /* Draw */ |
| 8972 |
{ |
| 8973 |
DrawInfo |
| 8974 |
*draw_info; |
| 8975 |
|
| 8976 |
draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL, |
| 8977 |
(DrawInfo *) NULL); |
| 8978 |
(void) CloneString(&draw_info->primitive,"point"); |
| 8979 |
if (attribute_flag[0] != 0) |
| 8980 |
{ |
| 8981 |
if (argument_list[0].integer_reference < 0) |
| 8982 |
(void) CloneString(&draw_info->primitive, |
| 8983 |
argument_list[0].string_reference); |
| 8984 |
else |
| 8985 |
(void) CloneString(&draw_info->primitive, |
| 8986 |
CommandOptionToMnemonic(MagickPrimitiveOptions, |
| 8987 |
argument_list[0].integer_reference)); |
| 8988 |
} |
| 8989 |
if (attribute_flag[1] != 0) |
| 8990 |
{ |
| 8991 |
if (LocaleCompare(draw_info->primitive,"path") == 0) |
| 8992 |
{ |
| 8993 |
(void) ConcatenateString(&draw_info->primitive," '"); |
| 8994 |
ConcatenateString(&draw_info->primitive, |
| 8995 |
argument_list[1].string_reference); |
| 8996 |
(void) ConcatenateString(&draw_info->primitive,"'"); |
| 8997 |
} |
| 8998 |
else |
| 8999 |
{ |
| 9000 |
(void) ConcatenateString(&draw_info->primitive," "); |
| 9001 |
ConcatenateString(&draw_info->primitive, |
| 9002 |
argument_list[1].string_reference); |
| 9003 |
} |
| 9004 |
} |
| 9005 |
if (attribute_flag[2] != 0) |
| 9006 |
{ |
| 9007 |
(void) ConcatenateString(&draw_info->primitive," "); |
| 9008 |
(void) ConcatenateString(&draw_info->primitive, |
| 9009 |
CommandOptionToMnemonic(MagickMethodOptions, |
| 9010 |
argument_list[2].integer_reference)); |
| 9011 |
} |
| 9012 |
if (attribute_flag[3] != 0) |
| 9013 |
{ |
| 9014 |
(void) QueryColorCompliance(argument_list[3].string_reference, |
| 9015 |
AllCompliance,&draw_info->stroke,exception); |
| 9016 |
if (argument_list[3].image_reference != (Image *) NULL) |
| 9017 |
draw_info->stroke_pattern=CloneImage( |
| 9018 |
argument_list[3].image_reference,0,0,MagickTrue,exception); |
| 9019 |
} |
| 9020 |
if (attribute_flag[4] != 0) |
| 9021 |
{ |
| 9022 |
(void) QueryColorCompliance(argument_list[4].string_reference, |
| 9023 |
AllCompliance,&draw_info->fill,exception); |
| 9024 |
if (argument_list[4].image_reference != (Image *) NULL) |
| 9025 |
draw_info->fill_pattern=CloneImage( |
| 9026 |
argument_list[4].image_reference,0,0,MagickTrue,exception); |
| 9027 |
} |
| 9028 |
if (attribute_flag[5] != 0) |
| 9029 |
draw_info->stroke_width=(size_t) argument_list[5].real_reference; |
| 9030 |
if (attribute_flag[6] != 0) |
| 9031 |
(void) CloneString(&draw_info->font, |
| 9032 |
argument_list[6].string_reference); |
| 9033 |
if (attribute_flag[7] != 0) |
| 9034 |
(void) QueryColorCompliance(argument_list[7].string_reference, |
| 9035 |
AllCompliance,&draw_info->border_color,exception); |
| 9036 |
if (attribute_flag[8] != 0) |
| 9037 |
draw_info->affine.tx=argument_list[8].real_reference; |
| 9038 |
if (attribute_flag[9] != 0) |
| 9039 |
draw_info->affine.ty=argument_list[9].real_reference; |
| 9040 |
if (attribute_flag[20] != 0) |
| 9041 |
{ |
| 9042 |
AV |
| 9043 |
*av; |
| 9044 |
|
| 9045 |
av=(AV *) argument_list[20].array_reference; |
| 9046 |
if ((av_len(av) != 3) && (av_len(av) != 5)) |
| 9047 |
{ |
| 9048 |
ThrowPerlException(exception,OptionError, |
| 9049 |
"affine matrix must have 4 or 6 elements",PackageName); |
| 9050 |
goto PerlException; |
| 9051 |
} |
| 9052 |
draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0))); |
| 9053 |
draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0))); |
| 9054 |
draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0))); |
| 9055 |
draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0))); |
| 9056 |
if (fabs(draw_info->affine.sx*draw_info->affine.sy- |
| 9057 |
draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon) |
| 9058 |
{ |
| 9059 |
ThrowPerlException(exception,OptionError, |
| 9060 |
"affine matrix is singular",PackageName); |
| 9061 |
goto PerlException; |
| 9062 |
} |
| 9063 |
if (av_len(av) == 5) |
| 9064 |
{ |
| 9065 |
draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0))); |
| 9066 |
draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0))); |
| 9067 |
} |
| 9068 |
} |
| 9069 |
for (j=10; j < 15; j++) |
| 9070 |
{ |
| 9071 |
if (attribute_flag[j] == 0) |
| 9072 |
continue; |
| 9073 |
value=argument_list[j].string_reference; |
| 9074 |
angle=argument_list[j].real_reference; |
| 9075 |
current=draw_info->affine; |
| 9076 |
GetAffineMatrix(&affine); |
| 9077 |
switch (j) |
| 9078 |
{ |
| 9079 |
case 10: |
| 9080 |
{ |
| 9081 |
/* |
| 9082 |
Translate. |
| 9083 |
*/ |
| 9084 |
flags=ParseGeometry(value,&geometry_info); |
| 9085 |
affine.tx=geometry_info.xi; |
| 9086 |
affine.ty=geometry_info.psi; |
| 9087 |
if ((flags & PsiValue) == 0) |
| 9088 |
affine.ty=affine.tx; |
| 9089 |
break; |
| 9090 |
} |
| 9091 |
case 11: |
| 9092 |
{ |
| 9093 |
/* |
| 9094 |
Scale. |
| 9095 |
*/ |
| 9096 |
flags=ParseGeometry(value,&geometry_info); |
| 9097 |
affine.sx=geometry_info.rho; |
| 9098 |
affine.sy=geometry_info.sigma; |
| 9099 |
if ((flags & SigmaValue) == 0) |
| 9100 |
affine.sy=affine.sx; |
| 9101 |
break; |
| 9102 |
} |
| 9103 |
case 12: |
| 9104 |
{ |
| 9105 |
/* |
| 9106 |
Rotate. |
| 9107 |
*/ |
| 9108 |
if (angle == 0.0) |
| 9109 |
break; |
| 9110 |
affine.sx=cos(DegreesToRadians(fmod(angle,360.0))); |
| 9111 |
affine.rx=sin(DegreesToRadians(fmod(angle,360.0))); |
| 9112 |
affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0)))); |
| 9113 |
affine.sy=cos(DegreesToRadians(fmod(angle,360.0))); |
| 9114 |
break; |
| 9115 |
} |
| 9116 |
case 13: |
| 9117 |
{ |
| 9118 |
/* |
| 9119 |
SkewX. |
| 9120 |
*/ |
| 9121 |
affine.ry=tan(DegreesToRadians(fmod(angle,360.0))); |
| 9122 |
break; |
| 9123 |
} |
| 9124 |
case 14: |
| 9125 |
{ |
| 9126 |
/* |
| 9127 |
SkewY. |
| 9128 |
*/ |
| 9129 |
affine.rx=tan(DegreesToRadians(fmod(angle,360.0))); |
| 9130 |
break; |
| 9131 |
} |
| 9132 |
} |
| 9133 |
draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx; |
| 9134 |
draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx; |
| 9135 |
draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy; |
| 9136 |
draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy; |
| 9137 |
draw_info->affine.tx= |
| 9138 |
current.sx*affine.tx+current.ry*affine.ty+current.tx; |
| 9139 |
draw_info->affine.ty= |
| 9140 |
current.rx*affine.tx+current.sy*affine.ty+current.ty; |
| 9141 |
} |
| 9142 |
if (attribute_flag[15] != 0) |
| 9143 |
draw_info->fill_pattern=CloneImage( |
| 9144 |
argument_list[15].image_reference,0,0,MagickTrue,exception); |
| 9145 |
if (attribute_flag[16] != 0) |
| 9146 |
draw_info->pointsize=argument_list[16].real_reference; |
| 9147 |
if (attribute_flag[17] != 0) |
| 9148 |
{ |
| 9149 |
draw_info->stroke_antialias= |
| 9150 |
argument_list[17].integer_reference != 0 ? MagickTrue : |
| 9151 |
MagickFalse; |
| 9152 |
draw_info->text_antialias=draw_info->stroke_antialias; |
| 9153 |
} |
| 9154 |
if (attribute_flag[18] != 0) |
| 9155 |
(void) CloneString(&draw_info->density, |
| 9156 |
argument_list[18].string_reference); |
| 9157 |
if (attribute_flag[19] != 0) |
| 9158 |
draw_info->stroke_width=(size_t) argument_list[19].real_reference; |
| 9159 |
if (attribute_flag[21] != 0) |
| 9160 |
draw_info->dash_offset=argument_list[21].real_reference; |
| 9161 |
if (attribute_flag[22] != 0) |
| 9162 |
{ |
| 9163 |
AV |
| 9164 |
*av; |
| 9165 |
|
| 9166 |
av=(AV *) argument_list[22].array_reference; |
| 9167 |
draw_info->dash_pattern=(double *) AcquireQuantumMemory( |
| 9168 |
(size_t) av_len(av)+2UL,sizeof(*draw_info->dash_pattern)); |
| 9169 |
if (draw_info->dash_pattern != (double *) NULL) |
| 9170 |
{ |
| 9171 |
for (i=0; i <= av_len(av); i++) |
| 9172 |
draw_info->dash_pattern[i]=(double) |
| 9173 |
SvNV(*(av_fetch(av,i,0))); |
| 9174 |
draw_info->dash_pattern[i]=0.0; |
| 9175 |
} |
| 9176 |
} |
| 9177 |
if (attribute_flag[23] != 0) |
| 9178 |
image->interpolate=(PixelInterpolateMethod) |
| 9179 |
argument_list[23].integer_reference; |
| 9180 |
if ((attribute_flag[24] != 0) && |
| 9181 |
(draw_info->fill_pattern != (Image *) NULL)) |
| 9182 |
flags=ParsePageGeometry(draw_info->fill_pattern, |
| 9183 |
argument_list[24].string_reference, |
| 9184 |
&draw_info->fill_pattern->tile_offset,exception); |
| 9185 |
if (attribute_flag[25] != 0) |
| 9186 |
{ |
| 9187 |
(void) ConcatenateString(&draw_info->primitive," '"); |
| 9188 |
(void) ConcatenateString(&draw_info->primitive, |
| 9189 |
argument_list[25].string_reference); |
| 9190 |
(void) ConcatenateString(&draw_info->primitive,"'"); |
| 9191 |
} |
| 9192 |
if (attribute_flag[26] != 0) |
| 9193 |
draw_info->fill_pattern=CloneImage( |
| 9194 |
argument_list[26].image_reference,0,0,MagickTrue,exception); |
| 9195 |
if (attribute_flag[27] != 0) |
| 9196 |
draw_info->stroke_pattern=CloneImage( |
| 9197 |
argument_list[27].image_reference,0,0,MagickTrue,exception); |
| 9198 |
if (attribute_flag[28] != 0) |
| 9199 |
(void) CloneString(&draw_info->primitive, |
| 9200 |
argument_list[28].string_reference); |
| 9201 |
if (attribute_flag[29] != 0) |
| 9202 |
draw_info->kerning=argument_list[29].real_reference; |
| 9203 |
if (attribute_flag[30] != 0) |
| 9204 |
draw_info->interline_spacing=argument_list[30].real_reference; |
| 9205 |
if (attribute_flag[31] != 0) |
| 9206 |
draw_info->interword_spacing=argument_list[31].real_reference; |
| 9207 |
if (attribute_flag[32] != 0) |
| 9208 |
draw_info->direction=(DirectionType) |
| 9209 |
argument_list[32].integer_reference; |
| 9210 |
if (attribute_flag[33] != 0) |
| 9211 |
draw_info->word_break=(WordBreakType) |
| 9212 |
argument_list[33].integer_reference; |
| 9213 |
DrawImage(image,draw_info,exception); |
| 9214 |
draw_info=DestroyDrawInfo(draw_info); |
| 9215 |
break; |
| 9216 |
} |
| 9217 |
case 39: /* Equalize */ |
| 9218 |
{ |
| 9219 |
if (attribute_flag[0] != 0) |
| 9220 |
channel=(ChannelType) argument_list[0].integer_reference; |
| 9221 |
channel_mask=SetImageChannelMask(image,channel); |
| 9222 |
(void) EqualizeImage(image,exception); |
| 9223 |
(void) SetImageChannelMask(image,channel_mask); |
| 9224 |
break; |
| 9225 |
} |
| 9226 |
case 40: /* Gamma */ |
| 9227 |
{ |
| 9228 |
if (attribute_flag[1] != 0) |
| 9229 |
channel=(ChannelType) argument_list[1].integer_reference; |
| 9230 |
if (attribute_flag[2] == 0) |
| 9231 |
argument_list[2].real_reference=1.0; |
| 9232 |
if (attribute_flag[3] == 0) |
| 9233 |
argument_list[3].real_reference=1.0; |
| 9234 |
if (attribute_flag[4] == 0) |
| 9235 |
argument_list[4].real_reference=1.0; |
| 9236 |
if (attribute_flag[0] == 0) |
| 9237 |
{ |
| 9238 |
(void) FormatLocaleString(message,MagickPathExtent, |
| 9239 |
"%.20g,%.20g,%.20g",(double) argument_list[2].real_reference, |
| 9240 |
(double) argument_list[3].real_reference, |
| 9241 |
(double) argument_list[4].real_reference); |
| 9242 |
argument_list[0].string_reference=message; |
| 9243 |
} |
| 9244 |
(void) GammaImage(image,StringToDouble( |
| 9245 |
argument_list[0].string_reference,(char **) NULL),exception); |
| 9246 |
break; |
| 9247 |
} |
| 9248 |
case 41: /* Map */ |
| 9249 |
{ |
| 9250 |
QuantizeInfo |
| 9251 |
*quantize_info; |
| 9252 |
|
| 9253 |
if (attribute_flag[0] == 0) |
| 9254 |
{ |
| 9255 |
ThrowPerlException(exception,OptionError,"MapImageRequired", |
| 9256 |
PackageName); |
| 9257 |
goto PerlException; |
| 9258 |
} |
| 9259 |
quantize_info=AcquireQuantizeInfo(info->image_info); |
| 9260 |
if (attribute_flag[1] != 0) |
| 9261 |
quantize_info->dither_method=(DitherMethod) |
| 9262 |
argument_list[1].integer_reference; |
| 9263 |
(void) RemapImages(quantize_info,image, |
| 9264 |
argument_list[0].image_reference,exception); |
| 9265 |
quantize_info=DestroyQuantizeInfo(quantize_info); |
| 9266 |
break; |
| 9267 |
} |
| 9268 |
case 42: /* MatteFloodfill */ |
| 9269 |
{ |
| 9270 |
DrawInfo |
| 9271 |
*draw_info; |
| 9272 |
|
| 9273 |
MagickBooleanType |
| 9274 |
invert; |
| 9275 |
|
| 9276 |
PixelInfo |
| 9277 |
target; |
| 9278 |
|
| 9279 |
draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL, |
| 9280 |
(DrawInfo *) NULL); |
| 9281 |
if (attribute_flag[0] != 0) |
| 9282 |
flags=ParsePageGeometry(image,argument_list[0].string_reference, |
| 9283 |
&geometry,exception); |
| 9284 |
if (attribute_flag[1] != 0) |
| 9285 |
geometry.x=argument_list[1].integer_reference; |
| 9286 |
if (attribute_flag[2] != 0) |
| 9287 |
geometry.y=argument_list[2].integer_reference; |
| 9288 |
if (image->alpha_trait == UndefinedPixelTrait) |
| 9289 |
(void) SetImageAlpha(image,OpaqueAlpha,exception); |
| 9290 |
(void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod, |
| 9291 |
geometry.x,geometry.y,&target,exception); |
| 9292 |
if (attribute_flag[4] != 0) |
| 9293 |
QueryColorCompliance(argument_list[4].string_reference, |
| 9294 |
AllCompliance,&target,exception); |
| 9295 |
if (attribute_flag[3] != 0) |
| 9296 |
target.alpha=StringToDoubleInterval( |
| 9297 |
argument_list[3].string_reference,(double) (double) QuantumRange+ |
| 9298 |
1.0); |
| 9299 |
if (attribute_flag[5] != 0) |
| 9300 |
image->fuzz=StringToDoubleInterval( |
| 9301 |
argument_list[5].string_reference,(double) QuantumRange+1.0); |
| 9302 |
invert=MagickFalse; |
| 9303 |
if (attribute_flag[6] != 0) |
| 9304 |
invert=(MagickBooleanType) argument_list[6].integer_reference; |
| 9305 |
channel_mask=SetImageChannelMask(image,AlphaChannel); |
| 9306 |
(void) FloodfillPaintImage(image,draw_info,&target,geometry.x, |
| 9307 |
geometry.y,invert,exception); |
| 9308 |
(void) SetImageChannelMask(image,channel_mask); |
| 9309 |
draw_info=DestroyDrawInfo(draw_info); |
| 9310 |
break; |
| 9311 |
} |
| 9312 |
case 43: /* Modulate */ |
| 9313 |
{ |
| 9314 |
char |
| 9315 |
modulate[MagickPathExtent]; |
| 9316 |
|
| 9317 |
geometry_info.rho=100.0; |
| 9318 |
geometry_info.sigma=100.0; |
| 9319 |
geometry_info.xi=100.0; |
| 9320 |
if (attribute_flag[0] != 0) |
| 9321 |
(void)ParseGeometry(argument_list[0].string_reference, |
| 9322 |
&geometry_info); |
| 9323 |
if (attribute_flag[1] != 0) |
| 9324 |
geometry_info.xi=argument_list[1].real_reference; |
| 9325 |
if (attribute_flag[2] != 0) |
| 9326 |
geometry_info.sigma=argument_list[2].real_reference; |
| 9327 |
if (attribute_flag[3] != 0) |
| 9328 |
{ |
| 9329 |
geometry_info.sigma=argument_list[3].real_reference; |
| 9330 |
SetImageArtifact(image,"modulate:colorspace","HWB"); |
| 9331 |
} |
| 9332 |
if (attribute_flag[4] != 0) |
| 9333 |
{ |
| 9334 |
geometry_info.rho=argument_list[4].real_reference; |
| 9335 |
SetImageArtifact(image,"modulate:colorspace","HSB"); |
| 9336 |
} |
| 9337 |
if (attribute_flag[5] != 0) |
| 9338 |
{ |
| 9339 |
geometry_info.sigma=argument_list[5].real_reference; |
| 9340 |
SetImageArtifact(image,"modulate:colorspace","HSL"); |
| 9341 |
} |
| 9342 |
if (attribute_flag[6] != 0) |
| 9343 |
{ |
| 9344 |
geometry_info.rho=argument_list[6].real_reference; |
| 9345 |
SetImageArtifact(image,"modulate:colorspace","HWB"); |
| 9346 |
} |
| 9347 |
(void) FormatLocaleString(modulate,MagickPathExtent, |
| 9348 |
"%.20g,%.20g,%.20g",geometry_info.rho,geometry_info.sigma, |
| 9349 |
geometry_info.xi); |
| 9350 |
(void) ModulateImage(image,modulate,exception); |
| 9351 |
break; |
| 9352 |
} |
| 9353 |
case 44: /* Negate */ |
| 9354 |
{ |
| 9355 |
if (attribute_flag[0] == 0) |
| 9356 |
argument_list[0].integer_reference=0; |
| 9357 |
if (attribute_flag[1] != 0) |
| 9358 |
channel=(ChannelType) argument_list[1].integer_reference; |
| 9359 |
channel_mask=SetImageChannelMask(image,channel); |
| 9360 |
(void) NegateImage(image,argument_list[0].integer_reference != 0 ? |
| 9361 |
MagickTrue : MagickFalse,exception); |
| 9362 |
(void) SetImageChannelMask(image,channel_mask); |
| 9363 |
break; |
| 9364 |
} |
| 9365 |
case 45: /* Normalize */ |
| 9366 |
{ |
| 9367 |
if (attribute_flag[0] != 0) |
| 9368 |
channel=(ChannelType) argument_list[0].integer_reference; |
| 9369 |
channel_mask=SetImageChannelMask(image,channel); |
| 9370 |
NormalizeImage(image,exception); |
| 9371 |
(void) SetImageChannelMask(image,channel_mask); |
| 9372 |
break; |
| 9373 |
} |
| 9374 |
case 46: /* NumberColors */ |
| 9375 |
break; |
| 9376 |
case 47: /* Opaque */ |
| 9377 |
{ |
| 9378 |
MagickBooleanType |
| 9379 |
invert; |
| 9380 |
|
| 9381 |
PixelInfo |
| 9382 |
fill_color, |
| 9383 |
target; |
| 9384 |
|
| 9385 |
(void) QueryColorCompliance("none",AllCompliance,&target, |
| 9386 |
exception); |
| 9387 |
(void) QueryColorCompliance("none",AllCompliance,&fill_color, |
| 9388 |
exception); |
| 9389 |
if (attribute_flag[0] != 0) |
| 9390 |
(void) QueryColorCompliance(argument_list[0].string_reference, |
| 9391 |
AllCompliance,&target,exception); |
| 9392 |
if (attribute_flag[1] != 0) |
| 9393 |
(void) QueryColorCompliance(argument_list[1].string_reference, |
| 9394 |
AllCompliance,&fill_color,exception); |
| 9395 |
if (attribute_flag[2] != 0) |
| 9396 |
image->fuzz=StringToDoubleInterval( |
| 9397 |
argument_list[2].string_reference,(double) QuantumRange+1.0); |
| 9398 |
if (attribute_flag[3] != 0) |
| 9399 |
channel=(ChannelType) argument_list[3].integer_reference; |
| 9400 |
invert=MagickFalse; |
| 9401 |
if (attribute_flag[4] != 0) |
| 9402 |
invert=(MagickBooleanType) argument_list[4].integer_reference; |
| 9403 |
channel_mask=SetImageChannelMask(image,channel); |
| 9404 |
(void) OpaquePaintImage(image,&target,&fill_color,invert,exception); |
| 9405 |
(void) SetImageChannelMask(image,channel_mask); |
| 9406 |
break; |
| 9407 |
} |
| 9408 |
case 48: /* Quantize */ |
| 9409 |
{ |
| 9410 |
QuantizeInfo |
| 9411 |
*quantize_info; |
| 9412 |
|
| 9413 |
quantize_info=AcquireQuantizeInfo(info->image_info); |
| 9414 |
if (attribute_flag[0] != 0) |
| 9415 |
quantize_info->number_colors=(size_t) |
| 9416 |
argument_list[0].integer_reference; |
| 9417 |
if (attribute_flag[1] != 0) |
| 9418 |
quantize_info->tree_depth=(size_t) |
| 9419 |
argument_list[1].integer_reference; |
| 9420 |
if (attribute_flag[2] != 0) |
| 9421 |
quantize_info->colorspace=(ColorspaceType) |
| 9422 |
argument_list[2].integer_reference; |
| 9423 |
if (attribute_flag[3] != 0) |
| 9424 |
quantize_info->dither_method=(DitherMethod) |
| 9425 |
argument_list[3].integer_reference; |
| 9426 |
if (attribute_flag[4] != 0) |
| 9427 |
quantize_info->measure_error= |
| 9428 |
argument_list[4].integer_reference != 0 ? MagickTrue : |
| 9429 |
MagickFalse; |
| 9430 |
if (attribute_flag[6] != 0) |
| 9431 |
(void) QueryColorCompliance(argument_list[6].string_reference, |
| 9432 |
AllCompliance,&image->transparent_color,exception); |
| 9433 |
if (attribute_flag[7] != 0) |
| 9434 |
quantize_info->dither_method=(DitherMethod) |
| 9435 |
argument_list[7].integer_reference; |
| 9436 |
if (attribute_flag[5] && argument_list[5].integer_reference) |
| 9437 |
(void) QuantizeImages(quantize_info,image,exception); |
| 9438 |
else |
| 9439 |
if ((image->storage_class == DirectClass) || |
| 9440 |
(image->colors > quantize_info->number_colors) || |
| 9441 |
(quantize_info->colorspace == GRAYColorspace)) |
| 9442 |
(void) QuantizeImage(quantize_info,image,exception); |
| 9443 |
else |
| 9444 |
CompressImageColormap(image,exception); |
| 9445 |
quantize_info=DestroyQuantizeInfo(quantize_info); |
| 9446 |
break; |
| 9447 |
} |
| 9448 |
case 49: /* Raise */ |
| 9449 |
{ |
| 9450 |
if (attribute_flag[0] != 0) |
| 9451 |
flags=ParsePageGeometry(image,argument_list[0].string_reference, |
| 9452 |
&geometry,exception); |
| 9453 |
if (attribute_flag[1] != 0) |
| 9454 |
geometry.width=(size_t) argument_list[1].integer_reference; |
| 9455 |
if (attribute_flag[2] != 0) |
| 9456 |
geometry.height=(size_t) argument_list[2].integer_reference; |
| 9457 |
if (attribute_flag[3] == 0) |
| 9458 |
argument_list[3].integer_reference=1; |
| 9459 |
(void) RaiseImage(image,&geometry, |
| 9460 |
argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse, |
| 9461 |
exception); |
| 9462 |
break; |
| 9463 |
} |
| 9464 |
case 50: /* Segment */ |
| 9465 |
{ |
| 9466 |
ColorspaceType |
| 9467 |
colorspace; |
| 9468 |
|
| 9469 |
double |
| 9470 |
cluster_threshold, |
| 9471 |
smoothing_threshold; |
| 9472 |
|
| 9473 |
MagickBooleanType |
| 9474 |
verbose; |
| 9475 |
|
| 9476 |
cluster_threshold=1.0; |
| 9477 |
smoothing_threshold=1.5; |
| 9478 |
colorspace=sRGBColorspace; |
| 9479 |
verbose=MagickFalse; |
| 9480 |
if (attribute_flag[0] != 0) |
| 9481 |
{ |
| 9482 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 9483 |
&geometry_info); |
| 9484 |
cluster_threshold=geometry_info.rho; |
| 9485 |
if (flags & SigmaValue) |
| 9486 |
smoothing_threshold=geometry_info.sigma; |
| 9487 |
} |
| 9488 |
if (attribute_flag[1] != 0) |
| 9489 |
cluster_threshold=argument_list[1].real_reference; |
| 9490 |
if (attribute_flag[2] != 0) |
| 9491 |
smoothing_threshold=argument_list[2].real_reference; |
| 9492 |
if (attribute_flag[3] != 0) |
| 9493 |
colorspace=(ColorspaceType) argument_list[3].integer_reference; |
| 9494 |
if (attribute_flag[4] != 0) |
| 9495 |
verbose=argument_list[4].integer_reference != 0 ? MagickTrue : |
| 9496 |
MagickFalse; |
| 9497 |
(void) SegmentImage(image,colorspace,verbose,cluster_threshold, |
| 9498 |
smoothing_threshold,exception); |
| 9499 |
break; |
| 9500 |
} |
| 9501 |
case 51: /* Signature */ |
| 9502 |
{ |
| 9503 |
(void) SignatureImage(image,exception); |
| 9504 |
break; |
| 9505 |
} |
| 9506 |
case 52: /* Solarize */ |
| 9507 |
{ |
| 9508 |
geometry_info.rho=QuantumRange/2.0; |
| 9509 |
if (attribute_flag[0] != 0) |
| 9510 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 9511 |
&geometry_info); |
| 9512 |
if (attribute_flag[1] != 0) |
| 9513 |
geometry_info.rho=StringToDoubleInterval( |
| 9514 |
argument_list[1].string_reference,(double) QuantumRange+1.0); |
| 9515 |
(void) SolarizeImage(image,geometry_info.rho,exception); |
| 9516 |
break; |
| 9517 |
} |
| 9518 |
case 53: /* Sync */ |
| 9519 |
{ |
| 9520 |
(void) SyncImage(image,exception); |
| 9521 |
break; |
| 9522 |
} |
| 9523 |
case 54: /* Texture */ |
| 9524 |
{ |
| 9525 |
if (attribute_flag[0] == 0) |
| 9526 |
break; |
| 9527 |
TextureImage(image,argument_list[0].image_reference,exception); |
| 9528 |
break; |
| 9529 |
} |
| 9530 |
case 55: /* Evaluate */ |
| 9531 |
{ |
| 9532 |
MagickEvaluateOperator |
| 9533 |
op; |
| 9534 |
|
| 9535 |
op=SetEvaluateOperator; |
| 9536 |
if (attribute_flag[0] == MagickFalse) |
| 9537 |
argument_list[0].real_reference=0.0; |
| 9538 |
if (attribute_flag[1] != MagickFalse) |
| 9539 |
op=(MagickEvaluateOperator) argument_list[1].integer_reference; |
| 9540 |
if (attribute_flag[2] != MagickFalse) |
| 9541 |
channel=(ChannelType) argument_list[2].integer_reference; |
| 9542 |
channel_mask=SetImageChannelMask(image,channel); |
| 9543 |
(void) EvaluateImage(image,op,argument_list[0].real_reference, |
| 9544 |
exception); |
| 9545 |
(void) SetImageChannelMask(image,channel_mask); |
| 9546 |
break; |
| 9547 |
} |
| 9548 |
case 56: /* Transparent */ |
| 9549 |
{ |
| 9550 |
double |
| 9551 |
opacity; |
| 9552 |
|
| 9553 |
MagickBooleanType |
| 9554 |
invert; |
| 9555 |
|
| 9556 |
PixelInfo |
| 9557 |
target; |
| 9558 |
|
| 9559 |
(void) QueryColorCompliance("none",AllCompliance,&target, |
| 9560 |
exception); |
| 9561 |
if (attribute_flag[0] != 0) |
| 9562 |
(void) QueryColorCompliance(argument_list[0].string_reference, |
| 9563 |
AllCompliance,&target,exception); |
| 9564 |
opacity=TransparentAlpha; |
| 9565 |
if (attribute_flag[1] != 0) |
| 9566 |
opacity=StringToDoubleInterval(argument_list[1].string_reference, |
| 9567 |
(double) QuantumRange+1.0); |
| 9568 |
if (attribute_flag[2] != 0) |
| 9569 |
image->fuzz=StringToDoubleInterval( |
| 9570 |
argument_list[2].string_reference,(double) QuantumRange+1.0); |
| 9571 |
if (attribute_flag[3] == 0) |
| 9572 |
argument_list[3].integer_reference=0; |
| 9573 |
invert=MagickFalse; |
| 9574 |
if (attribute_flag[3] != 0) |
| 9575 |
invert=(MagickBooleanType) argument_list[3].integer_reference; |
| 9576 |
(void) TransparentPaintImage(image,&target,ClampToQuantum(opacity), |
| 9577 |
invert,exception); |
| 9578 |
break; |
| 9579 |
} |
| 9580 |
case 57: /* Threshold */ |
| 9581 |
{ |
| 9582 |
double |
| 9583 |
threshold; |
| 9584 |
|
| 9585 |
if (attribute_flag[0] == 0) |
| 9586 |
argument_list[0].string_reference="50%"; |
| 9587 |
if (attribute_flag[1] != 0) |
| 9588 |
channel=(ChannelType) argument_list[1].integer_reference; |
| 9589 |
threshold=StringToDoubleInterval(argument_list[0].string_reference, |
| 9590 |
(double) QuantumRange+1.0); |
| 9591 |
channel_mask=SetImageChannelMask(image,channel); |
| 9592 |
(void) BilevelImage(image,threshold,exception); |
| 9593 |
(void) SetImageChannelMask(image,channel_mask); |
| 9594 |
break; |
| 9595 |
} |
| 9596 |
case 58: /* Charcoal */ |
| 9597 |
{ |
| 9598 |
if (attribute_flag[0] != 0) |
| 9599 |
{ |
| 9600 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 9601 |
&geometry_info); |
| 9602 |
if ((flags & SigmaValue) == 0) |
| 9603 |
geometry_info.sigma=1.0; |
| 9604 |
} |
| 9605 |
if (attribute_flag[1] != 0) |
| 9606 |
geometry_info.rho=argument_list[1].real_reference; |
| 9607 |
if (attribute_flag[2] != 0) |
| 9608 |
geometry_info.sigma=argument_list[2].real_reference; |
| 9609 |
image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma, |
| 9610 |
exception); |
| 9611 |
break; |
| 9612 |
} |
| 9613 |
case 59: /* Trim */ |
| 9614 |
{ |
| 9615 |
if (attribute_flag[0] != 0) |
| 9616 |
image->fuzz=StringToDoubleInterval( |
| 9617 |
argument_list[0].string_reference,(double) QuantumRange+1.0); |
| 9618 |
image=TrimImage(image,exception); |
| 9619 |
break; |
| 9620 |
} |
| 9621 |
case 60: /* Wave */ |
| 9622 |
{ |
| 9623 |
PixelInterpolateMethod |
| 9624 |
method; |
| 9625 |
|
| 9626 |
if (attribute_flag[0] != 0) |
| 9627 |
{ |
| 9628 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 9629 |
&geometry_info); |
| 9630 |
if ((flags & SigmaValue) == 0) |
| 9631 |
geometry_info.sigma=1.0; |
| 9632 |
} |
| 9633 |
if (attribute_flag[1] != 0) |
| 9634 |
geometry_info.rho=argument_list[1].real_reference; |
| 9635 |
if (attribute_flag[2] != 0) |
| 9636 |
geometry_info.sigma=argument_list[2].real_reference; |
| 9637 |
method=UndefinedInterpolatePixel; |
| 9638 |
if (attribute_flag[3] != 0) |
| 9639 |
method=(PixelInterpolateMethod) argument_list[3].integer_reference; |
| 9640 |
image=WaveImage(image,geometry_info.rho,geometry_info.sigma, |
| 9641 |
method,exception); |
| 9642 |
break; |
| 9643 |
} |
| 9644 |
case 61: /* Separate */ |
| 9645 |
{ |
| 9646 |
if (attribute_flag[0] != 0) |
| 9647 |
channel=(ChannelType) argument_list[0].integer_reference; |
| 9648 |
image=SeparateImage(image,channel,exception); |
| 9649 |
break; |
| 9650 |
} |
| 9651 |
case 63: /* Stereo */ |
| 9652 |
{ |
| 9653 |
if (attribute_flag[0] == 0) |
| 9654 |
{ |
| 9655 |
ThrowPerlException(exception,OptionError,"StereoImageRequired", |
| 9656 |
PackageName); |
| 9657 |
goto PerlException; |
| 9658 |
} |
| 9659 |
if (attribute_flag[1] != 0) |
| 9660 |
geometry.x=argument_list[1].integer_reference; |
| 9661 |
if (attribute_flag[2] != 0) |
| 9662 |
geometry.y=argument_list[2].integer_reference; |
| 9663 |
image=StereoAnaglyphImage(image,argument_list[0].image_reference, |
| 9664 |
geometry.x,geometry.y,exception); |
| 9665 |
break; |
| 9666 |
} |
| 9667 |
case 64: /* Stegano */ |
| 9668 |
{ |
| 9669 |
if (attribute_flag[0] == 0) |
| 9670 |
{ |
| 9671 |
ThrowPerlException(exception,OptionError,"SteganoImageRequired", |
| 9672 |
PackageName); |
| 9673 |
goto PerlException; |
| 9674 |
} |
| 9675 |
if (attribute_flag[1] == 0) |
| 9676 |
argument_list[1].integer_reference=0; |
| 9677 |
image->offset=argument_list[1].integer_reference; |
| 9678 |
image=SteganoImage(image,argument_list[0].image_reference,exception); |
| 9679 |
break; |
| 9680 |
} |
| 9681 |
case 65: /* Deconstruct */ |
| 9682 |
{ |
| 9683 |
image=CompareImagesLayers(image,CompareAnyLayer,exception); |
| 9684 |
break; |
| 9685 |
} |
| 9686 |
case 66: /* GaussianBlur */ |
| 9687 |
{ |
| 9688 |
if (attribute_flag[0] != 0) |
| 9689 |
{ |
| 9690 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 9691 |
&geometry_info); |
| 9692 |
if ((flags & SigmaValue) == 0) |
| 9693 |
geometry_info.sigma=1.0; |
| 9694 |
} |
| 9695 |
if (attribute_flag[1] != 0) |
| 9696 |
geometry_info.rho=argument_list[1].real_reference; |
| 9697 |
if (attribute_flag[2] != 0) |
| 9698 |
geometry_info.sigma=argument_list[2].real_reference; |
| 9699 |
if (attribute_flag[3] != 0) |
| 9700 |
channel=(ChannelType) argument_list[3].integer_reference; |
| 9701 |
channel_mask=SetImageChannelMask(image,channel); |
| 9702 |
image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma, |
| 9703 |
exception); |
| 9704 |
if (image != (Image *) NULL) |
| 9705 |
(void) SetImageChannelMask(image,channel_mask); |
| 9706 |
break; |
| 9707 |
} |
| 9708 |
case 67: /* Convolve */ |
| 9709 |
{ |
| 9710 |
KernelInfo |
| 9711 |
*kernel; |
| 9712 |
|
| 9713 |
kernel=(KernelInfo *) NULL; |
| 9714 |
if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0)) |
| 9715 |
break; |
| 9716 |
if (attribute_flag[0] != 0) |
| 9717 |
{ |
| 9718 |
AV |
| 9719 |
*av; |
| 9720 |
|
| 9721 |
size_t |
| 9722 |
order; |
| 9723 |
|
| 9724 |
kernel=AcquireKernelInfo((const char *) NULL,exception); |
| 9725 |
if (kernel == (KernelInfo *) NULL) |
| 9726 |
break; |
| 9727 |
av=(AV *) argument_list[0].array_reference; |
| 9728 |
order=(size_t) sqrt(av_len(av)+1); |
| 9729 |
kernel->width=order; |
| 9730 |
kernel->height=order; |
| 9731 |
kernel->values=(MagickRealType *) AcquireAlignedMemory(order, |
| 9732 |
order*sizeof(*kernel->values)); |
| 9733 |
if (kernel->values == (MagickRealType *) NULL) |
| 9734 |
{ |
| 9735 |
kernel=DestroyKernelInfo(kernel); |
| 9736 |
ThrowPerlException(exception,ResourceLimitFatalError, |
| 9737 |
"MemoryAllocationFailed",PackageName); |
| 9738 |
goto PerlException; |
| 9739 |
} |
| 9740 |
for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++) |
| 9741 |
kernel->values[j]=(MagickRealType) SvNV(*(av_fetch(av,j,0))); |
| 9742 |
for ( ; j < (ssize_t) (order*order); j++) |
| 9743 |
kernel->values[j]=0.0; |
| 9744 |
} |
| 9745 |
if (attribute_flag[1] != 0) |
| 9746 |
channel=(ChannelType) argument_list[1].integer_reference; |
| 9747 |
if (attribute_flag[2] != 0) |
| 9748 |
SetImageArtifact(image,"convolve:bias", |
| 9749 |
argument_list[2].string_reference); |
| 9750 |
if (attribute_flag[3] != 0) |
| 9751 |
{ |
| 9752 |
kernel=AcquireKernelInfo(argument_list[3].string_reference, |
| 9753 |
exception); |
| 9754 |
if (kernel == (KernelInfo *) NULL) |
| 9755 |
break; |
| 9756 |
} |
| 9757 |
channel_mask=SetImageChannelMask(image,channel); |
| 9758 |
image=ConvolveImage(image,kernel,exception); |
| 9759 |
if (image != (Image *) NULL) |
| 9760 |
(void) SetImageChannelMask(image,channel_mask); |
| 9761 |
kernel=DestroyKernelInfo(kernel); |
| 9762 |
break; |
| 9763 |
} |
| 9764 |
case 68: /* Profile */ |
| 9765 |
{ |
| 9766 |
const char |
| 9767 |
*name; |
| 9768 |
|
| 9769 |
Image |
| 9770 |
*profile_image; |
| 9771 |
|
| 9772 |
ImageInfo |
| 9773 |
*profile_info; |
| 9774 |
|
| 9775 |
StringInfo |
| 9776 |
*profile; |
| 9777 |
|
| 9778 |
name="*"; |
| 9779 |
if (attribute_flag[0] != 0) |
| 9780 |
name=argument_list[0].string_reference; |
| 9781 |
if (attribute_flag[2] != 0) |
| 9782 |
image->rendering_intent=(RenderingIntent) |
| 9783 |
argument_list[2].integer_reference; |
| 9784 |
if (attribute_flag[3] != 0) |
| 9785 |
image->black_point_compensation= |
| 9786 |
argument_list[3].integer_reference != 0 ? MagickTrue : |
| 9787 |
MagickFalse; |
| 9788 |
if (attribute_flag[1] != 0) |
| 9789 |
{ |
| 9790 |
if (argument_list[1].length == 0) |
| 9791 |
{ |
| 9792 |
/* |
| 9793 |
Remove a profile from the image. |
| 9794 |
*/ |
| 9795 |
(void) ProfileImage(image,name,(const unsigned char *) NULL,0, |
| 9796 |
exception); |
| 9797 |
break; |
| 9798 |
} |
| 9799 |
/* |
| 9800 |
Associate user supplied profile with the image. |
| 9801 |
*/ |
| 9802 |
profile=AcquireStringInfo(argument_list[1].length); |
| 9803 |
SetStringInfoDatum(profile,(const unsigned char *) |
| 9804 |
argument_list[1].string_reference); |
| 9805 |
(void) ProfileImage(image,name,GetStringInfoDatum(profile), |
| 9806 |
(size_t) GetStringInfoLength(profile),exception); |
| 9807 |
profile=DestroyStringInfo(profile); |
| 9808 |
break; |
| 9809 |
} |
| 9810 |
/* |
| 9811 |
Associate a profile with the image. |
| 9812 |
*/ |
| 9813 |
profile_info=CloneImageInfo(info ? info->image_info : (ImageInfo *) |
| 9814 |
NULL); |
| 9815 |
profile_image=ReadImages(profile_info,name,exception); |
| 9816 |
if (profile_image == (Image *) NULL) |
| 9817 |
break; |
| 9818 |
ResetImageProfileIterator(profile_image); |
| 9819 |
name=GetNextImageProfile(profile_image); |
| 9820 |
while (name != (const char *) NULL) |
| 9821 |
{ |
| 9822 |
const StringInfo |
| 9823 |
*profile; |
| 9824 |
|
| 9825 |
profile=GetImageProfile(profile_image,name); |
| 9826 |
if (profile != (const StringInfo *) NULL) |
| 9827 |
(void) ProfileImage(image,name,GetStringInfoDatum(profile), |
| 9828 |
(size_t) GetStringInfoLength(profile),exception); |
| 9829 |
name=GetNextImageProfile(profile_image); |
| 9830 |
} |
| 9831 |
profile_image=DestroyImage(profile_image); |
| 9832 |
profile_info=DestroyImageInfo(profile_info); |
| 9833 |
break; |
| 9834 |
} |
| 9835 |
case 69: /* UnsharpMask */ |
| 9836 |
{ |
| 9837 |
if (attribute_flag[0] != 0) |
| 9838 |
{ |
| 9839 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 9840 |
&geometry_info); |
| 9841 |
if ((flags & SigmaValue) == 0) |
| 9842 |
geometry_info.sigma=1.0; |
| 9843 |
if ((flags & XiValue) == 0) |
| 9844 |
geometry_info.xi=1.0; |
| 9845 |
if ((flags & PsiValue) == 0) |
| 9846 |
geometry_info.psi=0.5; |
| 9847 |
} |
| 9848 |
if (attribute_flag[1] != 0) |
| 9849 |
geometry_info.rho=argument_list[1].real_reference; |
| 9850 |
if (attribute_flag[2] != 0) |
| 9851 |
geometry_info.sigma=argument_list[2].real_reference; |
| 9852 |
if (attribute_flag[3] != 0) |
| 9853 |
geometry_info.xi=argument_list[3].real_reference; |
| 9854 |
if (attribute_flag[4] != 0) |
| 9855 |
geometry_info.psi=argument_list[4].real_reference; |
| 9856 |
if (attribute_flag[5] != 0) |
| 9857 |
channel=(ChannelType) argument_list[5].integer_reference; |
| 9858 |
channel_mask=SetImageChannelMask(image,channel); |
| 9859 |
image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma, |
| 9860 |
geometry_info.xi,geometry_info.psi,exception); |
| 9861 |
if (image != (Image *) NULL) |
| 9862 |
(void) SetImageChannelMask(image,channel_mask); |
| 9863 |
break; |
| 9864 |
} |
| 9865 |
case 70: /* MotionBlur */ |
| 9866 |
{ |
| 9867 |
if (attribute_flag[0] != 0) |
| 9868 |
{ |
| 9869 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 9870 |
&geometry_info); |
| 9871 |
if ((flags & SigmaValue) == 0) |
| 9872 |
geometry_info.sigma=1.0; |
| 9873 |
if ((flags & XiValue) == 0) |
| 9874 |
geometry_info.xi=1.0; |
| 9875 |
} |
| 9876 |
if (attribute_flag[1] != 0) |
| 9877 |
geometry_info.rho=argument_list[1].real_reference; |
| 9878 |
if (attribute_flag[2] != 0) |
| 9879 |
geometry_info.sigma=argument_list[2].real_reference; |
| 9880 |
if (attribute_flag[3] != 0) |
| 9881 |
geometry_info.xi=argument_list[3].real_reference; |
| 9882 |
if (attribute_flag[4] != 0) |
| 9883 |
channel=(ChannelType) argument_list[4].integer_reference; |
| 9884 |
channel_mask=SetImageChannelMask(image,channel); |
| 9885 |
image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma, |
| 9886 |
geometry_info.xi,exception); |
| 9887 |
if (image != (Image *) NULL) |
| 9888 |
(void) SetImageChannelMask(image,channel_mask); |
| 9889 |
break; |
| 9890 |
} |
| 9891 |
case 71: /* OrderedDither */ |
| 9892 |
{ |
| 9893 |
if (attribute_flag[0] == 0) |
| 9894 |
argument_list[0].string_reference="o8x8"; |
| 9895 |
if (attribute_flag[1] != 0) |
| 9896 |
channel=(ChannelType) argument_list[1].integer_reference; |
| 9897 |
channel_mask=SetImageChannelMask(image,channel); |
| 9898 |
(void) OrderedDitherImage(image,argument_list[0].string_reference, |
| 9899 |
exception); |
| 9900 |
(void) SetImageChannelMask(image,channel_mask); |
| 9901 |
break; |
| 9902 |
} |
| 9903 |
case 72: /* Shave */ |
| 9904 |
{ |
| 9905 |
if (attribute_flag[0] != 0) |
| 9906 |
flags=ParsePageGeometry(image,argument_list[0].string_reference, |
| 9907 |
&geometry,exception); |
| 9908 |
if (attribute_flag[1] != 0) |
| 9909 |
geometry.width=(size_t) argument_list[1].integer_reference; |
| 9910 |
if (attribute_flag[2] != 0) |
| 9911 |
geometry.height=(size_t) argument_list[2].integer_reference; |
| 9912 |
image=ShaveImage(image,&geometry,exception); |
| 9913 |
break; |
| 9914 |
} |
| 9915 |
case 73: /* Level */ |
| 9916 |
{ |
| 9917 |
double |
| 9918 |
black_point, |
| 9919 |
gamma, |
| 9920 |
white_point; |
| 9921 |
|
| 9922 |
black_point=0.0; |
| 9923 |
white_point=(double) image->columns*image->rows; |
| 9924 |
gamma=1.0; |
| 9925 |
if (attribute_flag[0] != 0) |
| 9926 |
{ |
| 9927 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 9928 |
&geometry_info); |
| 9929 |
black_point=geometry_info.rho; |
| 9930 |
if ((flags & SigmaValue) != 0) |
| 9931 |
white_point=geometry_info.sigma; |
| 9932 |
if ((flags & XiValue) != 0) |
| 9933 |
gamma=geometry_info.xi; |
| 9934 |
if ((flags & PercentValue) != 0) |
| 9935 |
{ |
| 9936 |
black_point*=(double) (QuantumRange/100.0); |
| 9937 |
white_point*=(double) (QuantumRange/100.0); |
| 9938 |
} |
| 9939 |
if ((flags & SigmaValue) == 0) |
| 9940 |
white_point=(double) QuantumRange-black_point; |
| 9941 |
} |
| 9942 |
if (attribute_flag[1] != 0) |
| 9943 |
black_point=argument_list[1].real_reference; |
| 9944 |
if (attribute_flag[2] != 0) |
| 9945 |
white_point=argument_list[2].real_reference; |
| 9946 |
if (attribute_flag[3] != 0) |
| 9947 |
gamma=argument_list[3].real_reference; |
| 9948 |
if (attribute_flag[4] != 0) |
| 9949 |
channel=(ChannelType) argument_list[4].integer_reference; |
| 9950 |
if (attribute_flag[5] != 0) |
| 9951 |
{ |
| 9952 |
argument_list[0].real_reference=argument_list[5].real_reference; |
| 9953 |
attribute_flag[0]=attribute_flag[5]; |
| 9954 |
} |
| 9955 |
channel_mask=SetImageChannelMask(image,channel); |
| 9956 |
(void) LevelImage(image,black_point,white_point,gamma,exception); |
| 9957 |
(void) SetImageChannelMask(image,channel_mask); |
| 9958 |
break; |
| 9959 |
} |
| 9960 |
case 74: /* Clip */ |
| 9961 |
{ |
| 9962 |
if (attribute_flag[0] == 0) |
| 9963 |
argument_list[0].string_reference="#1"; |
| 9964 |
if (attribute_flag[1] == 0) |
| 9965 |
argument_list[1].integer_reference=MagickTrue; |
| 9966 |
(void) ClipImagePath(image,argument_list[0].string_reference, |
| 9967 |
argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse, |
| 9968 |
exception); |
| 9969 |
break; |
| 9970 |
} |
| 9971 |
case 75: /* AffineTransform */ |
| 9972 |
{ |
| 9973 |
DrawInfo |
| 9974 |
*draw_info; |
| 9975 |
|
| 9976 |
draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL, |
| 9977 |
(DrawInfo *) NULL); |
| 9978 |
if (attribute_flag[0] != 0) |
| 9979 |
{ |
| 9980 |
AV |
| 9981 |
*av; |
| 9982 |
|
| 9983 |
av=(AV *) argument_list[0].array_reference; |
| 9984 |
if ((av_len(av) != 3) && (av_len(av) != 5)) |
| 9985 |
{ |
| 9986 |
ThrowPerlException(exception,OptionError, |
| 9987 |
"affine matrix must have 4 or 6 elements",PackageName); |
| 9988 |
goto PerlException; |
| 9989 |
} |
| 9990 |
draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0))); |
| 9991 |
draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0))); |
| 9992 |
draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0))); |
| 9993 |
draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0))); |
| 9994 |
if (fabs(draw_info->affine.sx*draw_info->affine.sy- |
| 9995 |
draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon) |
| 9996 |
{ |
| 9997 |
ThrowPerlException(exception,OptionError, |
| 9998 |
"affine matrix is singular",PackageName); |
| 9999 |
goto PerlException; |
| 10000 |
} |
| 10001 |
if (av_len(av) == 5) |
| 10002 |
{ |
| 10003 |
draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0))); |
| 10004 |
draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0))); |
| 10005 |
} |
| 10006 |
} |
| 10007 |
for (j=1; j < 6; j++) |
| 10008 |
{ |
| 10009 |
if (attribute_flag[j] == 0) |
| 10010 |
continue; |
| 10011 |
value=argument_list[j].string_reference; |
| 10012 |
angle=argument_list[j].real_reference; |
| 10013 |
current=draw_info->affine; |
| 10014 |
GetAffineMatrix(&affine); |
| 10015 |
switch (j) |
| 10016 |
{ |
| 10017 |
case 1: |
| 10018 |
{ |
| 10019 |
/* |
| 10020 |
Translate. |
| 10021 |
*/ |
| 10022 |
flags=ParseGeometry(value,&geometry_info); |
| 10023 |
affine.tx=geometry_info.xi; |
| 10024 |
affine.ty=geometry_info.psi; |
| 10025 |
if ((flags & PsiValue) == 0) |
| 10026 |
affine.ty=affine.tx; |
| 10027 |
break; |
| 10028 |
} |
| 10029 |
case 2: |
| 10030 |
{ |
| 10031 |
/* |
| 10032 |
Scale. |
| 10033 |
*/ |
| 10034 |
flags=ParseGeometry(value,&geometry_info); |
| 10035 |
affine.sx=geometry_info.rho; |
| 10036 |
affine.sy=geometry_info.sigma; |
| 10037 |
if ((flags & SigmaValue) == 0) |
| 10038 |
affine.sy=affine.sx; |
| 10039 |
break; |
| 10040 |
} |
| 10041 |
case 3: |
| 10042 |
{ |
| 10043 |
/* |
| 10044 |
Rotate. |
| 10045 |
*/ |
| 10046 |
if (angle == 0.0) |
| 10047 |
break; |
| 10048 |
affine.sx=cos(DegreesToRadians(fmod(angle,360.0))); |
| 10049 |
affine.rx=sin(DegreesToRadians(fmod(angle,360.0))); |
| 10050 |
affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0)))); |
| 10051 |
affine.sy=cos(DegreesToRadians(fmod(angle,360.0))); |
| 10052 |
break; |
| 10053 |
} |
| 10054 |
case 4: |
| 10055 |
{ |
| 10056 |
/* |
| 10057 |
SkewX. |
| 10058 |
*/ |
| 10059 |
affine.ry=tan(DegreesToRadians(fmod(angle,360.0))); |
| 10060 |
break; |
| 10061 |
} |
| 10062 |
case 5: |
| 10063 |
{ |
| 10064 |
/* |
| 10065 |
SkewY. |
| 10066 |
*/ |
| 10067 |
affine.rx=tan(DegreesToRadians(fmod(angle,360.0))); |
| 10068 |
break; |
| 10069 |
} |
| 10070 |
} |
| 10071 |
draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx; |
| 10072 |
draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx; |
| 10073 |
draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy; |
| 10074 |
draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy; |
| 10075 |
draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+ |
| 10076 |
current.tx; |
| 10077 |
draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+ |
| 10078 |
current.ty; |
| 10079 |
} |
| 10080 |
if (attribute_flag[6] != 0) |
| 10081 |
image->interpolate=(PixelInterpolateMethod) |
| 10082 |
argument_list[6].integer_reference; |
| 10083 |
if (attribute_flag[7] != 0) |
| 10084 |
QueryColorCompliance(argument_list[7].string_reference, |
| 10085 |
AllCompliance,&image->background_color,exception); |
| 10086 |
image=AffineTransformImage(image,&draw_info->affine,exception); |
| 10087 |
draw_info=DestroyDrawInfo(draw_info); |
| 10088 |
break; |
| 10089 |
} |
| 10090 |
case 76: /* Difference */ |
| 10091 |
{ |
| 10092 |
if (attribute_flag[0] == 0) |
| 10093 |
{ |
| 10094 |
ThrowPerlException(exception,OptionError, |
| 10095 |
"ReferenceImageRequired",PackageName); |
| 10096 |
goto PerlException; |
| 10097 |
} |
| 10098 |
if (attribute_flag[1] != 0) |
| 10099 |
image->fuzz=StringToDoubleInterval( |
| 10100 |
argument_list[1].string_reference,(double) QuantumRange+1.0); |
| 10101 |
(void) SetImageColorMetric(image,argument_list[0].image_reference, |
| 10102 |
exception); |
| 10103 |
break; |
| 10104 |
} |
| 10105 |
case 77: /* AdaptiveThreshold */ |
| 10106 |
{ |
| 10107 |
if (attribute_flag[0] != 0) |
| 10108 |
{ |
| 10109 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 10110 |
&geometry_info); |
| 10111 |
if ((flags & PercentValue) != 0) |
| 10112 |
geometry_info.xi=QuantumRange*geometry_info.xi/100.0; |
| 10113 |
} |
| 10114 |
if (attribute_flag[1] != 0) |
| 10115 |
geometry_info.rho=argument_list[1].integer_reference; |
| 10116 |
if (attribute_flag[2] != 0) |
| 10117 |
geometry_info.sigma=argument_list[2].integer_reference; |
| 10118 |
if (attribute_flag[3] != 0) |
| 10119 |
geometry_info.xi=argument_list[3].integer_reference;; |
| 10120 |
image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho, |
| 10121 |
(size_t) geometry_info.sigma,(double) geometry_info.xi,exception); |
| 10122 |
break; |
| 10123 |
} |
| 10124 |
case 78: /* Resample */ |
| 10125 |
{ |
| 10126 |
size_t |
| 10127 |
height, |
| 10128 |
width; |
| 10129 |
|
| 10130 |
if (attribute_flag[0] != 0) |
| 10131 |
{ |
| 10132 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 10133 |
&geometry_info); |
| 10134 |
if ((flags & SigmaValue) == 0) |
| 10135 |
geometry_info.sigma=geometry_info.rho; |
| 10136 |
} |
| 10137 |
if (attribute_flag[1] != 0) |
| 10138 |
geometry_info.rho=argument_list[1].real_reference; |
| 10139 |
if (attribute_flag[2] != 0) |
| 10140 |
geometry_info.sigma=argument_list[2].real_reference; |
| 10141 |
if (attribute_flag[3] == 0) |
| 10142 |
argument_list[3].integer_reference=(ssize_t) UndefinedFilter; |
| 10143 |
if (attribute_flag[4] == 0) |
| 10144 |
SetImageArtifact(image,"filter:support", |
| 10145 |
argument_list[4].string_reference); |
| 10146 |
width=(size_t) (geometry_info.rho*image->columns/ |
| 10147 |
(image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5); |
| 10148 |
height=(size_t) (geometry_info.sigma*image->rows/ |
| 10149 |
(image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5); |
| 10150 |
image=ResizeImage(image,width,height,(FilterType) |
| 10151 |
argument_list[3].integer_reference,exception); |
| 10152 |
if (image != (Image *) NULL) |
| 10153 |
{ |
| 10154 |
image->resolution.x=geometry_info.rho; |
| 10155 |
image->resolution.y=geometry_info.sigma; |
| 10156 |
} |
| 10157 |
break; |
| 10158 |
} |
| 10159 |
case 79: /* Describe */ |
| 10160 |
{ |
| 10161 |
if (attribute_flag[0] == 0) |
| 10162 |
argument_list[0].file_reference=(FILE *) NULL; |
| 10163 |
(void) IdentifyImage(image,argument_list[0].file_reference, |
| 10164 |
MagickTrue,exception); |
| 10165 |
break; |
| 10166 |
} |
| 10167 |
case 80: /* BlackThreshold */ |
| 10168 |
{ |
| 10169 |
if (attribute_flag[0] == 0) |
| 10170 |
argument_list[0].string_reference="50%"; |
| 10171 |
if (attribute_flag[2] != 0) |
| 10172 |
channel=(ChannelType) argument_list[2].integer_reference; |
| 10173 |
channel_mask=SetImageChannelMask(image,channel); |
| 10174 |
(void) BlackThresholdImage(image,argument_list[0].string_reference, |
| 10175 |
exception); |
| 10176 |
(void) SetImageChannelMask(image,channel_mask); |
| 10177 |
break; |
| 10178 |
} |
| 10179 |
case 81: /* WhiteThreshold */ |
| 10180 |
{ |
| 10181 |
if (attribute_flag[0] == 0) |
| 10182 |
argument_list[0].string_reference="50%"; |
| 10183 |
if (attribute_flag[2] != 0) |
| 10184 |
channel=(ChannelType) argument_list[2].integer_reference; |
| 10185 |
channel_mask=SetImageChannelMask(image,channel); |
| 10186 |
WhiteThresholdImage(image,argument_list[0].string_reference, |
| 10187 |
exception); |
| 10188 |
(void) SetImageChannelMask(image,channel_mask); |
| 10189 |
break; |
| 10190 |
} |
| 10191 |
case 82: /* RotationalBlur */ |
| 10192 |
{ |
| 10193 |
if (attribute_flag[0] != 0) |
| 10194 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 10195 |
&geometry_info); |
| 10196 |
if (attribute_flag[1] != 0) |
| 10197 |
geometry_info.rho=argument_list[1].real_reference; |
| 10198 |
if (attribute_flag[2] != 0) |
| 10199 |
channel=(ChannelType) argument_list[2].integer_reference; |
| 10200 |
channel_mask=SetImageChannelMask(image,channel); |
| 10201 |
image=RotationalBlurImage(image,geometry_info.rho,exception); |
| 10202 |
if (image != (Image *) NULL) |
| 10203 |
(void) SetImageChannelMask(image,channel_mask); |
| 10204 |
break; |
| 10205 |
} |
| 10206 |
case 83: /* Thumbnail */ |
| 10207 |
{ |
| 10208 |
if (attribute_flag[0] != 0) |
| 10209 |
flags=ParseRegionGeometry(image,argument_list[0].string_reference, |
| 10210 |
&geometry,exception); |
| 10211 |
if (attribute_flag[1] != 0) |
| 10212 |
geometry.width=(size_t) argument_list[1].integer_reference; |
| 10213 |
if (attribute_flag[2] != 0) |
| 10214 |
geometry.height=(size_t) argument_list[2].integer_reference; |
| 10215 |
image=ThumbnailImage(image,geometry.width,geometry.height,exception); |
| 10216 |
break; |
| 10217 |
} |
| 10218 |
case 84: /* Strip */ |
| 10219 |
{ |
| 10220 |
(void) StripImage(image,exception); |
| 10221 |
break; |
| 10222 |
} |
| 10223 |
case 85: /* Tint */ |
| 10224 |
{ |
| 10225 |
PixelInfo |
| 10226 |
tint; |
| 10227 |
|
| 10228 |
GetPixelInfo(image,&tint); |
| 10229 |
if (attribute_flag[0] != 0) |
| 10230 |
(void) QueryColorCompliance(argument_list[0].string_reference, |
| 10231 |
AllCompliance,&tint,exception); |
| 10232 |
if (attribute_flag[1] == 0) |
| 10233 |
argument_list[1].string_reference="100"; |
| 10234 |
image=TintImage(image,argument_list[1].string_reference,&tint, |
| 10235 |
exception); |
| 10236 |
break; |
| 10237 |
} |
| 10238 |
case 86: /* Channel */ |
| 10239 |
{ |
| 10240 |
if (attribute_flag[0] != 0) |
| 10241 |
channel=(ChannelType) argument_list[0].integer_reference; |
| 10242 |
image=SeparateImage(image,channel,exception); |
| 10243 |
break; |
| 10244 |
} |
| 10245 |
case 87: /* Splice */ |
| 10246 |
{ |
| 10247 |
if (attribute_flag[7] != 0) |
| 10248 |
image->gravity=(GravityType) argument_list[7].integer_reference; |
| 10249 |
if (attribute_flag[0] != 0) |
| 10250 |
flags=ParseGravityGeometry(image,argument_list[0].string_reference, |
| 10251 |
&geometry,exception); |
| 10252 |
if (attribute_flag[1] != 0) |
| 10253 |
geometry.width=(size_t) argument_list[1].integer_reference; |
| 10254 |
if (attribute_flag[2] != 0) |
| 10255 |
geometry.height=(size_t) argument_list[2].integer_reference; |
| 10256 |
if (attribute_flag[3] != 0) |
| 10257 |
geometry.x=argument_list[3].integer_reference; |
| 10258 |
if (attribute_flag[4] != 0) |
| 10259 |
geometry.y=argument_list[4].integer_reference; |
| 10260 |
if (attribute_flag[5] != 0) |
| 10261 |
image->fuzz=StringToDoubleInterval( |
| 10262 |
argument_list[5].string_reference,(double) QuantumRange+1.0); |
| 10263 |
if (attribute_flag[6] != 0) |
| 10264 |
(void) QueryColorCompliance(argument_list[6].string_reference, |
| 10265 |
AllCompliance,&image->background_color,exception); |
| 10266 |
image=SpliceImage(image,&geometry,exception); |
| 10267 |
break; |
| 10268 |
} |
| 10269 |
case 88: /* Posterize */ |
| 10270 |
{ |
| 10271 |
if (attribute_flag[0] == 0) |
| 10272 |
argument_list[0].integer_reference=3; |
| 10273 |
if (attribute_flag[1] == 0) |
| 10274 |
argument_list[1].integer_reference=0; |
| 10275 |
(void) PosterizeImage(image,(size_t) |
| 10276 |
argument_list[0].integer_reference, |
| 10277 |
argument_list[1].integer_reference ? RiemersmaDitherMethod : |
| 10278 |
NoDitherMethod,exception); |
| 10279 |
break; |
| 10280 |
} |
| 10281 |
case 89: /* Shadow */ |
| 10282 |
{ |
| 10283 |
if (attribute_flag[0] != 0) |
| 10284 |
{ |
| 10285 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 10286 |
&geometry_info); |
| 10287 |
if ((flags & SigmaValue) == 0) |
| 10288 |
geometry_info.sigma=1.0; |
| 10289 |
if ((flags & XiValue) == 0) |
| 10290 |
geometry_info.xi=4.0; |
| 10291 |
if ((flags & PsiValue) == 0) |
| 10292 |
geometry_info.psi=4.0; |
| 10293 |
} |
| 10294 |
if (attribute_flag[1] != 0) |
| 10295 |
geometry_info.rho=argument_list[1].real_reference; |
| 10296 |
if (attribute_flag[2] != 0) |
| 10297 |
geometry_info.sigma=argument_list[2].real_reference; |
| 10298 |
if (attribute_flag[3] != 0) |
| 10299 |
geometry_info.xi=argument_list[3].integer_reference; |
| 10300 |
if (attribute_flag[4] != 0) |
| 10301 |
geometry_info.psi=argument_list[4].integer_reference; |
| 10302 |
image=ShadowImage(image,geometry_info.rho,geometry_info.sigma, |
| 10303 |
(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 10304 |
ceil(geometry_info.psi-0.5),exception); |
| 10305 |
break; |
| 10306 |
} |
| 10307 |
case 90: /* Identify */ |
| 10308 |
{ |
| 10309 |
if (attribute_flag[0] == 0) |
| 10310 |
argument_list[0].file_reference=(FILE *) NULL; |
| 10311 |
if (attribute_flag[1] != 0) |
| 10312 |
(void) SetImageArtifact(image,"identify:features", |
| 10313 |
argument_list[1].string_reference); |
| 10314 |
if ((attribute_flag[2] != 0) && |
| 10315 |
(argument_list[2].integer_reference != 0)) |
| 10316 |
(void) SetImageArtifact(image,"identify:moments","true"); |
| 10317 |
if ((attribute_flag[3] != 0) && |
| 10318 |
(argument_list[3].integer_reference != 0)) |
| 10319 |
(void) SetImageArtifact(image,"identify:unique","true"); |
| 10320 |
(void) IdentifyImage(image,argument_list[0].file_reference, |
| 10321 |
MagickTrue,exception); |
| 10322 |
break; |
| 10323 |
} |
| 10324 |
case 91: /* SepiaTone */ |
| 10325 |
{ |
| 10326 |
if (attribute_flag[0] == 0) |
| 10327 |
argument_list[0].real_reference=80.0*QuantumRange/100.0; |
| 10328 |
image=SepiaToneImage(image,argument_list[0].real_reference,exception); |
| 10329 |
break; |
| 10330 |
} |
| 10331 |
case 92: /* SigmoidalContrast */ |
| 10332 |
{ |
| 10333 |
MagickBooleanType |
| 10334 |
sharpen; |
| 10335 |
|
| 10336 |
if (attribute_flag[0] != 0) |
| 10337 |
{ |
| 10338 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 10339 |
&geometry_info); |
| 10340 |
if ((flags & SigmaValue) == 0) |
| 10341 |
geometry_info.sigma=QuantumRange/2.0; |
| 10342 |
if ((flags & PercentValue) != 0) |
| 10343 |
geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0; |
| 10344 |
} |
| 10345 |
if (attribute_flag[1] != 0) |
| 10346 |
geometry_info.rho=argument_list[1].real_reference; |
| 10347 |
if (attribute_flag[2] != 0) |
| 10348 |
geometry_info.sigma=argument_list[2].real_reference; |
| 10349 |
if (attribute_flag[3] != 0) |
| 10350 |
channel=(ChannelType) argument_list[3].integer_reference; |
| 10351 |
sharpen=MagickTrue; |
| 10352 |
if (attribute_flag[4] != 0) |
| 10353 |
sharpen=argument_list[4].integer_reference != 0 ? MagickTrue : |
| 10354 |
MagickFalse; |
| 10355 |
channel_mask=SetImageChannelMask(image,channel); |
| 10356 |
(void) SigmoidalContrastImage(image,sharpen,geometry_info.rho, |
| 10357 |
geometry_info.sigma,exception); |
| 10358 |
(void) SetImageChannelMask(image,channel_mask); |
| 10359 |
break; |
| 10360 |
} |
| 10361 |
case 93: /* Extent */ |
| 10362 |
{ |
| 10363 |
if (attribute_flag[7] != 0) |
| 10364 |
image->gravity=(GravityType) argument_list[7].integer_reference; |
| 10365 |
if (attribute_flag[0] != 0) |
| 10366 |
{ |
| 10367 |
MagickStatusType |
| 10368 |
flags; |
| 10369 |
|
| 10370 |
flags=ParseGravityGeometry(image, |
| 10371 |
argument_list[0].string_reference,&geometry,exception); |
| 10372 |
(void) flags; |
| 10373 |
if (geometry.width == 0) |
| 10374 |
geometry.width=image->columns; |
| 10375 |
if (geometry.height == 0) |
| 10376 |
geometry.height=image->rows; |
| 10377 |
} |
| 10378 |
if (attribute_flag[1] != 0) |
| 10379 |
geometry.width=(size_t) argument_list[1].integer_reference; |
| 10380 |
if (attribute_flag[2] != 0) |
| 10381 |
geometry.height=(size_t) argument_list[2].integer_reference; |
| 10382 |
if (attribute_flag[3] != 0) |
| 10383 |
geometry.x=argument_list[3].integer_reference; |
| 10384 |
if (attribute_flag[4] != 0) |
| 10385 |
geometry.y=argument_list[4].integer_reference; |
| 10386 |
if (attribute_flag[5] != 0) |
| 10387 |
image->fuzz=StringToDoubleInterval( |
| 10388 |
argument_list[5].string_reference,(double) QuantumRange+1.0); |
| 10389 |
if (attribute_flag[6] != 0) |
| 10390 |
(void) QueryColorCompliance(argument_list[6].string_reference, |
| 10391 |
AllCompliance,&image->background_color,exception); |
| 10392 |
image=ExtentImage(image,&geometry,exception); |
| 10393 |
break; |
| 10394 |
} |
| 10395 |
case 94: /* Vignette */ |
| 10396 |
{ |
| 10397 |
if (attribute_flag[0] != 0) |
| 10398 |
{ |
| 10399 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 10400 |
&geometry_info); |
| 10401 |
if ((flags & SigmaValue) == 0) |
| 10402 |
geometry_info.sigma=1.0; |
| 10403 |
if ((flags & XiValue) == 0) |
| 10404 |
geometry_info.xi=0.1*image->columns; |
| 10405 |
if ((flags & PsiValue) == 0) |
| 10406 |
geometry_info.psi=0.1*image->rows; |
| 10407 |
} |
| 10408 |
if (attribute_flag[1] != 0) |
| 10409 |
geometry_info.rho=argument_list[1].real_reference; |
| 10410 |
if (attribute_flag[2] != 0) |
| 10411 |
geometry_info.sigma=argument_list[2].real_reference; |
| 10412 |
if (attribute_flag[3] != 0) |
| 10413 |
geometry_info.xi=argument_list[3].integer_reference; |
| 10414 |
if (attribute_flag[4] != 0) |
| 10415 |
geometry_info.psi=argument_list[4].integer_reference; |
| 10416 |
if (attribute_flag[5] != 0) |
| 10417 |
(void) QueryColorCompliance(argument_list[5].string_reference, |
| 10418 |
AllCompliance,&image->background_color,exception); |
| 10419 |
image=VignetteImage(image,geometry_info.rho,geometry_info.sigma, |
| 10420 |
(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 10421 |
ceil(geometry_info.psi-0.5),exception); |
| 10422 |
break; |
| 10423 |
} |
| 10424 |
case 95: /* ContrastStretch */ |
| 10425 |
{ |
| 10426 |
double |
| 10427 |
black_point, |
| 10428 |
white_point; |
| 10429 |
|
| 10430 |
black_point=0.0; |
| 10431 |
white_point=(double) image->columns*image->rows; |
| 10432 |
if (attribute_flag[0] != 0) |
| 10433 |
{ |
| 10434 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 10435 |
&geometry_info); |
| 10436 |
black_point=geometry_info.rho; |
| 10437 |
white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 10438 |
black_point; |
| 10439 |
if ((flags & PercentValue) != 0) |
| 10440 |
{ |
| 10441 |
black_point*=(double) image->columns*image->rows/100.0; |
| 10442 |
white_point*=(double) image->columns*image->rows/100.0; |
| 10443 |
} |
| 10444 |
white_point=(double) image->columns*image->rows-white_point; |
| 10445 |
} |
| 10446 |
if (attribute_flag[1] != 0) |
| 10447 |
black_point=argument_list[1].real_reference; |
| 10448 |
if (attribute_flag[2] != 0) |
| 10449 |
white_point=argument_list[2].real_reference; |
| 10450 |
if (attribute_flag[4] != 0) |
| 10451 |
channel=(ChannelType) argument_list[4].integer_reference; |
| 10452 |
channel_mask=SetImageChannelMask(image,channel); |
| 10453 |
(void) ContrastStretchImage(image,black_point,white_point,exception); |
| 10454 |
(void) SetImageChannelMask(image,channel_mask); |
| 10455 |
break; |
| 10456 |
} |
| 10457 |
case 96: /* Sans0 */ |
| 10458 |
{ |
| 10459 |
break; |
| 10460 |
} |
| 10461 |
case 97: /* Sans1 */ |
| 10462 |
{ |
| 10463 |
break; |
| 10464 |
} |
| 10465 |
case 98: /* AdaptiveSharpen */ |
| 10466 |
{ |
| 10467 |
if (attribute_flag[0] != 0) |
| 10468 |
{ |
| 10469 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 10470 |
&geometry_info); |
| 10471 |
if ((flags & SigmaValue) == 0) |
| 10472 |
geometry_info.sigma=1.0; |
| 10473 |
if ((flags & XiValue) == 0) |
| 10474 |
geometry_info.xi=0.0; |
| 10475 |
} |
| 10476 |
if (attribute_flag[1] != 0) |
| 10477 |
geometry_info.rho=argument_list[1].real_reference; |
| 10478 |
if (attribute_flag[2] != 0) |
| 10479 |
geometry_info.sigma=argument_list[2].real_reference; |
| 10480 |
if (attribute_flag[3] != 0) |
| 10481 |
geometry_info.xi=argument_list[3].real_reference; |
| 10482 |
if (attribute_flag[4] != 0) |
| 10483 |
channel=(ChannelType) argument_list[4].integer_reference; |
| 10484 |
channel_mask=SetImageChannelMask(image,channel); |
| 10485 |
image=AdaptiveSharpenImage(image,geometry_info.rho, |
| 10486 |
geometry_info.sigma,exception); |
| 10487 |
if (image != (Image *) NULL) |
| 10488 |
(void) SetImageChannelMask(image,channel_mask); |
| 10489 |
break; |
| 10490 |
} |
| 10491 |
case 99: /* Transpose */ |
| 10492 |
{ |
| 10493 |
image=TransposeImage(image,exception); |
| 10494 |
break; |
| 10495 |
} |
| 10496 |
case 100: /* Transverse */ |
| 10497 |
{ |
| 10498 |
image=TransverseImage(image,exception); |
| 10499 |
break; |
| 10500 |
} |
| 10501 |
case 101: /* AutoOrient */ |
| 10502 |
{ |
| 10503 |
image=AutoOrientImage(image,image->orientation,exception); |
| 10504 |
break; |
| 10505 |
} |
| 10506 |
case 102: /* AdaptiveBlur */ |
| 10507 |
{ |
| 10508 |
if (attribute_flag[0] != 0) |
| 10509 |
{ |
| 10510 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 10511 |
&geometry_info); |
| 10512 |
if ((flags & SigmaValue) == 0) |
| 10513 |
geometry_info.sigma=1.0; |
| 10514 |
if ((flags & XiValue) == 0) |
| 10515 |
geometry_info.xi=0.0; |
| 10516 |
} |
| 10517 |
if (attribute_flag[1] != 0) |
| 10518 |
geometry_info.rho=argument_list[1].real_reference; |
| 10519 |
if (attribute_flag[2] != 0) |
| 10520 |
geometry_info.sigma=argument_list[2].real_reference; |
| 10521 |
if (attribute_flag[3] != 0) |
| 10522 |
channel=(ChannelType) argument_list[3].integer_reference; |
| 10523 |
channel_mask=SetImageChannelMask(image,channel); |
| 10524 |
image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma, |
| 10525 |
exception); |
| 10526 |
if (image != (Image *) NULL) |
| 10527 |
(void) SetImageChannelMask(image,channel_mask); |
| 10528 |
break; |
| 10529 |
} |
| 10530 |
case 103: /* Sketch */ |
| 10531 |
{ |
| 10532 |
if (attribute_flag[0] != 0) |
| 10533 |
{ |
| 10534 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 10535 |
&geometry_info); |
| 10536 |
if ((flags & SigmaValue) == 0) |
| 10537 |
geometry_info.sigma=1.0; |
| 10538 |
if ((flags & XiValue) == 0) |
| 10539 |
geometry_info.xi=1.0; |
| 10540 |
} |
| 10541 |
if (attribute_flag[1] != 0) |
| 10542 |
geometry_info.rho=argument_list[1].real_reference; |
| 10543 |
if (attribute_flag[2] != 0) |
| 10544 |
geometry_info.sigma=argument_list[2].real_reference; |
| 10545 |
if (attribute_flag[3] != 0) |
| 10546 |
geometry_info.xi=argument_list[3].real_reference; |
| 10547 |
image=SketchImage(image,geometry_info.rho,geometry_info.sigma, |
| 10548 |
geometry_info.xi,exception); |
| 10549 |
break; |
| 10550 |
} |
| 10551 |
case 104: /* UniqueColors */ |
| 10552 |
{ |
| 10553 |
image=UniqueImageColors(image,exception); |
| 10554 |
break; |
| 10555 |
} |
| 10556 |
case 105: /* AdaptiveResize */ |
| 10557 |
{ |
| 10558 |
if (attribute_flag[0] != 0) |
| 10559 |
flags=ParseRegionGeometry(image,argument_list[0].string_reference, |
| 10560 |
&geometry,exception); |
| 10561 |
if (attribute_flag[1] != 0) |
| 10562 |
geometry.width=(size_t) argument_list[1].integer_reference; |
| 10563 |
if (attribute_flag[2] != 0) |
| 10564 |
geometry.height=(size_t) argument_list[2].integer_reference; |
| 10565 |
if (attribute_flag[3] != 0) |
| 10566 |
image->filter=(FilterType) argument_list[4].integer_reference; |
| 10567 |
if (attribute_flag[4] != 0) |
| 10568 |
SetImageArtifact(image,"filter:support", |
| 10569 |
argument_list[4].string_reference); |
| 10570 |
image=AdaptiveResizeImage(image,geometry.width,geometry.height, |
| 10571 |
exception); |
| 10572 |
break; |
| 10573 |
} |
| 10574 |
case 106: /* ClipMask */ |
| 10575 |
{ |
| 10576 |
Image |
| 10577 |
*mask_image; |
| 10578 |
|
| 10579 |
if (attribute_flag[0] == 0) |
| 10580 |
{ |
| 10581 |
ThrowPerlException(exception,OptionError,"MaskImageRequired", |
| 10582 |
PackageName); |
| 10583 |
goto PerlException; |
| 10584 |
} |
| 10585 |
mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue, |
| 10586 |
exception); |
| 10587 |
(void) SetImageMask(image,ReadPixelMask,mask_image,exception); |
| 10588 |
mask_image=DestroyImage(mask_image); |
| 10589 |
break; |
| 10590 |
} |
| 10591 |
case 107: /* LinearStretch */ |
| 10592 |
{ |
| 10593 |
double |
| 10594 |
black_point, |
| 10595 |
white_point; |
| 10596 |
|
| 10597 |
black_point=0.0; |
| 10598 |
white_point=(double) image->columns*image->rows; |
| 10599 |
if (attribute_flag[0] != 0) |
| 10600 |
{ |
| 10601 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 10602 |
&geometry_info); |
| 10603 |
if ((flags & SigmaValue) != 0) |
| 10604 |
white_point=geometry_info.sigma; |
| 10605 |
if ((flags & PercentValue) != 0) |
| 10606 |
{ |
| 10607 |
black_point*=(double) image->columns*image->rows/100.0; |
| 10608 |
white_point*=(double) image->columns*image->rows/100.0; |
| 10609 |
} |
| 10610 |
if ((flags & SigmaValue) == 0) |
| 10611 |
white_point=(double) image->columns*image->rows-black_point; |
| 10612 |
} |
| 10613 |
if (attribute_flag[1] != 0) |
| 10614 |
black_point=argument_list[1].real_reference; |
| 10615 |
if (attribute_flag[2] != 0) |
| 10616 |
white_point=argument_list[2].real_reference; |
| 10617 |
(void) LinearStretchImage(image,black_point,white_point,exception); |
| 10618 |
break; |
| 10619 |
} |
| 10620 |
case 108: /* ColorMatrix */ |
| 10621 |
{ |
| 10622 |
AV |
| 10623 |
*av; |
| 10624 |
|
| 10625 |
double |
| 10626 |
*color_matrix; |
| 10627 |
|
| 10628 |
KernelInfo |
| 10629 |
*kernel_info; |
| 10630 |
|
| 10631 |
size_t |
| 10632 |
order; |
| 10633 |
|
| 10634 |
if (attribute_flag[0] == 0) |
| 10635 |
break; |
| 10636 |
av=(AV *) argument_list[0].array_reference; |
| 10637 |
order=(size_t) sqrt(av_len(av)+1); |
| 10638 |
color_matrix=(double *) AcquireQuantumMemory(order,order* |
| 10639 |
sizeof(*color_matrix)); |
| 10640 |
if (color_matrix == (double *) NULL) |
| 10641 |
{ |
| 10642 |
ThrowPerlException(exception,ResourceLimitFatalError, |
| 10643 |
"MemoryAllocationFailed",PackageName); |
| 10644 |
goto PerlException; |
| 10645 |
} |
| 10646 |
for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++) |
| 10647 |
color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0))); |
| 10648 |
for ( ; j < (ssize_t) (order*order); j++) |
| 10649 |
color_matrix[j]=0.0; |
| 10650 |
kernel_info=AcquireKernelInfo((const char *) NULL,exception); |
| 10651 |
if (kernel_info == (KernelInfo *) NULL) |
| 10652 |
break; |
| 10653 |
kernel_info->width=order; |
| 10654 |
kernel_info->height=order; |
| 10655 |
kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order, |
| 10656 |
order*sizeof(*kernel_info->values)); |
| 10657 |
if (kernel_info->values != (MagickRealType *) NULL) |
| 10658 |
{ |
| 10659 |
for (i=0; i < (ssize_t) (order*order); i++) |
| 10660 |
kernel_info->values[i]=(MagickRealType) color_matrix[i]; |
| 10661 |
image=ColorMatrixImage(image,kernel_info,exception); |
| 10662 |
} |
| 10663 |
kernel_info=DestroyKernelInfo(kernel_info); |
| 10664 |
color_matrix=(double *) RelinquishMagickMemory(color_matrix); |
| 10665 |
break; |
| 10666 |
} |
| 10667 |
case 109: /* Mask */ |
| 10668 |
{ |
| 10669 |
Image |
| 10670 |
*mask_image; |
| 10671 |
|
| 10672 |
if (attribute_flag[0] == 0) |
| 10673 |
{ |
| 10674 |
ThrowPerlException(exception,OptionError,"MaskImageRequired", |
| 10675 |
PackageName); |
| 10676 |
goto PerlException; |
| 10677 |
} |
| 10678 |
mask_image=CloneImage(argument_list[0].image_reference,0,0, |
| 10679 |
MagickTrue,exception); |
| 10680 |
(void) SetImageMask(image,ReadPixelMask,mask_image,exception); |
| 10681 |
mask_image=DestroyImage(mask_image); |
| 10682 |
break; |
| 10683 |
} |
| 10684 |
case 110: /* Polaroid */ |
| 10685 |
{ |
| 10686 |
char |
| 10687 |
*caption; |
| 10688 |
|
| 10689 |
double |
| 10690 |
angle; |
| 10691 |
|
| 10692 |
DrawInfo |
| 10693 |
*draw_info; |
| 10694 |
|
| 10695 |
PixelInterpolateMethod |
| 10696 |
method; |
| 10697 |
|
| 10698 |
draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL, |
| 10699 |
(DrawInfo *) NULL); |
| 10700 |
caption=(char *) NULL; |
| 10701 |
if (attribute_flag[0] != 0) |
| 10702 |
caption=InterpretImageProperties(info ? info->image_info : |
| 10703 |
(ImageInfo *) NULL,image,argument_list[0].string_reference, |
| 10704 |
exception); |
| 10705 |
angle=0.0; |
| 10706 |
if (attribute_flag[1] != 0) |
| 10707 |
angle=argument_list[1].real_reference; |
| 10708 |
if (attribute_flag[2] != 0) |
| 10709 |
(void) CloneString(&draw_info->font, |
| 10710 |
argument_list[2].string_reference); |
| 10711 |
if (attribute_flag[3] != 0) |
| 10712 |
(void) QueryColorCompliance(argument_list[3].string_reference, |
| 10713 |
AllCompliance,&draw_info->stroke,exception); |
| 10714 |
if (attribute_flag[4] != 0) |
| 10715 |
(void) QueryColorCompliance(argument_list[4].string_reference, |
| 10716 |
AllCompliance,&draw_info->fill,exception); |
| 10717 |
if (attribute_flag[5] != 0) |
| 10718 |
draw_info->stroke_width=(size_t) argument_list[5].real_reference; |
| 10719 |
if (attribute_flag[6] != 0) |
| 10720 |
draw_info->pointsize=argument_list[6].real_reference; |
| 10721 |
if (attribute_flag[7] != 0) |
| 10722 |
draw_info->gravity=(GravityType) argument_list[7].integer_reference; |
| 10723 |
if (attribute_flag[8] != 0) |
| 10724 |
(void) QueryColorCompliance(argument_list[8].string_reference, |
| 10725 |
AllCompliance,&image->background_color,exception); |
| 10726 |
method=UndefinedInterpolatePixel; |
| 10727 |
if (attribute_flag[9] != 0) |
| 10728 |
method=(PixelInterpolateMethod) argument_list[9].integer_reference; |
| 10729 |
image=PolaroidImage(image,draw_info,caption,angle,method,exception); |
| 10730 |
draw_info=DestroyDrawInfo(draw_info); |
| 10731 |
if (caption != (char *) NULL) |
| 10732 |
caption=DestroyString(caption); |
| 10733 |
break; |
| 10734 |
} |
| 10735 |
case 111: /* FloodfillPaint */ |
| 10736 |
{ |
| 10737 |
DrawInfo |
| 10738 |
*draw_info; |
| 10739 |
|
| 10740 |
MagickBooleanType |
| 10741 |
invert; |
| 10742 |
|
| 10743 |
PixelInfo |
| 10744 |
target; |
| 10745 |
|
| 10746 |
draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL, |
| 10747 |
(DrawInfo *) NULL); |
| 10748 |
if (attribute_flag[0] != 0) |
| 10749 |
flags=ParsePageGeometry(image,argument_list[0].string_reference, |
| 10750 |
&geometry,exception); |
| 10751 |
if (attribute_flag[1] != 0) |
| 10752 |
geometry.x=argument_list[1].integer_reference; |
| 10753 |
if (attribute_flag[2] != 0) |
| 10754 |
geometry.y=argument_list[2].integer_reference; |
| 10755 |
if (attribute_flag[3] != 0) |
| 10756 |
(void) QueryColorCompliance(argument_list[3].string_reference, |
| 10757 |
AllCompliance,&draw_info->fill,exception); |
| 10758 |
(void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod, |
| 10759 |
geometry.x,geometry.y,&target,exception); |
| 10760 |
if (attribute_flag[4] != 0) |
| 10761 |
QueryColorCompliance(argument_list[4].string_reference, |
| 10762 |
AllCompliance,&target,exception); |
| 10763 |
if (attribute_flag[5] != 0) |
| 10764 |
image->fuzz=StringToDoubleInterval( |
| 10765 |
argument_list[5].string_reference,(double) QuantumRange+1.0); |
| 10766 |
if (attribute_flag[6] != 0) |
| 10767 |
channel=(ChannelType) argument_list[6].integer_reference; |
| 10768 |
invert=MagickFalse; |
| 10769 |
if (attribute_flag[7] != 0) |
| 10770 |
invert=(MagickBooleanType) argument_list[7].integer_reference; |
| 10771 |
channel_mask=SetImageChannelMask(image,channel); |
| 10772 |
(void) FloodfillPaintImage(image,draw_info,&target,geometry.x, |
| 10773 |
geometry.y,invert,exception); |
| 10774 |
(void) SetImageChannelMask(image,channel_mask); |
| 10775 |
draw_info=DestroyDrawInfo(draw_info); |
| 10776 |
break; |
| 10777 |
} |
| 10778 |
case 112: /* Distort */ |
| 10779 |
{ |
| 10780 |
AV |
| 10781 |
*av; |
| 10782 |
|
| 10783 |
DistortMethod |
| 10784 |
method; |
| 10785 |
|
| 10786 |
double |
| 10787 |
*coordinates; |
| 10788 |
|
| 10789 |
size_t |
| 10790 |
number_coordinates; |
| 10791 |
|
| 10792 |
VirtualPixelMethod |
| 10793 |
virtual_pixel; |
| 10794 |
|
| 10795 |
if (attribute_flag[0] == 0) |
| 10796 |
break; |
| 10797 |
method=UndefinedDistortion; |
| 10798 |
if (attribute_flag[1] != 0) |
| 10799 |
method=(DistortMethod) argument_list[1].integer_reference; |
| 10800 |
av=(AV *) argument_list[0].array_reference; |
| 10801 |
number_coordinates=(size_t) av_len(av)+1; |
| 10802 |
coordinates=(double *) AcquireQuantumMemory(number_coordinates, |
| 10803 |
sizeof(*coordinates)); |
| 10804 |
if (coordinates == (double *) NULL) |
| 10805 |
{ |
| 10806 |
ThrowPerlException(exception,ResourceLimitFatalError, |
| 10807 |
"MemoryAllocationFailed",PackageName); |
| 10808 |
goto PerlException; |
| 10809 |
} |
| 10810 |
for (j=0; j < (ssize_t) number_coordinates; j++) |
| 10811 |
coordinates[j]=(double) SvNV(*(av_fetch(av,j,0))); |
| 10812 |
virtual_pixel=UndefinedVirtualPixelMethod; |
| 10813 |
if (attribute_flag[2] != 0) |
| 10814 |
virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod) |
| 10815 |
argument_list[2].integer_reference,exception); |
| 10816 |
image=DistortImage(image,method,number_coordinates,coordinates, |
| 10817 |
argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse, |
| 10818 |
exception); |
| 10819 |
if ((attribute_flag[2] != 0) && (image != (Image *) NULL)) |
| 10820 |
virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel, |
| 10821 |
exception); |
| 10822 |
coordinates=(double *) RelinquishMagickMemory(coordinates); |
| 10823 |
break; |
| 10824 |
} |
| 10825 |
case 113: /* Clut */ |
| 10826 |
{ |
| 10827 |
PixelInterpolateMethod |
| 10828 |
method; |
| 10829 |
|
| 10830 |
if (attribute_flag[0] == 0) |
| 10831 |
{ |
| 10832 |
ThrowPerlException(exception,OptionError,"ClutImageRequired", |
| 10833 |
PackageName); |
| 10834 |
goto PerlException; |
| 10835 |
} |
| 10836 |
method=UndefinedInterpolatePixel; |
| 10837 |
if (attribute_flag[1] != 0) |
| 10838 |
method=(PixelInterpolateMethod) argument_list[1].integer_reference; |
| 10839 |
if (attribute_flag[2] != 0) |
| 10840 |
channel=(ChannelType) argument_list[2].integer_reference; |
| 10841 |
channel_mask=SetImageChannelMask(image,channel); |
| 10842 |
(void) ClutImage(image,argument_list[0].image_reference,method, |
| 10843 |
exception); |
| 10844 |
(void) SetImageChannelMask(image,channel_mask); |
| 10845 |
break; |
| 10846 |
} |
| 10847 |
case 114: /* LiquidRescale */ |
| 10848 |
{ |
| 10849 |
if (attribute_flag[0] != 0) |
| 10850 |
flags=ParseRegionGeometry(image,argument_list[0].string_reference, |
| 10851 |
&geometry,exception); |
| 10852 |
if (attribute_flag[1] != 0) |
| 10853 |
geometry.width=(size_t) argument_list[1].integer_reference; |
| 10854 |
if (attribute_flag[2] != 0) |
| 10855 |
geometry.height=(size_t) argument_list[2].integer_reference; |
| 10856 |
if (attribute_flag[3] == 0) |
| 10857 |
argument_list[3].real_reference=1.0; |
| 10858 |
if (attribute_flag[4] == 0) |
| 10859 |
argument_list[4].real_reference=0.0; |
| 10860 |
image=LiquidRescaleImage(image,geometry.width,geometry.height, |
| 10861 |
argument_list[3].real_reference,argument_list[4].real_reference, |
| 10862 |
exception); |
| 10863 |
break; |
| 10864 |
} |
| 10865 |
case 115: /* EncipherImage */ |
| 10866 |
{ |
| 10867 |
(void) EncipherImage(image,argument_list[0].string_reference, |
| 10868 |
exception); |
| 10869 |
break; |
| 10870 |
} |
| 10871 |
case 116: /* DecipherImage */ |
| 10872 |
{ |
| 10873 |
(void) DecipherImage(image,argument_list[0].string_reference, |
| 10874 |
exception); |
| 10875 |
break; |
| 10876 |
} |
| 10877 |
case 117: /* Deskew */ |
| 10878 |
{ |
| 10879 |
geometry_info.rho=QuantumRange/2.0; |
| 10880 |
if (attribute_flag[0] != 0) |
| 10881 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 10882 |
&geometry_info); |
| 10883 |
if (attribute_flag[1] != 0) |
| 10884 |
geometry_info.rho=StringToDoubleInterval( |
| 10885 |
argument_list[1].string_reference,(double) QuantumRange+1.0); |
| 10886 |
image=DeskewImage(image,geometry_info.rho,exception); |
| 10887 |
break; |
| 10888 |
} |
| 10889 |
case 118: /* Remap */ |
| 10890 |
{ |
| 10891 |
QuantizeInfo |
| 10892 |
*quantize_info; |
| 10893 |
|
| 10894 |
if (attribute_flag[0] == 0) |
| 10895 |
{ |
| 10896 |
ThrowPerlException(exception,OptionError,"RemapImageRequired", |
| 10897 |
PackageName); |
| 10898 |
goto PerlException; |
| 10899 |
} |
| 10900 |
quantize_info=AcquireQuantizeInfo(info->image_info); |
| 10901 |
if (attribute_flag[1] != 0) |
| 10902 |
quantize_info->dither_method=(DitherMethod) |
| 10903 |
argument_list[1].integer_reference; |
| 10904 |
(void) RemapImages(quantize_info,image, |
| 10905 |
argument_list[0].image_reference,exception); |
| 10906 |
quantize_info=DestroyQuantizeInfo(quantize_info); |
| 10907 |
break; |
| 10908 |
} |
| 10909 |
case 119: /* SparseColor */ |
| 10910 |
{ |
| 10911 |
AV |
| 10912 |
*av; |
| 10913 |
|
| 10914 |
double |
| 10915 |
*coordinates; |
| 10916 |
|
| 10917 |
size_t |
| 10918 |
number_coordinates; |
| 10919 |
|
| 10920 |
SparseColorMethod |
| 10921 |
method; |
| 10922 |
|
| 10923 |
VirtualPixelMethod |
| 10924 |
virtual_pixel; |
| 10925 |
|
| 10926 |
if (attribute_flag[0] == 0) |
| 10927 |
break; |
| 10928 |
method=UndefinedColorInterpolate; |
| 10929 |
if (attribute_flag[1] != 0) |
| 10930 |
method=(SparseColorMethod) argument_list[1].integer_reference; |
| 10931 |
av=(AV *) argument_list[0].array_reference; |
| 10932 |
number_coordinates=(size_t) av_len(av)+1; |
| 10933 |
coordinates=(double *) AcquireQuantumMemory(number_coordinates, |
| 10934 |
sizeof(*coordinates)); |
| 10935 |
if (coordinates == (double *) NULL) |
| 10936 |
{ |
| 10937 |
ThrowPerlException(exception,ResourceLimitFatalError, |
| 10938 |
"MemoryAllocationFailed",PackageName); |
| 10939 |
goto PerlException; |
| 10940 |
} |
| 10941 |
for (j=0; j < (ssize_t) number_coordinates; j++) |
| 10942 |
coordinates[j]=(double) SvNV(*(av_fetch(av,j,0))); |
| 10943 |
virtual_pixel=UndefinedVirtualPixelMethod; |
| 10944 |
if (attribute_flag[2] != 0) |
| 10945 |
virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod) |
| 10946 |
argument_list[2].integer_reference,exception); |
| 10947 |
if (attribute_flag[3] != 0) |
| 10948 |
channel=(ChannelType) argument_list[3].integer_reference; |
| 10949 |
channel_mask=SetImageChannelMask(image,channel); |
| 10950 |
image=SparseColorImage(image,method,number_coordinates,coordinates, |
| 10951 |
exception); |
| 10952 |
if (image != (Image *) NULL) |
| 10953 |
(void) SetImageChannelMask(image,channel_mask); |
| 10954 |
if ((attribute_flag[2] != 0) && (image != (Image *) NULL)) |
| 10955 |
virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel, |
| 10956 |
exception); |
| 10957 |
coordinates=(double *) RelinquishMagickMemory(coordinates); |
| 10958 |
break; |
| 10959 |
} |
| 10960 |
case 120: /* Function */ |
| 10961 |
{ |
| 10962 |
AV |
| 10963 |
*av; |
| 10964 |
|
| 10965 |
double |
| 10966 |
*parameters; |
| 10967 |
|
| 10968 |
MagickFunction |
| 10969 |
function; |
| 10970 |
|
| 10971 |
size_t |
| 10972 |
number_parameters; |
| 10973 |
|
| 10974 |
VirtualPixelMethod |
| 10975 |
virtual_pixel; |
| 10976 |
|
| 10977 |
if (attribute_flag[0] == 0) |
| 10978 |
break; |
| 10979 |
function=UndefinedFunction; |
| 10980 |
if (attribute_flag[1] != 0) |
| 10981 |
function=(MagickFunction) argument_list[1].integer_reference; |
| 10982 |
av=(AV *) argument_list[0].array_reference; |
| 10983 |
number_parameters=(size_t) av_len(av)+1; |
| 10984 |
parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 10985 |
sizeof(*parameters)); |
| 10986 |
if (parameters == (double *) NULL) |
| 10987 |
{ |
| 10988 |
ThrowPerlException(exception,ResourceLimitFatalError, |
| 10989 |
"MemoryAllocationFailed",PackageName); |
| 10990 |
goto PerlException; |
| 10991 |
} |
| 10992 |
for (j=0; j < (ssize_t) number_parameters; j++) |
| 10993 |
parameters[j]=(double) SvNV(*(av_fetch(av,j,0))); |
| 10994 |
virtual_pixel=UndefinedVirtualPixelMethod; |
| 10995 |
if (attribute_flag[2] != 0) |
| 10996 |
virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod) |
| 10997 |
argument_list[2].integer_reference,exception); |
| 10998 |
(void) FunctionImage(image,function,number_parameters,parameters, |
| 10999 |
exception); |
| 11000 |
if ((attribute_flag[2] != 0) && (image != (Image *) NULL)) |
| 11001 |
virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel, |
| 11002 |
exception); |
| 11003 |
parameters=(double *) RelinquishMagickMemory(parameters); |
| 11004 |
break; |
| 11005 |
} |
| 11006 |
case 121: /* SelectiveBlur */ |
| 11007 |
{ |
| 11008 |
if (attribute_flag[0] != 0) |
| 11009 |
{ |
| 11010 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 11011 |
&geometry_info); |
| 11012 |
if ((flags & SigmaValue) == 0) |
| 11013 |
geometry_info.sigma=1.0; |
| 11014 |
if ((flags & PercentValue) != 0) |
| 11015 |
geometry_info.xi=QuantumRange*geometry_info.xi/100.0; |
| 11016 |
} |
| 11017 |
if (attribute_flag[1] != 0) |
| 11018 |
geometry_info.rho=argument_list[1].real_reference; |
| 11019 |
if (attribute_flag[2] != 0) |
| 11020 |
geometry_info.sigma=argument_list[2].real_reference; |
| 11021 |
if (attribute_flag[3] != 0) |
| 11022 |
geometry_info.xi=argument_list[3].integer_reference;; |
| 11023 |
if (attribute_flag[5] != 0) |
| 11024 |
channel=(ChannelType) argument_list[5].integer_reference; |
| 11025 |
channel_mask=SetImageChannelMask(image,channel); |
| 11026 |
image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma, |
| 11027 |
geometry_info.xi,exception); |
| 11028 |
if (image != (Image *) NULL) |
| 11029 |
(void) SetImageChannelMask(image,channel_mask); |
| 11030 |
break; |
| 11031 |
} |
| 11032 |
case 122: /* HaldClut */ |
| 11033 |
{ |
| 11034 |
if (attribute_flag[0] == 0) |
| 11035 |
{ |
| 11036 |
ThrowPerlException(exception,OptionError,"ClutImageRequired", |
| 11037 |
PackageName); |
| 11038 |
goto PerlException; |
| 11039 |
} |
| 11040 |
if (attribute_flag[1] != 0) |
| 11041 |
channel=(ChannelType) argument_list[1].integer_reference; |
| 11042 |
channel_mask=SetImageChannelMask(image,channel); |
| 11043 |
(void) HaldClutImage(image,argument_list[0].image_reference, |
| 11044 |
exception); |
| 11045 |
(void) SetImageChannelMask(image,channel_mask); |
| 11046 |
break; |
| 11047 |
} |
| 11048 |
case 123: /* BlueShift */ |
| 11049 |
{ |
| 11050 |
if (attribute_flag[0] != 0) |
| 11051 |
(void) ParseGeometry(argument_list[0].string_reference, |
| 11052 |
&geometry_info); |
| 11053 |
image=BlueShiftImage(image,geometry_info.rho,exception); |
| 11054 |
break; |
| 11055 |
} |
| 11056 |
case 124: /* ForwardFourierTransformImage */ |
| 11057 |
{ |
| 11058 |
image=ForwardFourierTransformImage(image, |
| 11059 |
argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse, |
| 11060 |
exception); |
| 11061 |
break; |
| 11062 |
} |
| 11063 |
case 125: /* InverseFourierTransformImage */ |
| 11064 |
{ |
| 11065 |
image=InverseFourierTransformImage(image,image->next, |
| 11066 |
argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse, |
| 11067 |
exception); |
| 11068 |
break; |
| 11069 |
} |
| 11070 |
case 126: /* ColorDecisionList */ |
| 11071 |
{ |
| 11072 |
if (attribute_flag[0] == 0) |
| 11073 |
argument_list[0].string_reference=(char *) NULL; |
| 11074 |
(void) ColorDecisionListImage(image, |
| 11075 |
argument_list[0].string_reference,exception); |
| 11076 |
break; |
| 11077 |
} |
| 11078 |
case 127: /* AutoGamma */ |
| 11079 |
{ |
| 11080 |
if (attribute_flag[0] != 0) |
| 11081 |
channel=(ChannelType) argument_list[0].integer_reference; |
| 11082 |
channel_mask=SetImageChannelMask(image,channel); |
| 11083 |
(void) AutoGammaImage(image,exception); |
| 11084 |
(void) SetImageChannelMask(image,channel_mask); |
| 11085 |
break; |
| 11086 |
} |
| 11087 |
case 128: /* AutoLevel */ |
| 11088 |
{ |
| 11089 |
if (attribute_flag[0] != 0) |
| 11090 |
channel=(ChannelType) argument_list[0].integer_reference; |
| 11091 |
channel_mask=SetImageChannelMask(image,channel); |
| 11092 |
(void) AutoLevelImage(image,exception); |
| 11093 |
(void) SetImageChannelMask(image,channel_mask); |
| 11094 |
break; |
| 11095 |
} |
| 11096 |
case 129: /* LevelColors */ |
| 11097 |
{ |
| 11098 |
PixelInfo |
| 11099 |
black_point, |
| 11100 |
white_point; |
| 11101 |
|
| 11102 |
(void) QueryColorCompliance("#000000",AllCompliance,&black_point, |
| 11103 |
exception); |
| 11104 |
(void) QueryColorCompliance("#ffffff",AllCompliance,&white_point, |
| 11105 |
exception); |
| 11106 |
if (attribute_flag[1] != 0) |
| 11107 |
(void) QueryColorCompliance( |
| 11108 |
argument_list[1].string_reference,AllCompliance,&black_point, |
| 11109 |
exception); |
| 11110 |
if (attribute_flag[2] != 0) |
| 11111 |
(void) QueryColorCompliance( |
| 11112 |
argument_list[2].string_reference,AllCompliance,&white_point, |
| 11113 |
exception); |
| 11114 |
if (attribute_flag[3] != 0) |
| 11115 |
channel=(ChannelType) argument_list[3].integer_reference; |
| 11116 |
channel_mask=SetImageChannelMask(image,channel); |
| 11117 |
(void) LevelImageColors(image,&black_point,&white_point, |
| 11118 |
argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse, |
| 11119 |
exception); |
| 11120 |
(void) SetImageChannelMask(image,channel_mask); |
| 11121 |
break; |
| 11122 |
} |
| 11123 |
case 130: /* Clamp */ |
| 11124 |
{ |
| 11125 |
if (attribute_flag[0] != 0) |
| 11126 |
channel=(ChannelType) argument_list[0].integer_reference; |
| 11127 |
channel_mask=SetImageChannelMask(image,channel); |
| 11128 |
(void) ClampImage(image,exception); |
| 11129 |
(void) SetImageChannelMask(image,channel_mask); |
| 11130 |
break; |
| 11131 |
} |
| 11132 |
case 131: /* BrightnessContrast */ |
| 11133 |
{ |
| 11134 |
double |
| 11135 |
brightness, |
| 11136 |
contrast; |
| 11137 |
|
| 11138 |
brightness=0.0; |
| 11139 |
contrast=0.0; |
| 11140 |
if (attribute_flag[0] != 0) |
| 11141 |
{ |
| 11142 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 11143 |
&geometry_info); |
| 11144 |
brightness=geometry_info.rho; |
| 11145 |
if ((flags & SigmaValue) == 0) |
| 11146 |
contrast=geometry_info.sigma; |
| 11147 |
} |
| 11148 |
if (attribute_flag[1] != 0) |
| 11149 |
brightness=argument_list[1].real_reference; |
| 11150 |
if (attribute_flag[2] != 0) |
| 11151 |
contrast=argument_list[2].real_reference; |
| 11152 |
if (attribute_flag[4] != 0) |
| 11153 |
channel=(ChannelType) argument_list[4].integer_reference; |
| 11154 |
channel_mask=SetImageChannelMask(image,channel); |
| 11155 |
(void) BrightnessContrastImage(image,brightness,contrast,exception); |
| 11156 |
(void) SetImageChannelMask(image,channel_mask); |
| 11157 |
break; |
| 11158 |
} |
| 11159 |
case 132: /* Morphology */ |
| 11160 |
{ |
| 11161 |
KernelInfo |
| 11162 |
*kernel; |
| 11163 |
|
| 11164 |
MorphologyMethod |
| 11165 |
method; |
| 11166 |
|
| 11167 |
ssize_t |
| 11168 |
iterations; |
| 11169 |
|
| 11170 |
if (attribute_flag[0] == 0) |
| 11171 |
break; |
| 11172 |
kernel=AcquireKernelInfo(argument_list[0].string_reference,exception); |
| 11173 |
if (kernel == (KernelInfo *) NULL) |
| 11174 |
break; |
| 11175 |
if (attribute_flag[1] != 0) |
| 11176 |
channel=(ChannelType) argument_list[1].integer_reference; |
| 11177 |
method=UndefinedMorphology; |
| 11178 |
if (attribute_flag[2] != 0) |
| 11179 |
method=(MorphologyMethod) argument_list[2].integer_reference; |
| 11180 |
iterations=1; |
| 11181 |
if (attribute_flag[3] != 0) |
| 11182 |
iterations=argument_list[3].integer_reference; |
| 11183 |
channel_mask=SetImageChannelMask(image,channel); |
| 11184 |
image=MorphologyImage(image,method,iterations,kernel,exception); |
| 11185 |
if (image != (Image *) NULL) |
| 11186 |
(void) SetImageChannelMask(image,channel_mask); |
| 11187 |
kernel=DestroyKernelInfo(kernel); |
| 11188 |
break; |
| 11189 |
} |
| 11190 |
case 133: /* Mode */ |
| 11191 |
{ |
| 11192 |
if (attribute_flag[0] != 0) |
| 11193 |
{ |
| 11194 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 11195 |
&geometry_info); |
| 11196 |
if ((flags & SigmaValue) == 0) |
| 11197 |
geometry_info.sigma=1.0; |
| 11198 |
} |
| 11199 |
if (attribute_flag[1] != 0) |
| 11200 |
geometry_info.rho=argument_list[1].real_reference; |
| 11201 |
if (attribute_flag[2] != 0) |
| 11202 |
geometry_info.sigma=argument_list[2].real_reference; |
| 11203 |
if (attribute_flag[3] != 0) |
| 11204 |
channel=(ChannelType) argument_list[3].integer_reference; |
| 11205 |
channel_mask=SetImageChannelMask(image,channel); |
| 11206 |
image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho, |
| 11207 |
(size_t) geometry_info.sigma,exception); |
| 11208 |
if (image != (Image *) NULL) |
| 11209 |
(void) SetImageChannelMask(image,channel_mask); |
| 11210 |
break; |
| 11211 |
} |
| 11212 |
case 134: /* Statistic */ |
| 11213 |
{ |
| 11214 |
StatisticType |
| 11215 |
statistic; |
| 11216 |
|
| 11217 |
statistic=UndefinedStatistic; |
| 11218 |
if (attribute_flag[0] != 0) |
| 11219 |
{ |
| 11220 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 11221 |
&geometry_info); |
| 11222 |
if ((flags & SigmaValue) == 0) |
| 11223 |
geometry_info.sigma=1.0; |
| 11224 |
} |
| 11225 |
if (attribute_flag[1] != 0) |
| 11226 |
geometry_info.rho=argument_list[1].real_reference; |
| 11227 |
if (attribute_flag[2] != 0) |
| 11228 |
geometry_info.sigma=argument_list[2].real_reference; |
| 11229 |
if (attribute_flag[3] != 0) |
| 11230 |
channel=(ChannelType) argument_list[3].integer_reference; |
| 11231 |
if (attribute_flag[4] != 0) |
| 11232 |
statistic=(StatisticType) argument_list[4].integer_reference; |
| 11233 |
channel_mask=SetImageChannelMask(image,channel); |
| 11234 |
image=StatisticImage(image,statistic,(size_t) geometry_info.rho, |
| 11235 |
(size_t) geometry_info.sigma,exception); |
| 11236 |
if (image != (Image *) NULL) |
| 11237 |
(void) SetImageChannelMask(image,channel_mask); |
| 11238 |
break; |
| 11239 |
} |
| 11240 |
case 135: /* Perceptible */ |
| 11241 |
{ |
| 11242 |
double |
| 11243 |
epsilon; |
| 11244 |
|
| 11245 |
epsilon=MagickEpsilon; |
| 11246 |
if (attribute_flag[0] != 0) |
| 11247 |
epsilon=argument_list[0].real_reference; |
| 11248 |
if (attribute_flag[1] != 0) |
| 11249 |
channel=(ChannelType) argument_list[1].integer_reference; |
| 11250 |
channel_mask=SetImageChannelMask(image,channel); |
| 11251 |
(void) PerceptibleImage(image,epsilon,exception); |
| 11252 |
(void) SetImageChannelMask(image,channel_mask); |
| 11253 |
break; |
| 11254 |
} |
| 11255 |
case 136: /* Poly */ |
| 11256 |
{ |
| 11257 |
AV |
| 11258 |
*av; |
| 11259 |
|
| 11260 |
double |
| 11261 |
*terms; |
| 11262 |
|
| 11263 |
size_t |
| 11264 |
number_terms; |
| 11265 |
|
| 11266 |
if (attribute_flag[0] == 0) |
| 11267 |
break; |
| 11268 |
if (attribute_flag[1] != 0) |
| 11269 |
channel=(ChannelType) argument_list[1].integer_reference; |
| 11270 |
av=(AV *) argument_list[0].array_reference; |
| 11271 |
number_terms=(size_t) av_len(av); |
| 11272 |
terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms)); |
| 11273 |
if (terms == (double *) NULL) |
| 11274 |
{ |
| 11275 |
ThrowPerlException(exception,ResourceLimitFatalError, |
| 11276 |
"MemoryAllocationFailed",PackageName); |
| 11277 |
goto PerlException; |
| 11278 |
} |
| 11279 |
for (j=0; j < av_len(av); j++) |
| 11280 |
terms[j]=(double) SvNV(*(av_fetch(av,j,0))); |
| 11281 |
image=PolynomialImage(image,number_terms >> 1,terms,exception); |
| 11282 |
terms=(double *) RelinquishMagickMemory(terms); |
| 11283 |
break; |
| 11284 |
} |
| 11285 |
case 137: /* Grayscale */ |
| 11286 |
{ |
| 11287 |
PixelIntensityMethod |
| 11288 |
method; |
| 11289 |
|
| 11290 |
method=UndefinedPixelIntensityMethod; |
| 11291 |
if (attribute_flag[0] != 0) |
| 11292 |
method=(PixelIntensityMethod) argument_list[0].integer_reference; |
| 11293 |
(void) GrayscaleImage(image,method,exception); |
| 11294 |
break; |
| 11295 |
} |
| 11296 |
case 138: /* Canny */ |
| 11297 |
{ |
| 11298 |
if (attribute_flag[0] != 0) |
| 11299 |
{ |
| 11300 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 11301 |
&geometry_info); |
| 11302 |
if ((flags & SigmaValue) == 0) |
| 11303 |
geometry_info.sigma=1.0; |
| 11304 |
if ((flags & XiValue) == 0) |
| 11305 |
geometry_info.xi=0.10; |
| 11306 |
if ((flags & PsiValue) == 0) |
| 11307 |
geometry_info.psi=0.30; |
| 11308 |
if ((flags & PercentValue) != 0) |
| 11309 |
{ |
| 11310 |
geometry_info.xi/=100.0; |
| 11311 |
geometry_info.psi/=100.0; |
| 11312 |
} |
| 11313 |
} |
| 11314 |
if (attribute_flag[1] != 0) |
| 11315 |
geometry_info.rho=argument_list[1].real_reference; |
| 11316 |
if (attribute_flag[2] != 0) |
| 11317 |
geometry_info.sigma=argument_list[2].real_reference; |
| 11318 |
if (attribute_flag[3] != 0) |
| 11319 |
geometry_info.xi=argument_list[3].real_reference; |
| 11320 |
if (attribute_flag[4] != 0) |
| 11321 |
geometry_info.psi=argument_list[4].real_reference; |
| 11322 |
if (attribute_flag[5] != 0) |
| 11323 |
channel=(ChannelType) argument_list[5].integer_reference; |
| 11324 |
channel_mask=SetImageChannelMask(image,channel); |
| 11325 |
image=CannyEdgeImage(image,geometry_info.rho,geometry_info.sigma, |
| 11326 |
geometry_info.xi,geometry_info.psi,exception); |
| 11327 |
if (image != (Image *) NULL) |
| 11328 |
(void) SetImageChannelMask(image,channel_mask); |
| 11329 |
break; |
| 11330 |
} |
| 11331 |
case 139: /* HoughLine */ |
| 11332 |
{ |
| 11333 |
if (attribute_flag[0] != 0) |
| 11334 |
{ |
| 11335 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 11336 |
&geometry_info); |
| 11337 |
if ((flags & SigmaValue) == 0) |
| 11338 |
geometry_info.sigma=geometry_info.rho; |
| 11339 |
if ((flags & XiValue) == 0) |
| 11340 |
geometry_info.xi=40; |
| 11341 |
} |
| 11342 |
if (attribute_flag[1] != 0) |
| 11343 |
geometry_info.rho=(double) argument_list[1].integer_reference; |
| 11344 |
if (attribute_flag[2] != 0) |
| 11345 |
geometry_info.sigma=(double) argument_list[2].integer_reference; |
| 11346 |
if (attribute_flag[3] != 0) |
| 11347 |
geometry_info.xi=(double) argument_list[3].integer_reference; |
| 11348 |
image=HoughLineImage(image,(size_t) geometry_info.rho,(size_t) |
| 11349 |
geometry_info.sigma,(size_t) geometry_info.xi,exception); |
| 11350 |
break; |
| 11351 |
} |
| 11352 |
case 140: /* MeanShift */ |
| 11353 |
{ |
| 11354 |
if (attribute_flag[0] != 0) |
| 11355 |
{ |
| 11356 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 11357 |
&geometry_info); |
| 11358 |
if ((flags & SigmaValue) == 0) |
| 11359 |
geometry_info.sigma=geometry_info.rho; |
| 11360 |
if ((flags & XiValue) == 0) |
| 11361 |
geometry_info.xi=0.10*QuantumRange; |
| 11362 |
if ((flags & PercentValue) != 0) |
| 11363 |
geometry_info.xi=QuantumRange*geometry_info.xi/100.0; |
| 11364 |
} |
| 11365 |
if (attribute_flag[1] != 0) |
| 11366 |
geometry_info.rho=(double) argument_list[1].integer_reference; |
| 11367 |
if (attribute_flag[2] != 0) |
| 11368 |
geometry_info.sigma=(double) argument_list[2].integer_reference; |
| 11369 |
if (attribute_flag[3] != 0) |
| 11370 |
geometry_info.xi=(double) argument_list[3].integer_reference; |
| 11371 |
image=MeanShiftImage(image,(size_t) geometry_info.rho,(size_t) |
| 11372 |
geometry_info.sigma,geometry_info.xi,exception); |
| 11373 |
break; |
| 11374 |
} |
| 11375 |
case 141: /* Kuwahara */ |
| 11376 |
{ |
| 11377 |
if (attribute_flag[0] != 0) |
| 11378 |
{ |
| 11379 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 11380 |
&geometry_info); |
| 11381 |
if ((flags & SigmaValue) == 0) |
| 11382 |
geometry_info.sigma=geometry_info.rho-0.5; |
| 11383 |
} |
| 11384 |
if (attribute_flag[1] != 0) |
| 11385 |
geometry_info.rho=argument_list[1].real_reference; |
| 11386 |
if (attribute_flag[2] != 0) |
| 11387 |
geometry_info.sigma=argument_list[2].real_reference; |
| 11388 |
if (attribute_flag[3] != 0) |
| 11389 |
channel=(ChannelType) argument_list[3].integer_reference; |
| 11390 |
channel_mask=SetImageChannelMask(image,channel); |
| 11391 |
image=KuwaharaImage(image,geometry_info.rho,geometry_info.sigma, |
| 11392 |
exception); |
| 11393 |
if (image != (Image *) NULL) |
| 11394 |
(void) SetImageChannelMask(image,channel_mask); |
| 11395 |
break; |
| 11396 |
} |
| 11397 |
case 142: /* ConnectedComponents */ |
| 11398 |
{ |
| 11399 |
size_t |
| 11400 |
connectivity; |
| 11401 |
|
| 11402 |
connectivity=4; |
| 11403 |
if (attribute_flag[0] != 0) |
| 11404 |
connectivity=(size_t) argument_list[0].integer_reference; |
| 11405 |
image=ConnectedComponentsImage(image,connectivity, |
| 11406 |
(CCObjectInfo **) NULL,exception); |
| 11407 |
break; |
| 11408 |
} |
| 11409 |
case 143: /* Copy */ |
| 11410 |
{ |
| 11411 |
Image |
| 11412 |
*source_image; |
| 11413 |
|
| 11414 |
OffsetInfo |
| 11415 |
offset; |
| 11416 |
|
| 11417 |
RectangleInfo |
| 11418 |
offset_geometry; |
| 11419 |
|
| 11420 |
source_image=image; |
| 11421 |
if (attribute_flag[0] != 0) |
| 11422 |
source_image=argument_list[0].image_reference; |
| 11423 |
SetGeometry(source_image,&geometry); |
| 11424 |
if (attribute_flag[1] != 0) |
| 11425 |
flags=ParseGravityGeometry(source_image, |
| 11426 |
argument_list[1].string_reference,&geometry,exception); |
| 11427 |
if (attribute_flag[2] != 0) |
| 11428 |
geometry.width=(size_t) argument_list[2].integer_reference; |
| 11429 |
if (attribute_flag[3] != 0) |
| 11430 |
geometry.height=(size_t) argument_list[3].integer_reference; |
| 11431 |
if (attribute_flag[4] != 0) |
| 11432 |
geometry.x=argument_list[4].integer_reference; |
| 11433 |
if (attribute_flag[5] != 0) |
| 11434 |
geometry.y=argument_list[5].integer_reference; |
| 11435 |
if (attribute_flag[6] != 0) |
| 11436 |
image->gravity=(GravityType) argument_list[6].integer_reference; |
| 11437 |
SetGeometry(image,&offset_geometry); |
| 11438 |
if (attribute_flag[7] != 0) |
| 11439 |
flags=ParseGravityGeometry(image,argument_list[7].string_reference, |
| 11440 |
&offset_geometry,exception); |
| 11441 |
offset.x=offset_geometry.x; |
| 11442 |
offset.y=offset_geometry.y; |
| 11443 |
if (attribute_flag[8] != 0) |
| 11444 |
offset.x=argument_list[8].integer_reference; |
| 11445 |
if (attribute_flag[9] != 0) |
| 11446 |
offset.y=argument_list[9].integer_reference; |
| 11447 |
(void) CopyImagePixels(image,source_image,&geometry,&offset, |
| 11448 |
exception); |
| 11449 |
break; |
| 11450 |
} |
| 11451 |
case 144: /* Color */ |
| 11452 |
{ |
| 11453 |
PixelInfo |
| 11454 |
color; |
| 11455 |
|
| 11456 |
(void) QueryColorCompliance("none",AllCompliance,&color,exception); |
| 11457 |
if (attribute_flag[0] != 0) |
| 11458 |
(void) QueryColorCompliance(argument_list[0].string_reference, |
| 11459 |
AllCompliance,&color,exception); |
| 11460 |
(void) SetImageColor(image,&color,exception); |
| 11461 |
break; |
| 11462 |
} |
| 11463 |
case 145: /* WaveletDenoise */ |
| 11464 |
{ |
| 11465 |
if (attribute_flag[0] != 0) |
| 11466 |
{ |
| 11467 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 11468 |
&geometry_info); |
| 11469 |
if ((flags & PercentValue) != 0) |
| 11470 |
{ |
| 11471 |
geometry_info.rho=QuantumRange*geometry_info.rho/100.0; |
| 11472 |
geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0; |
| 11473 |
} |
| 11474 |
if ((flags & SigmaValue) == 0) |
| 11475 |
geometry_info.sigma=0.0; |
| 11476 |
} |
| 11477 |
if (attribute_flag[1] != 0) |
| 11478 |
geometry_info.rho=argument_list[1].real_reference; |
| 11479 |
if (attribute_flag[2] != 0) |
| 11480 |
geometry_info.sigma=argument_list[2].real_reference; |
| 11481 |
if (attribute_flag[3] != 0) |
| 11482 |
channel=(ChannelType) argument_list[3].integer_reference; |
| 11483 |
channel_mask=SetImageChannelMask(image,channel); |
| 11484 |
image=WaveletDenoiseImage(image,geometry_info.rho,geometry_info.sigma, |
| 11485 |
exception); |
| 11486 |
if (image != (Image *) NULL) |
| 11487 |
(void) SetImageChannelMask(image,channel_mask); |
| 11488 |
break; |
| 11489 |
} |
| 11490 |
case 146: /* Colorspace */ |
| 11491 |
{ |
| 11492 |
ColorspaceType |
| 11493 |
colorspace; |
| 11494 |
|
| 11495 |
colorspace=sRGBColorspace; |
| 11496 |
if (attribute_flag[0] != 0) |
| 11497 |
colorspace=(ColorspaceType) argument_list[0].integer_reference; |
| 11498 |
(void) TransformImageColorspace(image,colorspace,exception); |
| 11499 |
break; |
| 11500 |
} |
| 11501 |
case 147: /* AutoThreshold */ |
| 11502 |
{ |
| 11503 |
AutoThresholdMethod |
| 11504 |
method; |
| 11505 |
|
| 11506 |
method=UndefinedThresholdMethod; |
| 11507 |
if (attribute_flag[0] != 0) |
| 11508 |
method=(AutoThresholdMethod) argument_list[0].integer_reference; |
| 11509 |
(void) AutoThresholdImage(image,method,exception); |
| 11510 |
break; |
| 11511 |
} |
| 11512 |
case 148: /* RangeThreshold */ |
| 11513 |
{ |
| 11514 |
if (attribute_flag[0] != 0) |
| 11515 |
{ |
| 11516 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 11517 |
&geometry_info); |
| 11518 |
if ((flags & SigmaValue) == 0) |
| 11519 |
geometry_info.sigma=geometry_info.rho; |
| 11520 |
if ((flags & XiValue) == 0) |
| 11521 |
geometry_info.xi=geometry_info.sigma; |
| 11522 |
if ((flags & PsiValue) == 0) |
| 11523 |
geometry_info.psi=geometry_info.xi; |
| 11524 |
} |
| 11525 |
if (attribute_flag[1] != 0) |
| 11526 |
geometry_info.rho=argument_list[1].real_reference; |
| 11527 |
if (attribute_flag[2] != 0) |
| 11528 |
geometry_info.sigma=argument_list[2].real_reference; |
| 11529 |
if (attribute_flag[3] != 0) |
| 11530 |
geometry_info.xi=argument_list[3].real_reference; |
| 11531 |
if (attribute_flag[4] != 0) |
| 11532 |
geometry_info.psi=argument_list[4].real_reference; |
| 11533 |
if (attribute_flag[5] != 0) |
| 11534 |
channel=(ChannelType) argument_list[5].integer_reference; |
| 11535 |
channel_mask=SetImageChannelMask(image,channel); |
| 11536 |
(void) RangeThresholdImage(image,geometry_info.rho, |
| 11537 |
geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
| 11538 |
if (image != (Image *) NULL) |
| 11539 |
(void) SetImageChannelMask(image,channel_mask); |
| 11540 |
break; |
| 11541 |
} |
| 11542 |
case 149: /* CLAHE */ |
| 11543 |
{ |
| 11544 |
if (attribute_flag[0] != 0) |
| 11545 |
{ |
| 11546 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 11547 |
&geometry_info); |
| 11548 |
flags=ParseRegionGeometry(image,argument_list[0].string_reference, |
| 11549 |
&geometry,exception); |
| 11550 |
} |
| 11551 |
if (attribute_flag[1] != 0) |
| 11552 |
geometry.width=(size_t) argument_list[1].integer_reference; |
| 11553 |
if (attribute_flag[2] != 0) |
| 11554 |
geometry.height=(size_t) argument_list[2].integer_reference; |
| 11555 |
if (attribute_flag[3] != 0) |
| 11556 |
geometry.x=argument_list[3].integer_reference; |
| 11557 |
if (attribute_flag[4] != 0) |
| 11558 |
geometry_info.psi=argument_list[4].real_reference; |
| 11559 |
(void) CLAHEImage(image,geometry.width,geometry.height,(size_t) |
| 11560 |
geometry.x,(size_t) geometry_info.psi,exception); |
| 11561 |
break; |
| 11562 |
} |
| 11563 |
case 150: /* Kmeans */ |
| 11564 |
{ |
| 11565 |
if (attribute_flag[0] != 0) |
| 11566 |
{ |
| 11567 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 11568 |
&geometry_info); |
| 11569 |
if ((flags & SigmaValue) == 0) |
| 11570 |
geometry_info.sigma=100.0; |
| 11571 |
if ((flags & XiValue) == 0) |
| 11572 |
geometry_info.xi=0.01; |
| 11573 |
} |
| 11574 |
if (attribute_flag[1] != 0) |
| 11575 |
geometry_info.rho=argument_list[1].integer_reference; |
| 11576 |
if (attribute_flag[2] != 0) |
| 11577 |
geometry_info.sigma=argument_list[2].integer_reference; |
| 11578 |
if (attribute_flag[3] != 0) |
| 11579 |
geometry_info.xi=(ChannelType) argument_list[3].real_reference; |
| 11580 |
(void) KmeansImage(image,geometry_info.rho,geometry_info.sigma, |
| 11581 |
geometry_info.xi,exception); |
| 11582 |
break; |
| 11583 |
} |
| 11584 |
case 151: /* ColorThreshold */ |
| 11585 |
{ |
| 11586 |
PixelInfo |
| 11587 |
start_color, |
| 11588 |
stop_color; |
| 11589 |
|
| 11590 |
(void) QueryColorCompliance("black",AllCompliance,&start_color, |
| 11591 |
exception); |
| 11592 |
(void) QueryColorCompliance("white",AllCompliance,&stop_color, |
| 11593 |
exception); |
| 11594 |
if (attribute_flag[0] != 0) |
| 11595 |
(void) QueryColorCompliance(argument_list[0].string_reference, |
| 11596 |
AllCompliance,&start_color,exception); |
| 11597 |
if (attribute_flag[1] != 0) |
| 11598 |
(void) QueryColorCompliance(argument_list[1].string_reference, |
| 11599 |
AllCompliance,&stop_color,exception); |
| 11600 |
channel_mask=SetImageChannelMask(image,channel); |
| 11601 |
(void) ColorThresholdImage(image,&start_color,&stop_color,exception); |
| 11602 |
(void) SetImageChannelMask(image,channel_mask); |
| 11603 |
break; |
| 11604 |
} |
| 11605 |
case 152: /* WhiteBalance */ |
| 11606 |
{ |
| 11607 |
(void) WhiteBalanceImage(image,exception); |
| 11608 |
break; |
| 11609 |
} |
| 11610 |
case 153: /* BilateralBlur */ |
| 11611 |
{ |
| 11612 |
if (attribute_flag[0] != 0) |
| 11613 |
{ |
| 11614 |
flags=ParseGeometry(argument_list[0].string_reference, |
| 11615 |
&geometry_info); |
| 11616 |
if ((flags & SigmaValue) == 0) |
| 11617 |
geometry_info.sigma=geometry_info.rho; |
| 11618 |
if ((flags & XiValue) == 0) |
| 11619 |
geometry_info.xi=1.0*sqrt(geometry_info.rho*geometry_info.rho+ |
| 11620 |
geometry_info.sigma*geometry_info.sigma); |
| 11621 |
if ((flags & PsiValue) == 0) |
| 11622 |
geometry_info.xi=0.25*sqrt(geometry_info.rho*geometry_info.rho+ |
| 11623 |
geometry_info.sigma*geometry_info.sigma); |
| 11624 |
} |
| 11625 |
if (attribute_flag[1] != 0) |
| 11626 |
geometry_info.rho=(double) argument_list[1].integer_reference; |
| 11627 |
if (attribute_flag[2] != 0) |
| 11628 |
geometry_info.sigma=(double) argument_list[2].integer_reference; |
| 11629 |
if (attribute_flag[3] != 0) |
| 11630 |
geometry_info.xi=argument_list[3].real_reference; |
| 11631 |
if (attribute_flag[4] != 0) |
| 11632 |
geometry_info.psi=argument_list[4].real_reference; |
| 11633 |
if (attribute_flag[5] != 0) |
| 11634 |
channel=(ChannelType) argument_list[5].integer_reference; |
| 11635 |
channel_mask=SetImageChannelMask(image,channel); |
| 11636 |
image=BilateralBlurImage(image,(size_t) geometry_info.rho,(size_t) |
| 11637 |
geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); |
| 11638 |
if (image != (Image *) NULL) |
| 11639 |
(void) SetImageChannelMask(image,channel_mask); |
| 11640 |
break; |
| 11641 |
} |
| 11642 |
case 154: /* SortPixels */ |
| 11643 |
{ |
| 11644 |
(void) SortImagePixels(image,exception); |
| 11645 |
break; |
| 11646 |
} |
| 11647 |
case 155: /* Integral */ |
| 11648 |
{ |
| 11649 |
image=IntegralImage(image,exception); |
| 11650 |
break; |
| 11651 |
} |
| 11652 |
} |
| 11653 |
if (next != (Image *) NULL) |
| 11654 |
(void) CatchImageException(next); |
| 11655 |
if ((region_info.width*region_info.height) != 0) |
| 11656 |
(void) SetImageRegionMask(image,WritePixelMask,(const RectangleInfo *) |
| 11657 |
NULL,exception); |
| 11658 |
if (image != (Image *) NULL) |
| 11659 |
{ |
| 11660 |
number_images++; |
| 11661 |
if (next && (next != image)) |
| 11662 |
{ |
| 11663 |
image->next=next->next; |
| 11664 |
if (image->next != (Image *) NULL) |
| 11665 |
image->next->previous=image; |
| 11666 |
DeleteImageFromRegistry(*pv,next); |
| 11667 |
} |
| 11668 |
sv_setiv(*pv,PTR2IV(image)); |
| 11669 |
next=image; |
| 11670 |
} |
| 11671 |
if (*pv) |
| 11672 |
pv++; |
| 11673 |
} |
| 11674 |
|
| 11675 |
PerlException: |
| 11676 |
if (reference_vector) |
| 11677 |
reference_vector=(SV **) RelinquishMagickMemory(reference_vector); |
| 11678 |
InheritPerlException(exception,perl_exception); |
| 11679 |
exception=DestroyExceptionInfo(exception); |
| 11680 |
sv_setiv(perl_exception,(IV) number_images); |
| 11681 |
SvPOK_on(perl_exception); |
| 11682 |
ST(0)=sv_2mortal(perl_exception); |
| 11683 |
XSRETURN(1); |
| 11684 |
} |
| 11685 |
|
| 11686 |
# |
| 11687 |
############################################################################### |
| 11688 |
# # |
| 11689 |
# # |
| 11690 |
# # |
| 11691 |
# M o n t a g e # |
| 11692 |
# # |
| 11693 |
# # |
| 11694 |
# # |
| 11695 |
############################################################################### |
| 11696 |
# |
| 11697 |
# |
| 11698 |
void |
| 11699 |
Montage(ref,...) |
| 11700 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 11701 |
ALIAS: |
| 11702 |
MontageImage = 1 |
| 11703 |
montage = 2 |
| 11704 |
montageimage = 3 |
| 11705 |
PPCODE: |
| 11706 |
{ |
| 11707 |
AV |
| 11708 |
*av; |
| 11709 |
|
| 11710 |
char |
| 11711 |
*attribute; |
| 11712 |
|
| 11713 |
ExceptionInfo |
| 11714 |
*exception; |
| 11715 |
|
| 11716 |
HV |
| 11717 |
*hv; |
| 11718 |
|
| 11719 |
Image |
| 11720 |
*image, |
| 11721 |
*next; |
| 11722 |
|
| 11723 |
MontageInfo |
| 11724 |
*montage_info; |
| 11725 |
|
| 11726 |
PixelInfo |
| 11727 |
transparent_color; |
| 11728 |
|
| 11729 |
ssize_t |
| 11730 |
i, |
| 11731 |
sp; |
| 11732 |
|
| 11733 |
struct PackageInfo |
| 11734 |
*info; |
| 11735 |
|
| 11736 |
SV |
| 11737 |
*av_reference, |
| 11738 |
*perl_exception, |
| 11739 |
*reference, |
| 11740 |
*rv, |
| 11741 |
*sv; |
| 11742 |
|
| 11743 |
PERL_UNUSED_VAR(ref); |
| 11744 |
PERL_UNUSED_VAR(ix); |
| 11745 |
exception=AcquireExceptionInfo(); |
| 11746 |
perl_exception=newSVpv("",0); |
| 11747 |
sv=NULL; |
| 11748 |
attribute=NULL; |
| 11749 |
if (sv_isobject(ST(0)) == 0) |
| 11750 |
{ |
| 11751 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 11752 |
PackageName); |
| 11753 |
goto PerlException; |
| 11754 |
} |
| 11755 |
reference=SvRV(ST(0)); |
| 11756 |
hv=SvSTASH(reference); |
| 11757 |
av=newAV(); |
| 11758 |
av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv)); |
| 11759 |
SvREFCNT_dec(av); |
| 11760 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 11761 |
if (image == (Image *) NULL) |
| 11762 |
{ |
| 11763 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 11764 |
PackageName); |
| 11765 |
goto PerlException; |
| 11766 |
} |
| 11767 |
/* |
| 11768 |
Get options. |
| 11769 |
*/ |
| 11770 |
info=GetPackageInfo(aTHX_ (void *) av,info,exception); |
| 11771 |
montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL); |
| 11772 |
(void) QueryColorCompliance("none",AllCompliance,&transparent_color, |
| 11773 |
exception); |
| 11774 |
for (i=2; i < items; i+=2) |
| 11775 |
{ |
| 11776 |
attribute=(char *) SvPV(ST(i-1),na); |
| 11777 |
switch (*attribute) |
| 11778 |
{ |
| 11779 |
case 'B': |
| 11780 |
case 'b': |
| 11781 |
{ |
| 11782 |
if (LocaleCompare(attribute,"background") == 0) |
| 11783 |
{ |
| 11784 |
(void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance, |
| 11785 |
&montage_info->background_color,exception); |
| 11786 |
for (next=image; next; next=next->next) |
| 11787 |
next->background_color=montage_info->background_color; |
| 11788 |
break; |
| 11789 |
} |
| 11790 |
if (LocaleCompare(attribute,"border") == 0) |
| 11791 |
{ |
| 11792 |
montage_info->border_width=(size_t) SvIV(ST(i)); |
| 11793 |
break; |
| 11794 |
} |
| 11795 |
if (LocaleCompare(attribute,"bordercolor") == 0) |
| 11796 |
{ |
| 11797 |
(void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance, |
| 11798 |
&montage_info->border_color,exception); |
| 11799 |
for (next=image; next; next=next->next) |
| 11800 |
next->border_color=montage_info->border_color; |
| 11801 |
break; |
| 11802 |
} |
| 11803 |
if (LocaleCompare(attribute,"borderwidth") == 0) |
| 11804 |
{ |
| 11805 |
montage_info->border_width=(size_t) SvIV(ST(i)); |
| 11806 |
break; |
| 11807 |
} |
| 11808 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 11809 |
attribute); |
| 11810 |
break; |
| 11811 |
} |
| 11812 |
case 'C': |
| 11813 |
case 'c': |
| 11814 |
{ |
| 11815 |
if (LocaleCompare(attribute,"compose") == 0) |
| 11816 |
{ |
| 11817 |
sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption( |
| 11818 |
MagickComposeOptions,MagickFalse,SvPV(ST(i),na)); |
| 11819 |
if (sp < 0) |
| 11820 |
{ |
| 11821 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 11822 |
SvPV(ST(i),na)); |
| 11823 |
break; |
| 11824 |
} |
| 11825 |
for (next=image; next; next=next->next) |
| 11826 |
next->compose=(CompositeOperator) sp; |
| 11827 |
break; |
| 11828 |
} |
| 11829 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 11830 |
attribute); |
| 11831 |
break; |
| 11832 |
} |
| 11833 |
case 'F': |
| 11834 |
case 'f': |
| 11835 |
{ |
| 11836 |
if (LocaleCompare(attribute,"fill") == 0) |
| 11837 |
{ |
| 11838 |
(void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance, |
| 11839 |
&montage_info->fill,exception); |
| 11840 |
break; |
| 11841 |
} |
| 11842 |
if (LocaleCompare(attribute,"font") == 0) |
| 11843 |
{ |
| 11844 |
(void) CloneString(&montage_info->font,SvPV(ST(i),na)); |
| 11845 |
break; |
| 11846 |
} |
| 11847 |
if (LocaleCompare(attribute,"frame") == 0) |
| 11848 |
{ |
| 11849 |
char |
| 11850 |
*p; |
| 11851 |
|
| 11852 |
p=SvPV(ST(i),na); |
| 11853 |
if (IsGeometry(p) == MagickFalse) |
| 11854 |
{ |
| 11855 |
ThrowPerlException(exception,OptionError,"MissingGeometry", |
| 11856 |
p); |
| 11857 |
break; |
| 11858 |
} |
| 11859 |
(void) CloneString(&montage_info->frame,p); |
| 11860 |
if (*p == '\0') |
| 11861 |
montage_info->frame=(char *) NULL; |
| 11862 |
break; |
| 11863 |
} |
| 11864 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 11865 |
attribute); |
| 11866 |
break; |
| 11867 |
} |
| 11868 |
case 'G': |
| 11869 |
case 'g': |
| 11870 |
{ |
| 11871 |
if (LocaleCompare(attribute,"geometry") == 0) |
| 11872 |
{ |
| 11873 |
char |
| 11874 |
*p; |
| 11875 |
|
| 11876 |
p=SvPV(ST(i),na); |
| 11877 |
if (IsGeometry(p) == MagickFalse) |
| 11878 |
{ |
| 11879 |
ThrowPerlException(exception,OptionError,"MissingGeometry", |
| 11880 |
p); |
| 11881 |
break; |
| 11882 |
} |
| 11883 |
(void) CloneString(&montage_info->geometry,p); |
| 11884 |
if (*p == '\0') |
| 11885 |
montage_info->geometry=(char *) NULL; |
| 11886 |
break; |
| 11887 |
} |
| 11888 |
if (LocaleCompare(attribute,"gravity") == 0) |
| 11889 |
{ |
| 11890 |
ssize_t |
| 11891 |
in; |
| 11892 |
|
| 11893 |
in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption( |
| 11894 |
MagickGravityOptions,MagickFalse,SvPV(ST(i),na)); |
| 11895 |
if (in < 0) |
| 11896 |
{ |
| 11897 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 11898 |
SvPV(ST(i),na)); |
| 11899 |
return; |
| 11900 |
} |
| 11901 |
montage_info->gravity=(GravityType) in; |
| 11902 |
for (next=image; next; next=next->next) |
| 11903 |
next->gravity=(GravityType) in; |
| 11904 |
break; |
| 11905 |
} |
| 11906 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 11907 |
attribute); |
| 11908 |
break; |
| 11909 |
} |
| 11910 |
case 'L': |
| 11911 |
case 'l': |
| 11912 |
{ |
| 11913 |
if (LocaleCompare(attribute,"label") == 0) |
| 11914 |
{ |
| 11915 |
for (next=image; next; next=next->next) |
| 11916 |
(void) SetImageProperty(next,"label",InterpretImageProperties( |
| 11917 |
info ? info->image_info : (ImageInfo *) NULL,next, |
| 11918 |
SvPV(ST(i),na),exception),exception); |
| 11919 |
break; |
| 11920 |
} |
| 11921 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 11922 |
attribute); |
| 11923 |
break; |
| 11924 |
} |
| 11925 |
case 'M': |
| 11926 |
case 'm': |
| 11927 |
{ |
| 11928 |
if (LocaleCompare(attribute,"mattecolor") == 0) |
| 11929 |
{ |
| 11930 |
(void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance, |
| 11931 |
&montage_info->alpha_color,exception); |
| 11932 |
for (next=image; next; next=next->next) |
| 11933 |
next->alpha_color=montage_info->alpha_color; |
| 11934 |
break; |
| 11935 |
} |
| 11936 |
if (LocaleCompare(attribute,"mode") == 0) |
| 11937 |
{ |
| 11938 |
ssize_t |
| 11939 |
in; |
| 11940 |
|
| 11941 |
in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption( |
| 11942 |
MagickModeOptions,MagickFalse,SvPV(ST(i),na)); |
| 11943 |
switch (in) |
| 11944 |
{ |
| 11945 |
default: |
| 11946 |
{ |
| 11947 |
ThrowPerlException(exception,OptionError, |
| 11948 |
"UnrecognizedModeType",SvPV(ST(i),na)); |
| 11949 |
break; |
| 11950 |
} |
| 11951 |
case FrameMode: |
| 11952 |
{ |
| 11953 |
(void) CloneString(&montage_info->frame,"15x15+3+3"); |
| 11954 |
montage_info->shadow=MagickTrue; |
| 11955 |
break; |
| 11956 |
} |
| 11957 |
case UnframeMode: |
| 11958 |
{ |
| 11959 |
montage_info->frame=(char *) NULL; |
| 11960 |
montage_info->shadow=MagickFalse; |
| 11961 |
montage_info->border_width=0; |
| 11962 |
break; |
| 11963 |
} |
| 11964 |
case ConcatenateMode: |
| 11965 |
{ |
| 11966 |
montage_info->frame=(char *) NULL; |
| 11967 |
montage_info->shadow=MagickFalse; |
| 11968 |
(void) CloneString(&montage_info->geometry,"+0+0"); |
| 11969 |
montage_info->border_width=0; |
| 11970 |
} |
| 11971 |
} |
| 11972 |
break; |
| 11973 |
} |
| 11974 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 11975 |
attribute); |
| 11976 |
break; |
| 11977 |
} |
| 11978 |
case 'P': |
| 11979 |
case 'p': |
| 11980 |
{ |
| 11981 |
if (LocaleCompare(attribute,"pointsize") == 0) |
| 11982 |
{ |
| 11983 |
montage_info->pointsize=SvIV(ST(i)); |
| 11984 |
break; |
| 11985 |
} |
| 11986 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 11987 |
attribute); |
| 11988 |
break; |
| 11989 |
} |
| 11990 |
case 'S': |
| 11991 |
case 's': |
| 11992 |
{ |
| 11993 |
if (LocaleCompare(attribute,"shadow") == 0) |
| 11994 |
{ |
| 11995 |
sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption( |
| 11996 |
MagickBooleanOptions,MagickFalse,SvPV(ST(i),na)); |
| 11997 |
if (sp < 0) |
| 11998 |
{ |
| 11999 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 12000 |
SvPV(ST(i),na)); |
| 12001 |
break; |
| 12002 |
} |
| 12003 |
montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse; |
| 12004 |
break; |
| 12005 |
} |
| 12006 |
if (LocaleCompare(attribute,"stroke") == 0) |
| 12007 |
{ |
| 12008 |
(void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance, |
| 12009 |
&montage_info->stroke,exception); |
| 12010 |
break; |
| 12011 |
} |
| 12012 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 12013 |
attribute); |
| 12014 |
break; |
| 12015 |
} |
| 12016 |
case 'T': |
| 12017 |
case 't': |
| 12018 |
{ |
| 12019 |
if (LocaleCompare(attribute,"texture") == 0) |
| 12020 |
{ |
| 12021 |
(void) CloneString(&montage_info->texture,SvPV(ST(i),na)); |
| 12022 |
break; |
| 12023 |
} |
| 12024 |
if (LocaleCompare(attribute,"tile") == 0) |
| 12025 |
{ |
| 12026 |
char *p=SvPV(ST(i),na); |
| 12027 |
if (IsGeometry(p) == MagickFalse) |
| 12028 |
{ |
| 12029 |
ThrowPerlException(exception,OptionError,"MissingGeometry", |
| 12030 |
p); |
| 12031 |
break; |
| 12032 |
} |
| 12033 |
(void) CloneString(&montage_info->tile,p); |
| 12034 |
if (*p == '\0') |
| 12035 |
montage_info->tile=(char *) NULL; |
| 12036 |
break; |
| 12037 |
} |
| 12038 |
if (LocaleCompare(attribute,"title") == 0) |
| 12039 |
{ |
| 12040 |
(void) CloneString(&montage_info->title,SvPV(ST(i),na)); |
| 12041 |
break; |
| 12042 |
} |
| 12043 |
if (LocaleCompare(attribute,"transparent") == 0) |
| 12044 |
{ |
| 12045 |
PixelInfo |
| 12046 |
transparent_color; |
| 12047 |
|
| 12048 |
QueryColorCompliance(SvPV(ST(i),na),AllCompliance, |
| 12049 |
&transparent_color,exception); |
| 12050 |
for (next=image; next; next=next->next) |
| 12051 |
(void) TransparentPaintImage(next,&transparent_color, |
| 12052 |
TransparentAlpha,MagickFalse,exception); |
| 12053 |
break; |
| 12054 |
} |
| 12055 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 12056 |
attribute); |
| 12057 |
break; |
| 12058 |
} |
| 12059 |
default: |
| 12060 |
{ |
| 12061 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 12062 |
attribute); |
| 12063 |
break; |
| 12064 |
} |
| 12065 |
} |
| 12066 |
} |
| 12067 |
image=MontageImageList(info->image_info,montage_info,image,exception); |
| 12068 |
montage_info=DestroyMontageInfo(montage_info); |
| 12069 |
if (image == (Image *) NULL) |
| 12070 |
goto PerlException; |
| 12071 |
if (transparent_color.alpha != TransparentAlpha) |
| 12072 |
for (next=image; next; next=next->next) |
| 12073 |
(void) TransparentPaintImage(next,&transparent_color, |
| 12074 |
TransparentAlpha,MagickFalse,exception); |
| 12075 |
for ( ; image; image=image->next) |
| 12076 |
{ |
| 12077 |
AddImageToRegistry(sv,image); |
| 12078 |
rv=newRV(sv); |
| 12079 |
av_push(av,sv_bless(rv,hv)); |
| 12080 |
SvREFCNT_dec(sv); |
| 12081 |
} |
| 12082 |
exception=DestroyExceptionInfo(exception); |
| 12083 |
ST(0)=av_reference; |
| 12084 |
SvREFCNT_dec(perl_exception); |
| 12085 |
XSRETURN(1); |
| 12086 |
|
| 12087 |
PerlException: |
| 12088 |
InheritPerlException(exception,perl_exception); |
| 12089 |
exception=DestroyExceptionInfo(exception); |
| 12090 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 12091 |
SvPOK_on(perl_exception); |
| 12092 |
ST(0)=sv_2mortal(perl_exception); |
| 12093 |
XSRETURN(1); |
| 12094 |
} |
| 12095 |
|
| 12096 |
# |
| 12097 |
############################################################################### |
| 12098 |
# # |
| 12099 |
# # |
| 12100 |
# # |
| 12101 |
# M o r p h # |
| 12102 |
# # |
| 12103 |
# # |
| 12104 |
# # |
| 12105 |
############################################################################### |
| 12106 |
# |
| 12107 |
# |
| 12108 |
void |
| 12109 |
Morph(ref,...) |
| 12110 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 12111 |
ALIAS: |
| 12112 |
MorphImage = 1 |
| 12113 |
morph = 2 |
| 12114 |
morphimage = 3 |
| 12115 |
PPCODE: |
| 12116 |
{ |
| 12117 |
AV |
| 12118 |
*av; |
| 12119 |
|
| 12120 |
char |
| 12121 |
*attribute; |
| 12122 |
|
| 12123 |
ExceptionInfo |
| 12124 |
*exception; |
| 12125 |
|
| 12126 |
HV |
| 12127 |
*hv; |
| 12128 |
|
| 12129 |
Image |
| 12130 |
*image; |
| 12131 |
|
| 12132 |
ssize_t |
| 12133 |
i, |
| 12134 |
number_frames; |
| 12135 |
|
| 12136 |
struct PackageInfo |
| 12137 |
*info; |
| 12138 |
|
| 12139 |
SV |
| 12140 |
*av_reference, |
| 12141 |
*perl_exception, |
| 12142 |
*reference, |
| 12143 |
*rv, |
| 12144 |
*sv; |
| 12145 |
|
| 12146 |
PERL_UNUSED_VAR(ref); |
| 12147 |
PERL_UNUSED_VAR(ix); |
| 12148 |
exception=AcquireExceptionInfo(); |
| 12149 |
perl_exception=newSVpv("",0); |
| 12150 |
sv=NULL; |
| 12151 |
av=NULL; |
| 12152 |
attribute=NULL; |
| 12153 |
if (sv_isobject(ST(0)) == 0) |
| 12154 |
{ |
| 12155 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 12156 |
PackageName); |
| 12157 |
goto PerlException; |
| 12158 |
} |
| 12159 |
reference=SvRV(ST(0)); |
| 12160 |
hv=SvSTASH(reference); |
| 12161 |
av=newAV(); |
| 12162 |
av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv)); |
| 12163 |
SvREFCNT_dec(av); |
| 12164 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 12165 |
if (image == (Image *) NULL) |
| 12166 |
{ |
| 12167 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 12168 |
PackageName); |
| 12169 |
goto PerlException; |
| 12170 |
} |
| 12171 |
info=GetPackageInfo(aTHX_ (void *) av,info,exception); |
| 12172 |
/* |
| 12173 |
Get attribute. |
| 12174 |
*/ |
| 12175 |
number_frames=30; |
| 12176 |
for (i=2; i < items; i+=2) |
| 12177 |
{ |
| 12178 |
attribute=(char *) SvPV(ST(i-1),na); |
| 12179 |
switch (*attribute) |
| 12180 |
{ |
| 12181 |
case 'F': |
| 12182 |
case 'f': |
| 12183 |
{ |
| 12184 |
if (LocaleCompare(attribute,"frames") == 0) |
| 12185 |
{ |
| 12186 |
number_frames=SvIV(ST(i)); |
| 12187 |
break; |
| 12188 |
} |
| 12189 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 12190 |
attribute); |
| 12191 |
break; |
| 12192 |
} |
| 12193 |
default: |
| 12194 |
{ |
| 12195 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 12196 |
attribute); |
| 12197 |
break; |
| 12198 |
} |
| 12199 |
} |
| 12200 |
} |
| 12201 |
image=MorphImages(image,(size_t) number_frames,exception); |
| 12202 |
if (image == (Image *) NULL) |
| 12203 |
goto PerlException; |
| 12204 |
for ( ; image; image=image->next) |
| 12205 |
{ |
| 12206 |
AddImageToRegistry(sv,image); |
| 12207 |
rv=newRV(sv); |
| 12208 |
av_push(av,sv_bless(rv,hv)); |
| 12209 |
SvREFCNT_dec(sv); |
| 12210 |
} |
| 12211 |
exception=DestroyExceptionInfo(exception); |
| 12212 |
ST(0)=av_reference; |
| 12213 |
SvREFCNT_dec(perl_exception); /* can't return warning messages */ |
| 12214 |
XSRETURN(1); |
| 12215 |
|
| 12216 |
PerlException: |
| 12217 |
InheritPerlException(exception,perl_exception); |
| 12218 |
exception=DestroyExceptionInfo(exception); |
| 12219 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 12220 |
SvPOK_on(perl_exception); |
| 12221 |
ST(0)=sv_2mortal(perl_exception); |
| 12222 |
XSRETURN(1); |
| 12223 |
} |
| 12224 |
|
| 12225 |
# |
| 12226 |
############################################################################### |
| 12227 |
# # |
| 12228 |
# # |
| 12229 |
# # |
| 12230 |
# M o s a i c # |
| 12231 |
# # |
| 12232 |
# # |
| 12233 |
# # |
| 12234 |
############################################################################### |
| 12235 |
# |
| 12236 |
# |
| 12237 |
void |
| 12238 |
Mosaic(ref) |
| 12239 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 12240 |
ALIAS: |
| 12241 |
MosaicImage = 1 |
| 12242 |
mosaic = 2 |
| 12243 |
mosaicimage = 3 |
| 12244 |
PPCODE: |
| 12245 |
{ |
| 12246 |
AV |
| 12247 |
*av; |
| 12248 |
|
| 12249 |
ExceptionInfo |
| 12250 |
*exception; |
| 12251 |
|
| 12252 |
HV |
| 12253 |
*hv; |
| 12254 |
|
| 12255 |
Image |
| 12256 |
*image; |
| 12257 |
|
| 12258 |
struct PackageInfo |
| 12259 |
*info; |
| 12260 |
|
| 12261 |
SV |
| 12262 |
*perl_exception, |
| 12263 |
*reference, |
| 12264 |
*rv, |
| 12265 |
*sv; |
| 12266 |
|
| 12267 |
PERL_UNUSED_VAR(ref); |
| 12268 |
PERL_UNUSED_VAR(ix); |
| 12269 |
exception=AcquireExceptionInfo(); |
| 12270 |
perl_exception=newSVpv("",0); |
| 12271 |
sv=NULL; |
| 12272 |
if (sv_isobject(ST(0)) == 0) |
| 12273 |
{ |
| 12274 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 12275 |
PackageName); |
| 12276 |
goto PerlException; |
| 12277 |
} |
| 12278 |
reference=SvRV(ST(0)); |
| 12279 |
hv=SvSTASH(reference); |
| 12280 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 12281 |
if (image == (Image *) NULL) |
| 12282 |
{ |
| 12283 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 12284 |
PackageName); |
| 12285 |
goto PerlException; |
| 12286 |
} |
| 12287 |
image=MergeImageLayers(image,MosaicLayer,exception); |
| 12288 |
/* |
| 12289 |
Create blessed Perl array for the returned image. |
| 12290 |
*/ |
| 12291 |
av=newAV(); |
| 12292 |
ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv)); |
| 12293 |
SvREFCNT_dec(av); |
| 12294 |
AddImageToRegistry(sv,image); |
| 12295 |
rv=newRV(sv); |
| 12296 |
av_push(av,sv_bless(rv,hv)); |
| 12297 |
SvREFCNT_dec(sv); |
| 12298 |
(void) CopyMagickString(info->image_info->filename,image->filename, |
| 12299 |
MagickPathExtent); |
| 12300 |
SetImageInfo(info->image_info,0,exception); |
| 12301 |
exception=DestroyExceptionInfo(exception); |
| 12302 |
SvREFCNT_dec(perl_exception); |
| 12303 |
XSRETURN(1); |
| 12304 |
|
| 12305 |
PerlException: |
| 12306 |
InheritPerlException(exception,perl_exception); |
| 12307 |
exception=DestroyExceptionInfo(exception); |
| 12308 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 12309 |
SvPOK_on(perl_exception); /* return messages in string context */ |
| 12310 |
ST(0)=sv_2mortal(perl_exception); |
| 12311 |
XSRETURN(1); |
| 12312 |
} |
| 12313 |
|
| 12314 |
# |
| 12315 |
############################################################################### |
| 12316 |
# # |
| 12317 |
# # |
| 12318 |
# # |
| 12319 |
# P e r c e p t u a l H a s h # |
| 12320 |
# # |
| 12321 |
# # |
| 12322 |
# # |
| 12323 |
############################################################################### |
| 12324 |
# |
| 12325 |
# |
| 12326 |
void |
| 12327 |
PerceptualHash(ref) |
| 12328 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 12329 |
ALIAS: |
| 12330 |
PerceptualHashImage = 1 |
| 12331 |
perceptualhash = 2 |
| 12332 |
perceptualhashimage = 3 |
| 12333 |
PPCODE: |
| 12334 |
{ |
| 12335 |
AV |
| 12336 |
*av; |
| 12337 |
|
| 12338 |
ChannelPerceptualHash |
| 12339 |
*channel_phash; |
| 12340 |
|
| 12341 |
char |
| 12342 |
message[MagickPathExtent]; |
| 12343 |
|
| 12344 |
ExceptionInfo |
| 12345 |
*exception; |
| 12346 |
|
| 12347 |
Image |
| 12348 |
*image; |
| 12349 |
|
| 12350 |
ssize_t |
| 12351 |
count; |
| 12352 |
|
| 12353 |
struct PackageInfo |
| 12354 |
*info; |
| 12355 |
|
| 12356 |
SV |
| 12357 |
*perl_exception, |
| 12358 |
*reference; |
| 12359 |
|
| 12360 |
PERL_UNUSED_VAR(ref); |
| 12361 |
PERL_UNUSED_VAR(ix); |
| 12362 |
exception=AcquireExceptionInfo(); |
| 12363 |
perl_exception=newSVpv("",0); |
| 12364 |
av=NULL; |
| 12365 |
if (sv_isobject(ST(0)) == 0) |
| 12366 |
{ |
| 12367 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 12368 |
PackageName); |
| 12369 |
goto PerlException; |
| 12370 |
} |
| 12371 |
reference=SvRV(ST(0)); |
| 12372 |
av=newAV(); |
| 12373 |
SvREFCNT_dec(av); |
| 12374 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 12375 |
if (image == (Image *) NULL) |
| 12376 |
{ |
| 12377 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 12378 |
PackageName); |
| 12379 |
goto PerlException; |
| 12380 |
} |
| 12381 |
count=0; |
| 12382 |
for ( ; image; image=image->next) |
| 12383 |
{ |
| 12384 |
ssize_t |
| 12385 |
i; |
| 12386 |
|
| 12387 |
channel_phash=GetImagePerceptualHash(image,exception); |
| 12388 |
if (channel_phash == (ChannelPerceptualHash *) NULL) |
| 12389 |
continue; |
| 12390 |
count++; |
| 12391 |
for (i=0; i < (ssize_t) GetPixelChannels(image); i++) |
| 12392 |
{ |
| 12393 |
ssize_t |
| 12394 |
j; |
| 12395 |
|
| 12396 |
PixelChannel channel=GetPixelChannelChannel(image,i); |
| 12397 |
PixelTrait traits=GetPixelChannelTraits(image,channel); |
| 12398 |
if (traits == UndefinedPixelTrait) |
| 12399 |
continue; |
| 12400 |
EXTEND(sp,((ssize_t) GetPixelChannels(image)* |
| 12401 |
MaximumNumberOfPerceptualHashes* |
| 12402 |
(ssize_t) channel_phash[0].number_colorspaces*(i+1)*count)); |
| 12403 |
for (j=0; j < MaximumNumberOfPerceptualHashes; j++) |
| 12404 |
{ |
| 12405 |
ssize_t |
| 12406 |
k; |
| 12407 |
|
| 12408 |
for (k=0; k < (ssize_t) channel_phash[0].number_colorspaces; k++) |
| 12409 |
{ |
| 12410 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", |
| 12411 |
channel_phash[channel].phash[k][j]); |
| 12412 |
PUSHs(sv_2mortal(newSVpv(message,0))); |
| 12413 |
} |
| 12414 |
} |
| 12415 |
} |
| 12416 |
channel_phash=(ChannelPerceptualHash *) |
| 12417 |
RelinquishMagickMemory(channel_phash); |
| 12418 |
} |
| 12419 |
|
| 12420 |
PerlException: |
| 12421 |
InheritPerlException(exception,perl_exception); |
| 12422 |
exception=DestroyExceptionInfo(exception); |
| 12423 |
SvREFCNT_dec(perl_exception); |
| 12424 |
} |
| 12425 |
|
| 12426 |
# |
| 12427 |
############################################################################### |
| 12428 |
# # |
| 12429 |
# # |
| 12430 |
# # |
| 12431 |
# P i n g # |
| 12432 |
# # |
| 12433 |
# # |
| 12434 |
# # |
| 12435 |
############################################################################### |
| 12436 |
# |
| 12437 |
# |
| 12438 |
void |
| 12439 |
Ping(ref,...) |
| 12440 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 12441 |
ALIAS: |
| 12442 |
PingImage = 1 |
| 12443 |
ping = 2 |
| 12444 |
pingimage = 3 |
| 12445 |
PPCODE: |
| 12446 |
{ |
| 12447 |
AV |
| 12448 |
*av; |
| 12449 |
|
| 12450 |
char |
| 12451 |
**keep, |
| 12452 |
**list, |
| 12453 |
**p; |
| 12454 |
|
| 12455 |
ExceptionInfo |
| 12456 |
*exception; |
| 12457 |
|
| 12458 |
Image |
| 12459 |
*image, |
| 12460 |
*next; |
| 12461 |
|
| 12462 |
int |
| 12463 |
n; |
| 12464 |
|
| 12465 |
MagickBooleanType |
| 12466 |
status; |
| 12467 |
|
| 12468 |
ssize_t |
| 12469 |
ac, |
| 12470 |
i; |
| 12471 |
|
| 12472 |
STRLEN |
| 12473 |
*length; |
| 12474 |
|
| 12475 |
struct PackageInfo |
| 12476 |
*info, |
| 12477 |
*package_info; |
| 12478 |
|
| 12479 |
SV |
| 12480 |
*perl_exception, |
| 12481 |
*reference; |
| 12482 |
|
| 12483 |
size_t |
| 12484 |
count; |
| 12485 |
|
| 12486 |
PERL_UNUSED_VAR(ref); |
| 12487 |
PERL_UNUSED_VAR(ix); |
| 12488 |
exception=AcquireExceptionInfo(); |
| 12489 |
perl_exception=newSVpv("",0); |
| 12490 |
package_info=(struct PackageInfo *) NULL; |
| 12491 |
ac=(items < 2) ? 1 : items-1; |
| 12492 |
list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list)); |
| 12493 |
keep=list; |
| 12494 |
length=(STRLEN *) NULL; |
| 12495 |
if (list == (char **) NULL) |
| 12496 |
{ |
| 12497 |
ThrowPerlException(exception,ResourceLimitError, |
| 12498 |
"MemoryAllocationFailed",PackageName); |
| 12499 |
goto PerlException; |
| 12500 |
} |
| 12501 |
keep=list; |
| 12502 |
length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length)); |
| 12503 |
if (length == (STRLEN *) NULL) |
| 12504 |
{ |
| 12505 |
ThrowPerlException(exception,ResourceLimitError, |
| 12506 |
"MemoryAllocationFailed",PackageName); |
| 12507 |
goto PerlException; |
| 12508 |
} |
| 12509 |
if (sv_isobject(ST(0)) == 0) |
| 12510 |
{ |
| 12511 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 12512 |
PackageName); |
| 12513 |
goto PerlException; |
| 12514 |
} |
| 12515 |
reference=SvRV(ST(0)); |
| 12516 |
if (SvTYPE(reference) != SVt_PVAV) |
| 12517 |
{ |
| 12518 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 12519 |
PackageName); |
| 12520 |
goto PerlException; |
| 12521 |
} |
| 12522 |
av=(AV *) reference; |
| 12523 |
info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL, |
| 12524 |
exception); |
| 12525 |
package_info=ClonePackageInfo(info,exception); |
| 12526 |
n=1; |
| 12527 |
if (items <= 1) |
| 12528 |
*list=(char *) (*package_info->image_info->filename ? |
| 12529 |
package_info->image_info->filename : "XC:black"); |
| 12530 |
else |
| 12531 |
for (n=0, i=0; i < ac; i++) |
| 12532 |
{ |
| 12533 |
list[n]=(char *) SvPV(ST(i+1),length[n]); |
| 12534 |
if ((items >= 3) && strEQcase(list[n],"blob")) |
| 12535 |
{ |
| 12536 |
void |
| 12537 |
*blob; |
| 12538 |
|
| 12539 |
i++; |
| 12540 |
blob=(void *) (SvPV(ST(i+1),length[n])); |
| 12541 |
SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]); |
| 12542 |
} |
| 12543 |
if ((items >= 3) && strEQcase(list[n],"filename")) |
| 12544 |
continue; |
| 12545 |
if ((items >= 3) && strEQcase(list[n],"file")) |
| 12546 |
{ |
| 12547 |
FILE |
| 12548 |
*file; |
| 12549 |
|
| 12550 |
PerlIO |
| 12551 |
*io_info; |
| 12552 |
|
| 12553 |
i++; |
| 12554 |
io_info=IoIFP(sv_2io(ST(i+1))); |
| 12555 |
if (io_info == (PerlIO *) NULL) |
| 12556 |
{ |
| 12557 |
ThrowPerlException(exception,BlobError,"UnableToOpenFile", |
| 12558 |
PackageName); |
| 12559 |
continue; |
| 12560 |
} |
| 12561 |
file=PerlIO_findFILE(io_info); |
| 12562 |
if (file == (FILE *) NULL) |
| 12563 |
{ |
| 12564 |
ThrowPerlException(exception,BlobError,"UnableToOpenFile", |
| 12565 |
PackageName); |
| 12566 |
continue; |
| 12567 |
} |
| 12568 |
SetImageInfoFile(package_info->image_info,file); |
| 12569 |
} |
| 12570 |
if ((items >= 3) && strEQcase(list[n],"magick")) |
| 12571 |
continue; |
| 12572 |
n++; |
| 12573 |
} |
| 12574 |
list[n]=(char *) NULL; |
| 12575 |
keep=list; |
| 12576 |
status=ExpandFilenames(&n,&list); |
| 12577 |
if (status == MagickFalse) |
| 12578 |
{ |
| 12579 |
ThrowPerlException(exception,ResourceLimitError, |
| 12580 |
"MemoryAllocationFailed",PackageName); |
| 12581 |
goto PerlException; |
| 12582 |
} |
| 12583 |
count=0; |
| 12584 |
for (i=0; i < n; i++) |
| 12585 |
{ |
| 12586 |
(void) CopyMagickString(package_info->image_info->filename,list[i], |
| 12587 |
MagickPathExtent); |
| 12588 |
image=PingImage(package_info->image_info,exception); |
| 12589 |
if (image == (Image *) NULL) |
| 12590 |
break; |
| 12591 |
if ((package_info->image_info->file != (FILE *) NULL) || |
| 12592 |
(package_info->image_info->blob != (void *) NULL)) |
| 12593 |
DisassociateImageStream(image); |
| 12594 |
count+=GetImageListLength(image); |
| 12595 |
EXTEND(sp,4*(ssize_t) count); |
| 12596 |
for (next=image; next; next=next->next) |
| 12597 |
{ |
| 12598 |
PUSHs(sv_2mortal(newSViv((ssize_t) next->columns))); |
| 12599 |
PUSHs(sv_2mortal(newSViv((ssize_t) next->rows))); |
| 12600 |
PUSHs(sv_2mortal(newSViv((ssize_t) GetBlobSize(next)))); |
| 12601 |
PUSHs(sv_2mortal(newSVpv(next->magick,0))); |
| 12602 |
} |
| 12603 |
image=DestroyImageList(image); |
| 12604 |
} |
| 12605 |
/* |
| 12606 |
Free resources. |
| 12607 |
*/ |
| 12608 |
for (i=0; i < n; i++) |
| 12609 |
if (list[i] != (char *) NULL) |
| 12610 |
for (p=keep; list[i] != *p++; ) |
| 12611 |
if (*p == NULL) |
| 12612 |
{ |
| 12613 |
list[i]=(char *) RelinquishMagickMemory(list[i]); |
| 12614 |
break; |
| 12615 |
} |
| 12616 |
|
| 12617 |
PerlException: |
| 12618 |
if (package_info != (struct PackageInfo *) NULL) |
| 12619 |
DestroyPackageInfo(package_info); |
| 12620 |
if (list && (list != keep)) |
| 12621 |
list=(char **) RelinquishMagickMemory(list); |
| 12622 |
if (keep) |
| 12623 |
keep=(char **) RelinquishMagickMemory(keep); |
| 12624 |
if (length) |
| 12625 |
length=(STRLEN *) RelinquishMagickMemory(length); |
| 12626 |
InheritPerlException(exception,perl_exception); |
| 12627 |
exception=DestroyExceptionInfo(exception); |
| 12628 |
SvREFCNT_dec(perl_exception); /* throw away all errors */ |
| 12629 |
} |
| 12630 |
|
| 12631 |
# |
| 12632 |
############################################################################### |
| 12633 |
# # |
| 12634 |
# # |
| 12635 |
# # |
| 12636 |
# P r e v i e w # |
| 12637 |
# # |
| 12638 |
# # |
| 12639 |
# # |
| 12640 |
############################################################################### |
| 12641 |
# |
| 12642 |
# |
| 12643 |
void |
| 12644 |
Preview(ref,...) |
| 12645 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 12646 |
ALIAS: |
| 12647 |
PreviewImage = 1 |
| 12648 |
preview = 2 |
| 12649 |
previewimage = 3 |
| 12650 |
PPCODE: |
| 12651 |
{ |
| 12652 |
AV |
| 12653 |
*av; |
| 12654 |
|
| 12655 |
ExceptionInfo |
| 12656 |
*exception; |
| 12657 |
|
| 12658 |
HV |
| 12659 |
*hv; |
| 12660 |
|
| 12661 |
Image |
| 12662 |
*image, |
| 12663 |
*preview_image; |
| 12664 |
|
| 12665 |
PreviewType |
| 12666 |
preview_type; |
| 12667 |
|
| 12668 |
struct PackageInfo |
| 12669 |
*info; |
| 12670 |
|
| 12671 |
SV |
| 12672 |
*av_reference, |
| 12673 |
*perl_exception, |
| 12674 |
*reference, |
| 12675 |
*rv, |
| 12676 |
*sv; |
| 12677 |
|
| 12678 |
PERL_UNUSED_VAR(ref); |
| 12679 |
PERL_UNUSED_VAR(ix); |
| 12680 |
exception=AcquireExceptionInfo(); |
| 12681 |
perl_exception=newSVpv("",0); |
| 12682 |
sv=NULL; |
| 12683 |
av=NULL; |
| 12684 |
if (sv_isobject(ST(0)) == 0) |
| 12685 |
{ |
| 12686 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 12687 |
PackageName); |
| 12688 |
goto PerlException; |
| 12689 |
} |
| 12690 |
reference=SvRV(ST(0)); |
| 12691 |
hv=SvSTASH(reference); |
| 12692 |
av=newAV(); |
| 12693 |
av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv)); |
| 12694 |
SvREFCNT_dec(av); |
| 12695 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 12696 |
if (image == (Image *) NULL) |
| 12697 |
{ |
| 12698 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 12699 |
PackageName); |
| 12700 |
goto PerlException; |
| 12701 |
} |
| 12702 |
info=GetPackageInfo(aTHX_ (void *) av,info,exception); |
| 12703 |
preview_type=GammaPreview; |
| 12704 |
if (items > 1) |
| 12705 |
preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions, |
| 12706 |
MagickFalse,SvPV(ST(1),na)); |
| 12707 |
for ( ; image; image=image->next) |
| 12708 |
{ |
| 12709 |
preview_image=PreviewImage(image,preview_type,exception); |
| 12710 |
if (preview_image == (Image *) NULL) |
| 12711 |
goto PerlException; |
| 12712 |
AddImageToRegistry(sv,preview_image); |
| 12713 |
rv=newRV(sv); |
| 12714 |
av_push(av,sv_bless(rv,hv)); |
| 12715 |
SvREFCNT_dec(sv); |
| 12716 |
} |
| 12717 |
exception=DestroyExceptionInfo(exception); |
| 12718 |
ST(0)=av_reference; |
| 12719 |
SvREFCNT_dec(perl_exception); /* can't return warning messages */ |
| 12720 |
XSRETURN(1); |
| 12721 |
|
| 12722 |
PerlException: |
| 12723 |
InheritPerlException(exception,perl_exception); |
| 12724 |
exception=DestroyExceptionInfo(exception); |
| 12725 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 12726 |
SvPOK_on(perl_exception); |
| 12727 |
ST(0)=sv_2mortal(perl_exception); |
| 12728 |
XSRETURN(1); |
| 12729 |
} |
| 12730 |
|
| 12731 |
# |
| 12732 |
############################################################################### |
| 12733 |
# # |
| 12734 |
# # |
| 12735 |
# # |
| 12736 |
# Q u e r y C o l o r # |
| 12737 |
# # |
| 12738 |
# # |
| 12739 |
# # |
| 12740 |
############################################################################### |
| 12741 |
# |
| 12742 |
# |
| 12743 |
void |
| 12744 |
QueryColor(ref,...) |
| 12745 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 12746 |
ALIAS: |
| 12747 |
querycolor = 1 |
| 12748 |
PPCODE: |
| 12749 |
{ |
| 12750 |
char |
| 12751 |
*name; |
| 12752 |
|
| 12753 |
ExceptionInfo |
| 12754 |
*exception; |
| 12755 |
|
| 12756 |
PixelInfo |
| 12757 |
color; |
| 12758 |
|
| 12759 |
ssize_t |
| 12760 |
i; |
| 12761 |
|
| 12762 |
SV |
| 12763 |
*perl_exception; |
| 12764 |
|
| 12765 |
PERL_UNUSED_VAR(ref); |
| 12766 |
PERL_UNUSED_VAR(ix); |
| 12767 |
exception=AcquireExceptionInfo(); |
| 12768 |
perl_exception=newSVpv("",0); |
| 12769 |
if (items == 1) |
| 12770 |
{ |
| 12771 |
const ColorInfo |
| 12772 |
**colorlist; |
| 12773 |
|
| 12774 |
size_t |
| 12775 |
colors; |
| 12776 |
|
| 12777 |
colorlist=GetColorInfoList("*",&colors,exception); |
| 12778 |
EXTEND(sp,(ssize_t) colors); |
| 12779 |
for (i=0; i < (ssize_t) colors; i++) |
| 12780 |
{ |
| 12781 |
PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0))); |
| 12782 |
} |
| 12783 |
colorlist=(const ColorInfo **) |
| 12784 |
RelinquishMagickMemory((ColorInfo **) colorlist); |
| 12785 |
goto PerlException; |
| 12786 |
} |
| 12787 |
EXTEND(sp,5*items); |
| 12788 |
for (i=1; i < items; i++) |
| 12789 |
{ |
| 12790 |
name=(char *) SvPV(ST(i),na); |
| 12791 |
if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse) |
| 12792 |
{ |
| 12793 |
PUSHs(&sv_undef); |
| 12794 |
continue; |
| 12795 |
} |
| 12796 |
PUSHs(sv_2mortal(newSViv((ssize_t) floor(color.red+0.5)))); |
| 12797 |
PUSHs(sv_2mortal(newSViv((ssize_t) floor(color.green+0.5)))); |
| 12798 |
PUSHs(sv_2mortal(newSViv((ssize_t) floor(color.blue+0.5)))); |
| 12799 |
if (color.colorspace == CMYKColorspace) |
| 12800 |
PUSHs(sv_2mortal(newSViv((ssize_t) floor(color.black+0.5)))); |
| 12801 |
if (color.alpha_trait != UndefinedPixelTrait) |
| 12802 |
PUSHs(sv_2mortal(newSViv((ssize_t) floor(color.alpha+0.5)))); |
| 12803 |
} |
| 12804 |
|
| 12805 |
PerlException: |
| 12806 |
InheritPerlException(exception,perl_exception); |
| 12807 |
exception=DestroyExceptionInfo(exception); |
| 12808 |
SvREFCNT_dec(perl_exception); |
| 12809 |
} |
| 12810 |
|
| 12811 |
# |
| 12812 |
############################################################################### |
| 12813 |
# # |
| 12814 |
# # |
| 12815 |
# # |
| 12816 |
# Q u e r y C o l o r N a m e # |
| 12817 |
# # |
| 12818 |
# # |
| 12819 |
# # |
| 12820 |
############################################################################### |
| 12821 |
# |
| 12822 |
# |
| 12823 |
void |
| 12824 |
QueryColorname(ref,...) |
| 12825 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 12826 |
ALIAS: |
| 12827 |
querycolorname = 1 |
| 12828 |
PPCODE: |
| 12829 |
{ |
| 12830 |
AV |
| 12831 |
*av; |
| 12832 |
|
| 12833 |
char |
| 12834 |
message[MagickPathExtent]; |
| 12835 |
|
| 12836 |
ExceptionInfo |
| 12837 |
*exception; |
| 12838 |
|
| 12839 |
Image |
| 12840 |
*image; |
| 12841 |
|
| 12842 |
PixelInfo |
| 12843 |
target_color; |
| 12844 |
|
| 12845 |
ssize_t |
| 12846 |
i; |
| 12847 |
|
| 12848 |
struct PackageInfo |
| 12849 |
*info; |
| 12850 |
|
| 12851 |
SV |
| 12852 |
*perl_exception, |
| 12853 |
*reference; /* reference is the SV* of ref=SvIV(reference) */ |
| 12854 |
|
| 12855 |
PERL_UNUSED_VAR(ref); |
| 12856 |
PERL_UNUSED_VAR(ix); |
| 12857 |
exception=AcquireExceptionInfo(); |
| 12858 |
perl_exception=newSVpv("",0); |
| 12859 |
reference=SvRV(ST(0)); |
| 12860 |
av=(AV *) reference; |
| 12861 |
info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL, |
| 12862 |
exception); |
| 12863 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 12864 |
if (image == (Image *) NULL) |
| 12865 |
{ |
| 12866 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 12867 |
PackageName); |
| 12868 |
goto PerlException; |
| 12869 |
} |
| 12870 |
EXTEND(sp,items); |
| 12871 |
for (i=1; i < items; i++) |
| 12872 |
{ |
| 12873 |
(void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color, |
| 12874 |
exception); |
| 12875 |
(void) QueryColorname(image,&target_color,SVGCompliance,message, |
| 12876 |
exception); |
| 12877 |
PUSHs(sv_2mortal(newSVpv(message,0))); |
| 12878 |
} |
| 12879 |
|
| 12880 |
PerlException: |
| 12881 |
InheritPerlException(exception,perl_exception); |
| 12882 |
exception=DestroyExceptionInfo(exception); |
| 12883 |
SvREFCNT_dec(perl_exception); |
| 12884 |
} |
| 12885 |
|
| 12886 |
# |
| 12887 |
############################################################################### |
| 12888 |
# # |
| 12889 |
# # |
| 12890 |
# # |
| 12891 |
# Q u e r y F o n t # |
| 12892 |
# # |
| 12893 |
# # |
| 12894 |
# # |
| 12895 |
############################################################################### |
| 12896 |
# |
| 12897 |
# |
| 12898 |
void |
| 12899 |
QueryFont(ref,...) |
| 12900 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 12901 |
ALIAS: |
| 12902 |
queryfont = 1 |
| 12903 |
PPCODE: |
| 12904 |
{ |
| 12905 |
char |
| 12906 |
*name, |
| 12907 |
message[MagickPathExtent]; |
| 12908 |
|
| 12909 |
ExceptionInfo |
| 12910 |
*exception; |
| 12911 |
|
| 12912 |
ssize_t |
| 12913 |
i; |
| 12914 |
|
| 12915 |
SV |
| 12916 |
*perl_exception; |
| 12917 |
|
| 12918 |
volatile const TypeInfo |
| 12919 |
*type_info; |
| 12920 |
|
| 12921 |
PERL_UNUSED_VAR(ref); |
| 12922 |
PERL_UNUSED_VAR(ix); |
| 12923 |
exception=AcquireExceptionInfo(); |
| 12924 |
perl_exception=newSVpv("",0); |
| 12925 |
if (items == 1) |
| 12926 |
{ |
| 12927 |
const TypeInfo |
| 12928 |
**typelist; |
| 12929 |
|
| 12930 |
size_t |
| 12931 |
types; |
| 12932 |
|
| 12933 |
typelist=GetTypeInfoList("*",&types,exception); |
| 12934 |
EXTEND(sp,(ssize_t) types); |
| 12935 |
for (i=0; i < (ssize_t) types; i++) |
| 12936 |
{ |
| 12937 |
PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0))); |
| 12938 |
} |
| 12939 |
typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **) |
| 12940 |
typelist); |
| 12941 |
goto PerlException; |
| 12942 |
} |
| 12943 |
EXTEND(sp,10*items); |
| 12944 |
for (i=1; i < items; i++) |
| 12945 |
{ |
| 12946 |
name=(char *) SvPV(ST(i),na); |
| 12947 |
type_info=GetTypeInfo(name,exception); |
| 12948 |
if (type_info == (TypeInfo *) NULL) |
| 12949 |
{ |
| 12950 |
PUSHs(&sv_undef); |
| 12951 |
continue; |
| 12952 |
} |
| 12953 |
if (type_info->name == (char *) NULL) |
| 12954 |
PUSHs(&sv_undef); |
| 12955 |
else |
| 12956 |
PUSHs(sv_2mortal(newSVpv(type_info->name,0))); |
| 12957 |
if (type_info->description == (char *) NULL) |
| 12958 |
PUSHs(&sv_undef); |
| 12959 |
else |
| 12960 |
PUSHs(sv_2mortal(newSVpv(type_info->description,0))); |
| 12961 |
if (type_info->family == (char *) NULL) |
| 12962 |
PUSHs(&sv_undef); |
| 12963 |
else |
| 12964 |
PUSHs(sv_2mortal(newSVpv(type_info->family,0))); |
| 12965 |
if (type_info->style == UndefinedStyle) |
| 12966 |
PUSHs(&sv_undef); |
| 12967 |
else |
| 12968 |
PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions, |
| 12969 |
type_info->style),0))); |
| 12970 |
if (type_info->stretch == UndefinedStretch) |
| 12971 |
PUSHs(&sv_undef); |
| 12972 |
else |
| 12973 |
PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions, |
| 12974 |
type_info->stretch),0))); |
| 12975 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double) |
| 12976 |
type_info->weight); |
| 12977 |
PUSHs(sv_2mortal(newSVpv(message,0))); |
| 12978 |
if (type_info->encoding == (char *) NULL) |
| 12979 |
PUSHs(&sv_undef); |
| 12980 |
else |
| 12981 |
PUSHs(sv_2mortal(newSVpv(type_info->encoding,0))); |
| 12982 |
if (type_info->foundry == (char *) NULL) |
| 12983 |
PUSHs(&sv_undef); |
| 12984 |
else |
| 12985 |
PUSHs(sv_2mortal(newSVpv(type_info->foundry,0))); |
| 12986 |
if (type_info->format == (char *) NULL) |
| 12987 |
PUSHs(&sv_undef); |
| 12988 |
else |
| 12989 |
PUSHs(sv_2mortal(newSVpv(type_info->format,0))); |
| 12990 |
if (type_info->metrics == (char *) NULL) |
| 12991 |
PUSHs(&sv_undef); |
| 12992 |
else |
| 12993 |
PUSHs(sv_2mortal(newSVpv(type_info->metrics,0))); |
| 12994 |
if (type_info->glyphs == (char *) NULL) |
| 12995 |
PUSHs(&sv_undef); |
| 12996 |
else |
| 12997 |
PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0))); |
| 12998 |
} |
| 12999 |
|
| 13000 |
PerlException: |
| 13001 |
InheritPerlException(exception,perl_exception); |
| 13002 |
exception=DestroyExceptionInfo(exception); |
| 13003 |
SvREFCNT_dec(perl_exception); |
| 13004 |
} |
| 13005 |
|
| 13006 |
# |
| 13007 |
############################################################################### |
| 13008 |
# # |
| 13009 |
# # |
| 13010 |
# # |
| 13011 |
# Q u e r y F o n t M e t r i c s # |
| 13012 |
# # |
| 13013 |
# # |
| 13014 |
# # |
| 13015 |
############################################################################### |
| 13016 |
# |
| 13017 |
# |
| 13018 |
void |
| 13019 |
QueryFontMetrics(ref,...) |
| 13020 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 13021 |
ALIAS: |
| 13022 |
queryfontmetrics = 1 |
| 13023 |
PPCODE: |
| 13024 |
{ |
| 13025 |
AffineMatrix |
| 13026 |
affine, |
| 13027 |
current; |
| 13028 |
|
| 13029 |
AV |
| 13030 |
*av; |
| 13031 |
|
| 13032 |
char |
| 13033 |
*attribute; |
| 13034 |
|
| 13035 |
double |
| 13036 |
x, |
| 13037 |
y; |
| 13038 |
|
| 13039 |
DrawInfo |
| 13040 |
*draw_info; |
| 13041 |
|
| 13042 |
ExceptionInfo |
| 13043 |
*exception; |
| 13044 |
|
| 13045 |
GeometryInfo |
| 13046 |
geometry_info; |
| 13047 |
|
| 13048 |
Image |
| 13049 |
*image; |
| 13050 |
|
| 13051 |
MagickBooleanType |
| 13052 |
status; |
| 13053 |
|
| 13054 |
MagickStatusType |
| 13055 |
flags; |
| 13056 |
|
| 13057 |
ssize_t |
| 13058 |
i, |
| 13059 |
type; |
| 13060 |
|
| 13061 |
struct PackageInfo |
| 13062 |
*info, |
| 13063 |
*package_info; |
| 13064 |
|
| 13065 |
SV |
| 13066 |
*perl_exception, |
| 13067 |
*reference; /* reference is the SV* of ref=SvIV(reference) */ |
| 13068 |
|
| 13069 |
TypeMetric |
| 13070 |
metrics; |
| 13071 |
|
| 13072 |
PERL_UNUSED_VAR(ref); |
| 13073 |
PERL_UNUSED_VAR(ix); |
| 13074 |
exception=AcquireExceptionInfo(); |
| 13075 |
package_info=(struct PackageInfo *) NULL; |
| 13076 |
perl_exception=newSVpv("",0); |
| 13077 |
reference=SvRV(ST(0)); |
| 13078 |
av=(AV *) reference; |
| 13079 |
info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL, |
| 13080 |
exception); |
| 13081 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 13082 |
if (image == (Image *) NULL) |
| 13083 |
{ |
| 13084 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 13085 |
PackageName); |
| 13086 |
goto PerlException; |
| 13087 |
} |
| 13088 |
package_info=ClonePackageInfo(info,exception); |
| 13089 |
draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL); |
| 13090 |
CloneString(&draw_info->text,""); |
| 13091 |
current=draw_info->affine; |
| 13092 |
GetAffineMatrix(&affine); |
| 13093 |
x=0.0; |
| 13094 |
y=0.0; |
| 13095 |
EXTEND(sp,7*items); |
| 13096 |
for (i=2; i < items; i+=2) |
| 13097 |
{ |
| 13098 |
attribute=(char *) SvPV(ST(i-1),na); |
| 13099 |
switch (*attribute) |
| 13100 |
{ |
| 13101 |
case 'A': |
| 13102 |
case 'a': |
| 13103 |
{ |
| 13104 |
if (LocaleCompare(attribute,"antialias") == 0) |
| 13105 |
{ |
| 13106 |
type=ParseCommandOption(MagickBooleanOptions,MagickFalse, |
| 13107 |
SvPV(ST(i),na)); |
| 13108 |
if (type < 0) |
| 13109 |
{ |
| 13110 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 13111 |
SvPV(ST(i),na)); |
| 13112 |
break; |
| 13113 |
} |
| 13114 |
draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse; |
| 13115 |
break; |
| 13116 |
} |
| 13117 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13118 |
attribute); |
| 13119 |
break; |
| 13120 |
} |
| 13121 |
case 'd': |
| 13122 |
case 'D': |
| 13123 |
{ |
| 13124 |
if (LocaleCompare(attribute,"density") == 0) |
| 13125 |
{ |
| 13126 |
CloneString(&draw_info->density,SvPV(ST(i),na)); |
| 13127 |
break; |
| 13128 |
} |
| 13129 |
if (LocaleCompare(attribute,"direction") == 0) |
| 13130 |
{ |
| 13131 |
draw_info->direction=(DirectionType) ParseCommandOption( |
| 13132 |
MagickDirectionOptions,MagickFalse,SvPV(ST(i),na)); |
| 13133 |
break; |
| 13134 |
} |
| 13135 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13136 |
attribute); |
| 13137 |
break; |
| 13138 |
} |
| 13139 |
case 'e': |
| 13140 |
case 'E': |
| 13141 |
{ |
| 13142 |
if (LocaleCompare(attribute,"encoding") == 0) |
| 13143 |
{ |
| 13144 |
CloneString(&draw_info->encoding,SvPV(ST(i),na)); |
| 13145 |
break; |
| 13146 |
} |
| 13147 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13148 |
attribute); |
| 13149 |
break; |
| 13150 |
} |
| 13151 |
case 'f': |
| 13152 |
case 'F': |
| 13153 |
{ |
| 13154 |
if (LocaleCompare(attribute,"family") == 0) |
| 13155 |
{ |
| 13156 |
CloneString(&draw_info->family,SvPV(ST(i),na)); |
| 13157 |
break; |
| 13158 |
} |
| 13159 |
if (LocaleCompare(attribute,"fill") == 0) |
| 13160 |
{ |
| 13161 |
if (info) |
| 13162 |
(void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance, |
| 13163 |
&draw_info->fill,exception); |
| 13164 |
break; |
| 13165 |
} |
| 13166 |
if (LocaleCompare(attribute,"font") == 0) |
| 13167 |
{ |
| 13168 |
CloneString(&draw_info->font,SvPV(ST(i),na)); |
| 13169 |
break; |
| 13170 |
} |
| 13171 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13172 |
attribute); |
| 13173 |
break; |
| 13174 |
} |
| 13175 |
case 'g': |
| 13176 |
case 'G': |
| 13177 |
{ |
| 13178 |
if (LocaleCompare(attribute,"geometry") == 0) |
| 13179 |
{ |
| 13180 |
CloneString(&draw_info->geometry,SvPV(ST(i),na)); |
| 13181 |
break; |
| 13182 |
} |
| 13183 |
if (LocaleCompare(attribute,"gravity") == 0) |
| 13184 |
{ |
| 13185 |
draw_info->gravity=(GravityType) ParseCommandOption( |
| 13186 |
MagickGravityOptions,MagickFalse,SvPV(ST(i),na)); |
| 13187 |
break; |
| 13188 |
} |
| 13189 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13190 |
attribute); |
| 13191 |
break; |
| 13192 |
} |
| 13193 |
case 'i': |
| 13194 |
case 'I': |
| 13195 |
{ |
| 13196 |
if (LocaleCompare(attribute,"interline-spacing") == 0) |
| 13197 |
{ |
| 13198 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13199 |
draw_info->interline_spacing=geometry_info.rho; |
| 13200 |
break; |
| 13201 |
} |
| 13202 |
if (LocaleCompare(attribute,"interword-spacing") == 0) |
| 13203 |
{ |
| 13204 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13205 |
draw_info->interword_spacing=geometry_info.rho; |
| 13206 |
break; |
| 13207 |
} |
| 13208 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13209 |
attribute); |
| 13210 |
break; |
| 13211 |
} |
| 13212 |
case 'k': |
| 13213 |
case 'K': |
| 13214 |
{ |
| 13215 |
if (LocaleCompare(attribute,"kerning") == 0) |
| 13216 |
{ |
| 13217 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13218 |
draw_info->kerning=geometry_info.rho; |
| 13219 |
break; |
| 13220 |
} |
| 13221 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13222 |
attribute); |
| 13223 |
break; |
| 13224 |
} |
| 13225 |
case 'p': |
| 13226 |
case 'P': |
| 13227 |
{ |
| 13228 |
if (LocaleCompare(attribute,"pointsize") == 0) |
| 13229 |
{ |
| 13230 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13231 |
draw_info->pointsize=geometry_info.rho; |
| 13232 |
break; |
| 13233 |
} |
| 13234 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13235 |
attribute); |
| 13236 |
break; |
| 13237 |
} |
| 13238 |
case 'r': |
| 13239 |
case 'R': |
| 13240 |
{ |
| 13241 |
if (LocaleCompare(attribute,"rotate") == 0) |
| 13242 |
{ |
| 13243 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13244 |
affine.rx=geometry_info.rho; |
| 13245 |
affine.ry=geometry_info.sigma; |
| 13246 |
if ((flags & SigmaValue) == 0) |
| 13247 |
affine.ry=affine.rx; |
| 13248 |
break; |
| 13249 |
} |
| 13250 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13251 |
attribute); |
| 13252 |
break; |
| 13253 |
} |
| 13254 |
case 's': |
| 13255 |
case 'S': |
| 13256 |
{ |
| 13257 |
if (LocaleCompare(attribute,"scale") == 0) |
| 13258 |
{ |
| 13259 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13260 |
affine.sx=geometry_info.rho; |
| 13261 |
affine.sy=geometry_info.sigma; |
| 13262 |
if ((flags & SigmaValue) == 0) |
| 13263 |
affine.sy=affine.sx; |
| 13264 |
break; |
| 13265 |
} |
| 13266 |
if (LocaleCompare(attribute,"skew") == 0) |
| 13267 |
{ |
| 13268 |
double |
| 13269 |
x_angle, |
| 13270 |
y_angle; |
| 13271 |
|
| 13272 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13273 |
x_angle=geometry_info.rho; |
| 13274 |
y_angle=geometry_info.sigma; |
| 13275 |
if ((flags & SigmaValue) == 0) |
| 13276 |
y_angle=x_angle; |
| 13277 |
affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0))); |
| 13278 |
affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0))); |
| 13279 |
break; |
| 13280 |
} |
| 13281 |
if (LocaleCompare(attribute,"stroke") == 0) |
| 13282 |
{ |
| 13283 |
if (info) |
| 13284 |
(void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance, |
| 13285 |
&draw_info->stroke,exception); |
| 13286 |
break; |
| 13287 |
} |
| 13288 |
if (LocaleCompare(attribute,"style") == 0) |
| 13289 |
{ |
| 13290 |
type=ParseCommandOption(MagickStyleOptions,MagickFalse, |
| 13291 |
SvPV(ST(i),na)); |
| 13292 |
if (type < 0) |
| 13293 |
{ |
| 13294 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 13295 |
SvPV(ST(i),na)); |
| 13296 |
break; |
| 13297 |
} |
| 13298 |
draw_info->style=(StyleType) type; |
| 13299 |
break; |
| 13300 |
} |
| 13301 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13302 |
attribute); |
| 13303 |
break; |
| 13304 |
} |
| 13305 |
case 't': |
| 13306 |
case 'T': |
| 13307 |
{ |
| 13308 |
if (LocaleCompare(attribute,"text") == 0) |
| 13309 |
{ |
| 13310 |
CloneString(&draw_info->text,SvPV(ST(i),na)); |
| 13311 |
break; |
| 13312 |
} |
| 13313 |
if (LocaleCompare(attribute,"translate") == 0) |
| 13314 |
{ |
| 13315 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13316 |
affine.tx=geometry_info.rho; |
| 13317 |
affine.ty=geometry_info.sigma; |
| 13318 |
if ((flags & SigmaValue) == 0) |
| 13319 |
affine.ty=affine.tx; |
| 13320 |
break; |
| 13321 |
} |
| 13322 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13323 |
attribute); |
| 13324 |
break; |
| 13325 |
} |
| 13326 |
case 'w': |
| 13327 |
case 'W': |
| 13328 |
{ |
| 13329 |
if (LocaleCompare(attribute,"weight") == 0) |
| 13330 |
{ |
| 13331 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13332 |
draw_info->weight=(size_t) geometry_info.rho; |
| 13333 |
break; |
| 13334 |
} |
| 13335 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13336 |
attribute); |
| 13337 |
break; |
| 13338 |
} |
| 13339 |
case 'x': |
| 13340 |
case 'X': |
| 13341 |
{ |
| 13342 |
if (LocaleCompare(attribute,"x") == 0) |
| 13343 |
{ |
| 13344 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13345 |
x=geometry_info.rho; |
| 13346 |
break; |
| 13347 |
} |
| 13348 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13349 |
attribute); |
| 13350 |
break; |
| 13351 |
} |
| 13352 |
case 'y': |
| 13353 |
case 'Y': |
| 13354 |
{ |
| 13355 |
if (LocaleCompare(attribute,"y") == 0) |
| 13356 |
{ |
| 13357 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13358 |
y=geometry_info.rho; |
| 13359 |
break; |
| 13360 |
} |
| 13361 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13362 |
attribute); |
| 13363 |
break; |
| 13364 |
} |
| 13365 |
default: |
| 13366 |
{ |
| 13367 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13368 |
attribute); |
| 13369 |
break; |
| 13370 |
} |
| 13371 |
} |
| 13372 |
} |
| 13373 |
draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx; |
| 13374 |
draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx; |
| 13375 |
draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy; |
| 13376 |
draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy; |
| 13377 |
draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx; |
| 13378 |
draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty; |
| 13379 |
if (draw_info->geometry == (char *) NULL) |
| 13380 |
{ |
| 13381 |
draw_info->geometry=AcquireString((char *) NULL); |
| 13382 |
(void) FormatLocaleString(draw_info->geometry,MagickPathExtent, |
| 13383 |
"%.20g,%.20g",x,y); |
| 13384 |
} |
| 13385 |
status=GetTypeMetrics(image,draw_info,&metrics,exception); |
| 13386 |
(void) CatchImageException(image); |
| 13387 |
if (status == MagickFalse) |
| 13388 |
PUSHs(&sv_undef); |
| 13389 |
else |
| 13390 |
{ |
| 13391 |
PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x))); |
| 13392 |
PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y))); |
| 13393 |
PUSHs(sv_2mortal(newSVnv(metrics.ascent))); |
| 13394 |
PUSHs(sv_2mortal(newSVnv(metrics.descent))); |
| 13395 |
PUSHs(sv_2mortal(newSVnv(metrics.width))); |
| 13396 |
PUSHs(sv_2mortal(newSVnv(metrics.height))); |
| 13397 |
PUSHs(sv_2mortal(newSVnv(metrics.max_advance))); |
| 13398 |
PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1))); |
| 13399 |
PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1))); |
| 13400 |
PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2))); |
| 13401 |
PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2))); |
| 13402 |
PUSHs(sv_2mortal(newSVnv(metrics.origin.x))); |
| 13403 |
PUSHs(sv_2mortal(newSVnv(metrics.origin.y))); |
| 13404 |
} |
| 13405 |
draw_info=DestroyDrawInfo(draw_info); |
| 13406 |
|
| 13407 |
PerlException: |
| 13408 |
if (package_info != (struct PackageInfo *) NULL) |
| 13409 |
DestroyPackageInfo(package_info); |
| 13410 |
InheritPerlException(exception,perl_exception); |
| 13411 |
exception=DestroyExceptionInfo(exception); |
| 13412 |
SvREFCNT_dec(perl_exception); /* can't return warning messages */ |
| 13413 |
} |
| 13414 |
|
| 13415 |
# |
| 13416 |
############################################################################### |
| 13417 |
# # |
| 13418 |
# # |
| 13419 |
# # |
| 13420 |
# Q u e r y M u l t i l i n e F o n t M e t r i c s # |
| 13421 |
# # |
| 13422 |
# # |
| 13423 |
# # |
| 13424 |
############################################################################### |
| 13425 |
# |
| 13426 |
# |
| 13427 |
void |
| 13428 |
QueryMultilineFontMetrics(ref,...) |
| 13429 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 13430 |
ALIAS: |
| 13431 |
querymultilinefontmetrics = 1 |
| 13432 |
PPCODE: |
| 13433 |
{ |
| 13434 |
AffineMatrix |
| 13435 |
affine, |
| 13436 |
current; |
| 13437 |
|
| 13438 |
AV |
| 13439 |
*av; |
| 13440 |
|
| 13441 |
char |
| 13442 |
*attribute; |
| 13443 |
|
| 13444 |
double |
| 13445 |
x, |
| 13446 |
y; |
| 13447 |
|
| 13448 |
DrawInfo |
| 13449 |
*draw_info; |
| 13450 |
|
| 13451 |
ExceptionInfo |
| 13452 |
*exception; |
| 13453 |
|
| 13454 |
GeometryInfo |
| 13455 |
geometry_info; |
| 13456 |
|
| 13457 |
Image |
| 13458 |
*image; |
| 13459 |
|
| 13460 |
MagickBooleanType |
| 13461 |
status; |
| 13462 |
|
| 13463 |
MagickStatusType |
| 13464 |
flags; |
| 13465 |
|
| 13466 |
ssize_t |
| 13467 |
i, |
| 13468 |
type; |
| 13469 |
|
| 13470 |
struct PackageInfo |
| 13471 |
*info, |
| 13472 |
*package_info; |
| 13473 |
|
| 13474 |
SV |
| 13475 |
*perl_exception, |
| 13476 |
*reference; /* reference is the SV* of ref=SvIV(reference) */ |
| 13477 |
|
| 13478 |
TypeMetric |
| 13479 |
metrics; |
| 13480 |
|
| 13481 |
PERL_UNUSED_VAR(ref); |
| 13482 |
PERL_UNUSED_VAR(ix); |
| 13483 |
exception=AcquireExceptionInfo(); |
| 13484 |
package_info=(struct PackageInfo *) NULL; |
| 13485 |
perl_exception=newSVpv("",0); |
| 13486 |
reference=SvRV(ST(0)); |
| 13487 |
av=(AV *) reference; |
| 13488 |
info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL, |
| 13489 |
exception); |
| 13490 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 13491 |
if (image == (Image *) NULL) |
| 13492 |
{ |
| 13493 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 13494 |
PackageName); |
| 13495 |
goto PerlException; |
| 13496 |
} |
| 13497 |
package_info=ClonePackageInfo(info,exception); |
| 13498 |
draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL); |
| 13499 |
CloneString(&draw_info->text,""); |
| 13500 |
current=draw_info->affine; |
| 13501 |
GetAffineMatrix(&affine); |
| 13502 |
x=0.0; |
| 13503 |
y=0.0; |
| 13504 |
EXTEND(sp,7*items); |
| 13505 |
for (i=2; i < items; i+=2) |
| 13506 |
{ |
| 13507 |
attribute=(char *) SvPV(ST(i-1),na); |
| 13508 |
switch (*attribute) |
| 13509 |
{ |
| 13510 |
case 'A': |
| 13511 |
case 'a': |
| 13512 |
{ |
| 13513 |
if (LocaleCompare(attribute,"antialias") == 0) |
| 13514 |
{ |
| 13515 |
type=ParseCommandOption(MagickBooleanOptions,MagickFalse, |
| 13516 |
SvPV(ST(i),na)); |
| 13517 |
if (type < 0) |
| 13518 |
{ |
| 13519 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 13520 |
SvPV(ST(i),na)); |
| 13521 |
break; |
| 13522 |
} |
| 13523 |
draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse; |
| 13524 |
break; |
| 13525 |
} |
| 13526 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13527 |
attribute); |
| 13528 |
break; |
| 13529 |
} |
| 13530 |
case 'd': |
| 13531 |
case 'D': |
| 13532 |
{ |
| 13533 |
if (LocaleCompare(attribute,"density") == 0) |
| 13534 |
{ |
| 13535 |
CloneString(&draw_info->density,SvPV(ST(i),na)); |
| 13536 |
break; |
| 13537 |
} |
| 13538 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13539 |
attribute); |
| 13540 |
break; |
| 13541 |
} |
| 13542 |
case 'e': |
| 13543 |
case 'E': |
| 13544 |
{ |
| 13545 |
if (LocaleCompare(attribute,"encoding") == 0) |
| 13546 |
{ |
| 13547 |
CloneString(&draw_info->encoding,SvPV(ST(i),na)); |
| 13548 |
break; |
| 13549 |
} |
| 13550 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13551 |
attribute); |
| 13552 |
break; |
| 13553 |
} |
| 13554 |
case 'f': |
| 13555 |
case 'F': |
| 13556 |
{ |
| 13557 |
if (LocaleCompare(attribute,"family") == 0) |
| 13558 |
{ |
| 13559 |
CloneString(&draw_info->family,SvPV(ST(i),na)); |
| 13560 |
break; |
| 13561 |
} |
| 13562 |
if (LocaleCompare(attribute,"fill") == 0) |
| 13563 |
{ |
| 13564 |
if (info) |
| 13565 |
(void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance, |
| 13566 |
&draw_info->fill,exception); |
| 13567 |
break; |
| 13568 |
} |
| 13569 |
if (LocaleCompare(attribute,"font") == 0) |
| 13570 |
{ |
| 13571 |
CloneString(&draw_info->font,SvPV(ST(i),na)); |
| 13572 |
break; |
| 13573 |
} |
| 13574 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13575 |
attribute); |
| 13576 |
break; |
| 13577 |
} |
| 13578 |
case 'g': |
| 13579 |
case 'G': |
| 13580 |
{ |
| 13581 |
if (LocaleCompare(attribute,"geometry") == 0) |
| 13582 |
{ |
| 13583 |
CloneString(&draw_info->geometry,SvPV(ST(i),na)); |
| 13584 |
break; |
| 13585 |
} |
| 13586 |
if (LocaleCompare(attribute,"gravity") == 0) |
| 13587 |
{ |
| 13588 |
draw_info->gravity=(GravityType) ParseCommandOption( |
| 13589 |
MagickGravityOptions,MagickFalse,SvPV(ST(i),na)); |
| 13590 |
break; |
| 13591 |
} |
| 13592 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13593 |
attribute); |
| 13594 |
break; |
| 13595 |
} |
| 13596 |
case 'p': |
| 13597 |
case 'P': |
| 13598 |
{ |
| 13599 |
if (LocaleCompare(attribute,"pointsize") == 0) |
| 13600 |
{ |
| 13601 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13602 |
draw_info->pointsize=geometry_info.rho; |
| 13603 |
break; |
| 13604 |
} |
| 13605 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13606 |
attribute); |
| 13607 |
break; |
| 13608 |
} |
| 13609 |
case 'r': |
| 13610 |
case 'R': |
| 13611 |
{ |
| 13612 |
if (LocaleCompare(attribute,"rotate") == 0) |
| 13613 |
{ |
| 13614 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13615 |
affine.rx=geometry_info.rho; |
| 13616 |
affine.ry=geometry_info.sigma; |
| 13617 |
if ((flags & SigmaValue) == 0) |
| 13618 |
affine.ry=affine.rx; |
| 13619 |
break; |
| 13620 |
} |
| 13621 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13622 |
attribute); |
| 13623 |
break; |
| 13624 |
} |
| 13625 |
case 's': |
| 13626 |
case 'S': |
| 13627 |
{ |
| 13628 |
if (LocaleCompare(attribute,"scale") == 0) |
| 13629 |
{ |
| 13630 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13631 |
affine.sx=geometry_info.rho; |
| 13632 |
affine.sy=geometry_info.sigma; |
| 13633 |
if ((flags & SigmaValue) == 0) |
| 13634 |
affine.sy=affine.sx; |
| 13635 |
break; |
| 13636 |
} |
| 13637 |
if (LocaleCompare(attribute,"skew") == 0) |
| 13638 |
{ |
| 13639 |
double |
| 13640 |
x_angle, |
| 13641 |
y_angle; |
| 13642 |
|
| 13643 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13644 |
x_angle=geometry_info.rho; |
| 13645 |
y_angle=geometry_info.sigma; |
| 13646 |
if ((flags & SigmaValue) == 0) |
| 13647 |
y_angle=x_angle; |
| 13648 |
affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0))); |
| 13649 |
affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0))); |
| 13650 |
break; |
| 13651 |
} |
| 13652 |
if (LocaleCompare(attribute,"stroke") == 0) |
| 13653 |
{ |
| 13654 |
if (info) |
| 13655 |
(void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance, |
| 13656 |
&draw_info->stroke,exception); |
| 13657 |
break; |
| 13658 |
} |
| 13659 |
if (LocaleCompare(attribute,"style") == 0) |
| 13660 |
{ |
| 13661 |
type=ParseCommandOption(MagickStyleOptions,MagickFalse, |
| 13662 |
SvPV(ST(i),na)); |
| 13663 |
if (type < 0) |
| 13664 |
{ |
| 13665 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 13666 |
SvPV(ST(i),na)); |
| 13667 |
break; |
| 13668 |
} |
| 13669 |
draw_info->style=(StyleType) type; |
| 13670 |
break; |
| 13671 |
} |
| 13672 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13673 |
attribute); |
| 13674 |
break; |
| 13675 |
} |
| 13676 |
case 't': |
| 13677 |
case 'T': |
| 13678 |
{ |
| 13679 |
if (LocaleCompare(attribute,"text") == 0) |
| 13680 |
{ |
| 13681 |
CloneString(&draw_info->text,SvPV(ST(i),na)); |
| 13682 |
break; |
| 13683 |
} |
| 13684 |
if (LocaleCompare(attribute,"translate") == 0) |
| 13685 |
{ |
| 13686 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13687 |
affine.tx=geometry_info.rho; |
| 13688 |
affine.ty=geometry_info.sigma; |
| 13689 |
if ((flags & SigmaValue) == 0) |
| 13690 |
affine.ty=affine.tx; |
| 13691 |
break; |
| 13692 |
} |
| 13693 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13694 |
attribute); |
| 13695 |
break; |
| 13696 |
} |
| 13697 |
case 'w': |
| 13698 |
case 'W': |
| 13699 |
{ |
| 13700 |
if (LocaleCompare(attribute,"weight") == 0) |
| 13701 |
{ |
| 13702 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13703 |
draw_info->weight=(size_t) geometry_info.rho; |
| 13704 |
break; |
| 13705 |
} |
| 13706 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13707 |
attribute); |
| 13708 |
break; |
| 13709 |
} |
| 13710 |
case 'x': |
| 13711 |
case 'X': |
| 13712 |
{ |
| 13713 |
if (LocaleCompare(attribute,"x") == 0) |
| 13714 |
{ |
| 13715 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13716 |
x=geometry_info.rho; |
| 13717 |
break; |
| 13718 |
} |
| 13719 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13720 |
attribute); |
| 13721 |
break; |
| 13722 |
} |
| 13723 |
case 'y': |
| 13724 |
case 'Y': |
| 13725 |
{ |
| 13726 |
if (LocaleCompare(attribute,"y") == 0) |
| 13727 |
{ |
| 13728 |
flags=ParseGeometry(SvPV(ST(i),na),&geometry_info); |
| 13729 |
y=geometry_info.rho; |
| 13730 |
break; |
| 13731 |
} |
| 13732 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13733 |
attribute); |
| 13734 |
break; |
| 13735 |
} |
| 13736 |
default: |
| 13737 |
{ |
| 13738 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 13739 |
attribute); |
| 13740 |
break; |
| 13741 |
} |
| 13742 |
} |
| 13743 |
} |
| 13744 |
draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx; |
| 13745 |
draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx; |
| 13746 |
draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy; |
| 13747 |
draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy; |
| 13748 |
draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx; |
| 13749 |
draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty; |
| 13750 |
if (draw_info->geometry == (char *) NULL) |
| 13751 |
{ |
| 13752 |
draw_info->geometry=AcquireString((char *) NULL); |
| 13753 |
(void) FormatLocaleString(draw_info->geometry,MagickPathExtent, |
| 13754 |
"%.20g,%.20g",x,y); |
| 13755 |
} |
| 13756 |
status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception); |
| 13757 |
(void) CatchException(exception); |
| 13758 |
if (status == MagickFalse) |
| 13759 |
PUSHs(&sv_undef); |
| 13760 |
else |
| 13761 |
{ |
| 13762 |
PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x))); |
| 13763 |
PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y))); |
| 13764 |
PUSHs(sv_2mortal(newSVnv(metrics.ascent))); |
| 13765 |
PUSHs(sv_2mortal(newSVnv(metrics.descent))); |
| 13766 |
PUSHs(sv_2mortal(newSVnv(metrics.width))); |
| 13767 |
PUSHs(sv_2mortal(newSVnv(metrics.height))); |
| 13768 |
PUSHs(sv_2mortal(newSVnv(metrics.max_advance))); |
| 13769 |
PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1))); |
| 13770 |
PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1))); |
| 13771 |
PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2))); |
| 13772 |
PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2))); |
| 13773 |
PUSHs(sv_2mortal(newSVnv(metrics.origin.x))); |
| 13774 |
PUSHs(sv_2mortal(newSVnv(metrics.origin.y))); |
| 13775 |
} |
| 13776 |
draw_info=DestroyDrawInfo(draw_info); |
| 13777 |
|
| 13778 |
PerlException: |
| 13779 |
if (package_info != (struct PackageInfo *) NULL) |
| 13780 |
DestroyPackageInfo(package_info); |
| 13781 |
InheritPerlException(exception,perl_exception); |
| 13782 |
exception=DestroyExceptionInfo(exception); |
| 13783 |
SvREFCNT_dec(perl_exception); /* can't return warning messages */ |
| 13784 |
} |
| 13785 |
|
| 13786 |
# |
| 13787 |
############################################################################### |
| 13788 |
# # |
| 13789 |
# # |
| 13790 |
# # |
| 13791 |
# Q u e r y F o r m a t # |
| 13792 |
# # |
| 13793 |
# # |
| 13794 |
# # |
| 13795 |
############################################################################### |
| 13796 |
# |
| 13797 |
# |
| 13798 |
void |
| 13799 |
QueryFormat(ref,...) |
| 13800 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 13801 |
ALIAS: |
| 13802 |
queryformat = 1 |
| 13803 |
PPCODE: |
| 13804 |
{ |
| 13805 |
char |
| 13806 |
*name; |
| 13807 |
|
| 13808 |
ExceptionInfo |
| 13809 |
*exception; |
| 13810 |
|
| 13811 |
ssize_t |
| 13812 |
i; |
| 13813 |
|
| 13814 |
SV |
| 13815 |
*perl_exception; |
| 13816 |
|
| 13817 |
volatile const MagickInfo |
| 13818 |
*magick_info; |
| 13819 |
|
| 13820 |
PERL_UNUSED_VAR(ref); |
| 13821 |
PERL_UNUSED_VAR(ix); |
| 13822 |
exception=AcquireExceptionInfo(); |
| 13823 |
perl_exception=newSVpv("",0); |
| 13824 |
if (items == 1) |
| 13825 |
{ |
| 13826 |
char |
| 13827 |
format[MagickPathExtent]; |
| 13828 |
|
| 13829 |
const MagickInfo |
| 13830 |
**format_list; |
| 13831 |
|
| 13832 |
size_t |
| 13833 |
types; |
| 13834 |
|
| 13835 |
format_list=GetMagickInfoList("*",&types,exception); |
| 13836 |
EXTEND(sp,(ssize_t) types); |
| 13837 |
for (i=0; i < (ssize_t) types; i++) |
| 13838 |
{ |
| 13839 |
(void) CopyMagickString(format,format_list[i]->name,MagickPathExtent); |
| 13840 |
LocaleLower(format); |
| 13841 |
PUSHs(sv_2mortal(newSVpv(format,0))); |
| 13842 |
} |
| 13843 |
format_list=(const MagickInfo **) |
| 13844 |
RelinquishMagickMemory((MagickInfo *) format_list); |
| 13845 |
goto PerlException; |
| 13846 |
} |
| 13847 |
EXTEND(sp,8*items); |
| 13848 |
for (i=1; i < items; i++) |
| 13849 |
{ |
| 13850 |
name=(char *) SvPV(ST(i),na); |
| 13851 |
magick_info=GetMagickInfo(name,exception); |
| 13852 |
if (magick_info == (const MagickInfo *) NULL) |
| 13853 |
{ |
| 13854 |
PUSHs(&sv_undef); |
| 13855 |
continue; |
| 13856 |
} |
| 13857 |
if (magick_info->description == (char *) NULL) |
| 13858 |
PUSHs(&sv_undef); |
| 13859 |
else |
| 13860 |
PUSHs(sv_2mortal(newSVpv(magick_info->description,0))); |
| 13861 |
if (magick_info->magick_module == (char *) NULL) |
| 13862 |
PUSHs(&sv_undef); |
| 13863 |
else |
| 13864 |
PUSHs(sv_2mortal(newSVpv(magick_info->magick_module,0))); |
| 13865 |
} |
| 13866 |
|
| 13867 |
PerlException: |
| 13868 |
InheritPerlException(exception,perl_exception); |
| 13869 |
exception=DestroyExceptionInfo(exception); |
| 13870 |
SvREFCNT_dec(perl_exception); |
| 13871 |
} |
| 13872 |
|
| 13873 |
# |
| 13874 |
############################################################################### |
| 13875 |
# # |
| 13876 |
# # |
| 13877 |
# # |
| 13878 |
# Q u e r y O p t i o n # |
| 13879 |
# # |
| 13880 |
# # |
| 13881 |
# # |
| 13882 |
############################################################################### |
| 13883 |
# |
| 13884 |
# |
| 13885 |
void |
| 13886 |
QueryOption(ref,...) |
| 13887 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 13888 |
ALIAS: |
| 13889 |
queryoption = 1 |
| 13890 |
PPCODE: |
| 13891 |
{ |
| 13892 |
char |
| 13893 |
**options; |
| 13894 |
|
| 13895 |
ExceptionInfo |
| 13896 |
*exception; |
| 13897 |
|
| 13898 |
ssize_t |
| 13899 |
i, |
| 13900 |
j, |
| 13901 |
option; |
| 13902 |
|
| 13903 |
SV |
| 13904 |
*perl_exception; |
| 13905 |
|
| 13906 |
PERL_UNUSED_VAR(ref); |
| 13907 |
PERL_UNUSED_VAR(ix); |
| 13908 |
exception=AcquireExceptionInfo(); |
| 13909 |
perl_exception=newSVpv("",0); |
| 13910 |
EXTEND(sp,8*items); |
| 13911 |
for (i=1; i < items; i++) |
| 13912 |
{ |
| 13913 |
option=ParseCommandOption(MagickListOptions,MagickFalse,(char *) |
| 13914 |
SvPV(ST(i),na)); |
| 13915 |
options=GetCommandOptions((CommandOption) option); |
| 13916 |
if (options == (char **) NULL) |
| 13917 |
PUSHs(&sv_undef); |
| 13918 |
else |
| 13919 |
{ |
| 13920 |
for (j=0; options[j] != (char *) NULL; j++) |
| 13921 |
PUSHs(sv_2mortal(newSVpv(options[j],0))); |
| 13922 |
options=DestroyStringList(options); |
| 13923 |
} |
| 13924 |
} |
| 13925 |
|
| 13926 |
InheritPerlException(exception,perl_exception); |
| 13927 |
exception=DestroyExceptionInfo(exception); |
| 13928 |
SvREFCNT_dec(perl_exception); |
| 13929 |
} |
| 13930 |
|
| 13931 |
# |
| 13932 |
############################################################################### |
| 13933 |
# # |
| 13934 |
# # |
| 13935 |
# # |
| 13936 |
# R e a d # |
| 13937 |
# # |
| 13938 |
# # |
| 13939 |
# # |
| 13940 |
############################################################################### |
| 13941 |
# |
| 13942 |
# |
| 13943 |
void |
| 13944 |
Read(ref,...) |
| 13945 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 13946 |
ALIAS: |
| 13947 |
ReadImage = 1 |
| 13948 |
read = 2 |
| 13949 |
readimage = 3 |
| 13950 |
PPCODE: |
| 13951 |
{ |
| 13952 |
AV |
| 13953 |
*av; |
| 13954 |
|
| 13955 |
char |
| 13956 |
**keep, |
| 13957 |
**list, |
| 13958 |
**p; |
| 13959 |
|
| 13960 |
ExceptionInfo |
| 13961 |
*exception; |
| 13962 |
|
| 13963 |
HV |
| 13964 |
*hv; |
| 13965 |
|
| 13966 |
Image |
| 13967 |
*image; |
| 13968 |
|
| 13969 |
int |
| 13970 |
n; |
| 13971 |
|
| 13972 |
MagickBooleanType |
| 13973 |
status; |
| 13974 |
|
| 13975 |
ssize_t |
| 13976 |
ac, |
| 13977 |
i, |
| 13978 |
number_images; |
| 13979 |
|
| 13980 |
STRLEN |
| 13981 |
*length; |
| 13982 |
|
| 13983 |
struct PackageInfo |
| 13984 |
*info, |
| 13985 |
*package_info; |
| 13986 |
|
| 13987 |
SV |
| 13988 |
*perl_exception, /* Perl variable for storing messages */ |
| 13989 |
*reference, |
| 13990 |
*rv, |
| 13991 |
*sv; |
| 13992 |
|
| 13993 |
PERL_UNUSED_VAR(ref); |
| 13994 |
PERL_UNUSED_VAR(ix); |
| 13995 |
exception=AcquireExceptionInfo(); |
| 13996 |
perl_exception=newSVpv("",0); |
| 13997 |
sv=NULL; |
| 13998 |
package_info=(struct PackageInfo *) NULL; |
| 13999 |
number_images=0; |
| 14000 |
ac=(items < 2) ? 1 : items-1; |
| 14001 |
list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list)); |
| 14002 |
keep=list; |
| 14003 |
length=(STRLEN *) NULL; |
| 14004 |
if (list == (char **) NULL) |
| 14005 |
{ |
| 14006 |
ThrowPerlException(exception,ResourceLimitError, |
| 14007 |
"MemoryAllocationFailed",PackageName); |
| 14008 |
goto PerlException; |
| 14009 |
} |
| 14010 |
length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length)); |
| 14011 |
if (length == (STRLEN *) NULL) |
| 14012 |
{ |
| 14013 |
ThrowPerlException(exception,ResourceLimitError, |
| 14014 |
"MemoryAllocationFailed",PackageName); |
| 14015 |
goto PerlException; |
| 14016 |
} |
| 14017 |
if (sv_isobject(ST(0)) == 0) |
| 14018 |
{ |
| 14019 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 14020 |
PackageName); |
| 14021 |
goto PerlException; |
| 14022 |
} |
| 14023 |
reference=SvRV(ST(0)); |
| 14024 |
hv=SvSTASH(reference); |
| 14025 |
if (SvTYPE(reference) != SVt_PVAV) |
| 14026 |
{ |
| 14027 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 14028 |
PackageName); |
| 14029 |
goto PerlException; |
| 14030 |
} |
| 14031 |
av=(AV *) reference; |
| 14032 |
info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL, |
| 14033 |
exception); |
| 14034 |
package_info=ClonePackageInfo(info,exception); |
| 14035 |
n=1; |
| 14036 |
if (items <= 1) |
| 14037 |
*list=(char *) (*package_info->image_info->filename ? |
| 14038 |
package_info->image_info->filename : "XC:black"); |
| 14039 |
else |
| 14040 |
for (n=0, i=0; i < ac; i++) |
| 14041 |
{ |
| 14042 |
list[n]=(char *) SvPV(ST(i+1),length[n]); |
| 14043 |
if ((items >= 3) && strEQcase(list[n],"blob")) |
| 14044 |
{ |
| 14045 |
void |
| 14046 |
*blob; |
| 14047 |
|
| 14048 |
i++; |
| 14049 |
blob=(void *) (SvPV(ST(i+1),length[n])); |
| 14050 |
SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]); |
| 14051 |
} |
| 14052 |
if ((items >= 3) && strEQcase(list[n],"filename")) |
| 14053 |
continue; |
| 14054 |
if ((items >= 3) && strEQcase(list[n],"file")) |
| 14055 |
{ |
| 14056 |
FILE |
| 14057 |
*file; |
| 14058 |
|
| 14059 |
PerlIO |
| 14060 |
*io_info; |
| 14061 |
|
| 14062 |
i++; |
| 14063 |
io_info=IoIFP(sv_2io(ST(i+1))); |
| 14064 |
if (io_info == (PerlIO *) NULL) |
| 14065 |
{ |
| 14066 |
ThrowPerlException(exception,BlobError,"UnableToOpenFile", |
| 14067 |
PackageName); |
| 14068 |
continue; |
| 14069 |
} |
| 14070 |
file=PerlIO_findFILE(io_info); |
| 14071 |
if (file == (FILE *) NULL) |
| 14072 |
{ |
| 14073 |
ThrowPerlException(exception,BlobError,"UnableToOpenFile", |
| 14074 |
PackageName); |
| 14075 |
continue; |
| 14076 |
} |
| 14077 |
SetImageInfoFile(package_info->image_info,file); |
| 14078 |
} |
| 14079 |
if ((items >= 3) && strEQcase(list[n],"magick")) |
| 14080 |
continue; |
| 14081 |
n++; |
| 14082 |
} |
| 14083 |
list[n]=(char *) NULL; |
| 14084 |
keep=list; |
| 14085 |
status=ExpandFilenames(&n,&list); |
| 14086 |
if (status == MagickFalse) |
| 14087 |
{ |
| 14088 |
ThrowPerlException(exception,ResourceLimitError, |
| 14089 |
"MemoryAllocationFailed",PackageName); |
| 14090 |
goto PerlException; |
| 14091 |
} |
| 14092 |
number_images=0; |
| 14093 |
for (i=0; i < n; i++) |
| 14094 |
{ |
| 14095 |
if ((package_info->image_info->file == (FILE *) NULL) && |
| 14096 |
(package_info->image_info->blob == (void *) NULL)) |
| 14097 |
image=ReadImages(package_info->image_info,list[i],exception); |
| 14098 |
else |
| 14099 |
{ |
| 14100 |
image=ReadImages(package_info->image_info, |
| 14101 |
package_info->image_info->filename,exception); |
| 14102 |
if (image != (Image *) NULL) |
| 14103 |
DisassociateImageStream(image); |
| 14104 |
} |
| 14105 |
if (image == (Image *) NULL) |
| 14106 |
break; |
| 14107 |
for ( ; image; image=image->next) |
| 14108 |
{ |
| 14109 |
AddImageToRegistry(sv,image); |
| 14110 |
rv=newRV(sv); |
| 14111 |
av_push(av,sv_bless(rv,hv)); |
| 14112 |
SvREFCNT_dec(sv); |
| 14113 |
number_images++; |
| 14114 |
} |
| 14115 |
} |
| 14116 |
/* |
| 14117 |
Free resources. |
| 14118 |
*/ |
| 14119 |
for (i=0; i < n; i++) |
| 14120 |
if (list[i] != (char *) NULL) |
| 14121 |
for (p=keep; list[i] != *p++; ) |
| 14122 |
if (*p == (char *) NULL) |
| 14123 |
{ |
| 14124 |
list[i]=(char *) RelinquishMagickMemory(list[i]); |
| 14125 |
break; |
| 14126 |
} |
| 14127 |
|
| 14128 |
PerlException: |
| 14129 |
if (package_info != (struct PackageInfo *) NULL) |
| 14130 |
DestroyPackageInfo(package_info); |
| 14131 |
if (list && (list != keep)) |
| 14132 |
list=(char **) RelinquishMagickMemory(list); |
| 14133 |
if (keep) |
| 14134 |
keep=(char **) RelinquishMagickMemory(keep); |
| 14135 |
if (length) |
| 14136 |
length=(STRLEN *) RelinquishMagickMemory(length); |
| 14137 |
InheritPerlException(exception,perl_exception); |
| 14138 |
exception=DestroyExceptionInfo(exception); |
| 14139 |
sv_setiv(perl_exception,(IV) number_images); |
| 14140 |
SvPOK_on(perl_exception); |
| 14141 |
ST(0)=sv_2mortal(perl_exception); |
| 14142 |
XSRETURN(1); |
| 14143 |
} |
| 14144 |
|
| 14145 |
# |
| 14146 |
############################################################################### |
| 14147 |
# # |
| 14148 |
# # |
| 14149 |
# # |
| 14150 |
# R e m o t e # |
| 14151 |
# # |
| 14152 |
# # |
| 14153 |
# # |
| 14154 |
############################################################################### |
| 14155 |
# |
| 14156 |
# |
| 14157 |
void |
| 14158 |
Remote(ref,...) |
| 14159 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 14160 |
ALIAS: |
| 14161 |
RemoteCommand = 1 |
| 14162 |
remote = 2 |
| 14163 |
remoteCommand = 3 |
| 14164 |
PPCODE: |
| 14165 |
{ |
| 14166 |
AV |
| 14167 |
*av; |
| 14168 |
|
| 14169 |
ExceptionInfo |
| 14170 |
*exception; |
| 14171 |
|
| 14172 |
ssize_t |
| 14173 |
i; |
| 14174 |
|
| 14175 |
SV |
| 14176 |
*perl_exception, |
| 14177 |
*reference; |
| 14178 |
|
| 14179 |
struct PackageInfo |
| 14180 |
*info; |
| 14181 |
|
| 14182 |
PERL_UNUSED_VAR(ref); |
| 14183 |
PERL_UNUSED_VAR(ix); |
| 14184 |
exception=AcquireExceptionInfo(); |
| 14185 |
perl_exception=newSVpv("",0); |
| 14186 |
reference=SvRV(ST(0)); |
| 14187 |
av=(AV *) reference; |
| 14188 |
info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL, |
| 14189 |
exception); |
| 14190 |
for (i=1; i < items; i++) |
| 14191 |
(void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *) |
| 14192 |
SvPV(ST(i),na),exception); |
| 14193 |
InheritPerlException(exception,perl_exception); |
| 14194 |
exception=DestroyExceptionInfo(exception); |
| 14195 |
SvREFCNT_dec(perl_exception); /* throw away all errors */ |
| 14196 |
} |
| 14197 |
|
| 14198 |
# |
| 14199 |
############################################################################### |
| 14200 |
# # |
| 14201 |
# # |
| 14202 |
# # |
| 14203 |
# S e t # |
| 14204 |
# # |
| 14205 |
# # |
| 14206 |
# # |
| 14207 |
############################################################################### |
| 14208 |
# |
| 14209 |
# |
| 14210 |
void |
| 14211 |
Set(ref,...) |
| 14212 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 14213 |
ALIAS: |
| 14214 |
SetAttributes = 1 |
| 14215 |
SetAttribute = 2 |
| 14216 |
set = 3 |
| 14217 |
setattributes = 4 |
| 14218 |
setattribute = 5 |
| 14219 |
PPCODE: |
| 14220 |
{ |
| 14221 |
ExceptionInfo |
| 14222 |
*exception; |
| 14223 |
|
| 14224 |
Image |
| 14225 |
*image; |
| 14226 |
|
| 14227 |
ssize_t |
| 14228 |
i; |
| 14229 |
|
| 14230 |
struct PackageInfo |
| 14231 |
*info; |
| 14232 |
|
| 14233 |
SV |
| 14234 |
*perl_exception, |
| 14235 |
*reference; /* reference is the SV* of ref=SvIV(reference) */ |
| 14236 |
|
| 14237 |
PERL_UNUSED_VAR(ref); |
| 14238 |
PERL_UNUSED_VAR(ix); |
| 14239 |
exception=AcquireExceptionInfo(); |
| 14240 |
perl_exception=newSVpv("",0); |
| 14241 |
if (sv_isobject(ST(0)) == 0) |
| 14242 |
{ |
| 14243 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 14244 |
PackageName); |
| 14245 |
goto PerlException; |
| 14246 |
} |
| 14247 |
reference=SvRV(ST(0)); |
| 14248 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 14249 |
if (items == 2) |
| 14250 |
SetAttribute(aTHX_ info,image,"size",ST(1),exception); |
| 14251 |
else |
| 14252 |
for (i=2; i < items; i+=2) |
| 14253 |
SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception); |
| 14254 |
|
| 14255 |
PerlException: |
| 14256 |
InheritPerlException(exception,perl_exception); |
| 14257 |
exception=DestroyExceptionInfo(exception); |
| 14258 |
sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0)); |
| 14259 |
SvPOK_on(perl_exception); |
| 14260 |
ST(0)=sv_2mortal(perl_exception); |
| 14261 |
XSRETURN(1); |
| 14262 |
} |
| 14263 |
|
| 14264 |
# |
| 14265 |
############################################################################### |
| 14266 |
# # |
| 14267 |
# # |
| 14268 |
# # |
| 14269 |
# S e t P i x e l # |
| 14270 |
# # |
| 14271 |
# # |
| 14272 |
# # |
| 14273 |
############################################################################### |
| 14274 |
# |
| 14275 |
# |
| 14276 |
void |
| 14277 |
SetPixel(ref,...) |
| 14278 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 14279 |
ALIAS: |
| 14280 |
setpixel = 1 |
| 14281 |
setPixel = 2 |
| 14282 |
PPCODE: |
| 14283 |
{ |
| 14284 |
AV |
| 14285 |
*av; |
| 14286 |
|
| 14287 |
char |
| 14288 |
*attribute; |
| 14289 |
|
| 14290 |
ChannelType |
| 14291 |
channel, |
| 14292 |
channel_mask; |
| 14293 |
|
| 14294 |
ExceptionInfo |
| 14295 |
*exception; |
| 14296 |
|
| 14297 |
Image |
| 14298 |
*image; |
| 14299 |
|
| 14300 |
MagickBooleanType |
| 14301 |
normalize; |
| 14302 |
|
| 14303 |
RectangleInfo |
| 14304 |
region; |
| 14305 |
|
| 14306 |
Quantum |
| 14307 |
*q; |
| 14308 |
|
| 14309 |
ssize_t |
| 14310 |
i, |
| 14311 |
option; |
| 14312 |
|
| 14313 |
struct PackageInfo |
| 14314 |
*info; |
| 14315 |
|
| 14316 |
SV |
| 14317 |
*perl_exception, |
| 14318 |
*reference; /* reference is the SV* of ref=SvIV(reference) */ |
| 14319 |
|
| 14320 |
PERL_UNUSED_VAR(ref); |
| 14321 |
PERL_UNUSED_VAR(ix); |
| 14322 |
exception=AcquireExceptionInfo(); |
| 14323 |
perl_exception=newSVpv("",0); |
| 14324 |
reference=SvRV(ST(0)); |
| 14325 |
av=(AV *) reference; |
| 14326 |
info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL, |
| 14327 |
exception); |
| 14328 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 14329 |
if (image == (Image *) NULL) |
| 14330 |
{ |
| 14331 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 14332 |
PackageName); |
| 14333 |
goto PerlException; |
| 14334 |
} |
| 14335 |
av=(AV *) NULL; |
| 14336 |
normalize=MagickTrue; |
| 14337 |
region.x=0; |
| 14338 |
region.y=0; |
| 14339 |
region.width=image->columns; |
| 14340 |
region.height=1; |
| 14341 |
if (items == 1) |
| 14342 |
(void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion); |
| 14343 |
channel=DefaultChannels; |
| 14344 |
for (i=2; i < items; i+=2) |
| 14345 |
{ |
| 14346 |
attribute=(char *) SvPV(ST(i-1),na); |
| 14347 |
switch (*attribute) |
| 14348 |
{ |
| 14349 |
case 'C': |
| 14350 |
case 'c': |
| 14351 |
{ |
| 14352 |
if (LocaleCompare(attribute,"channel") == 0) |
| 14353 |
{ |
| 14354 |
ssize_t |
| 14355 |
option; |
| 14356 |
|
| 14357 |
option=ParseChannelOption(SvPV(ST(i),na)); |
| 14358 |
if (option < 0) |
| 14359 |
{ |
| 14360 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 14361 |
SvPV(ST(i),na)); |
| 14362 |
return; |
| 14363 |
} |
| 14364 |
channel=(ChannelType) option; |
| 14365 |
break; |
| 14366 |
} |
| 14367 |
if (LocaleCompare(attribute,"color") == 0) |
| 14368 |
{ |
| 14369 |
if (SvTYPE(ST(i)) != SVt_RV) |
| 14370 |
{ |
| 14371 |
char |
| 14372 |
message[MagickPathExtent]; |
| 14373 |
|
| 14374 |
(void) FormatLocaleString(message,MagickPathExtent, |
| 14375 |
"invalid %.60s value",attribute); |
| 14376 |
ThrowPerlException(exception,OptionError,message, |
| 14377 |
SvPV(ST(i),na)); |
| 14378 |
} |
| 14379 |
av=(AV *) SvRV(ST(i)); |
| 14380 |
break; |
| 14381 |
} |
| 14382 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 14383 |
attribute); |
| 14384 |
break; |
| 14385 |
} |
| 14386 |
case 'g': |
| 14387 |
case 'G': |
| 14388 |
{ |
| 14389 |
if (LocaleCompare(attribute,"geometry") == 0) |
| 14390 |
{ |
| 14391 |
(void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion); |
| 14392 |
break; |
| 14393 |
} |
| 14394 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 14395 |
attribute); |
| 14396 |
break; |
| 14397 |
} |
| 14398 |
case 'N': |
| 14399 |
case 'n': |
| 14400 |
{ |
| 14401 |
if (LocaleCompare(attribute,"normalize") == 0) |
| 14402 |
{ |
| 14403 |
option=ParseCommandOption(MagickBooleanOptions,MagickFalse, |
| 14404 |
SvPV(ST(i),na)); |
| 14405 |
if (option < 0) |
| 14406 |
{ |
| 14407 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 14408 |
SvPV(ST(i),na)); |
| 14409 |
break; |
| 14410 |
} |
| 14411 |
normalize=option != 0 ? MagickTrue : MagickFalse; |
| 14412 |
break; |
| 14413 |
} |
| 14414 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 14415 |
attribute); |
| 14416 |
break; |
| 14417 |
} |
| 14418 |
case 'x': |
| 14419 |
case 'X': |
| 14420 |
{ |
| 14421 |
if (LocaleCompare(attribute,"x") == 0) |
| 14422 |
{ |
| 14423 |
region.x=SvIV(ST(i)); |
| 14424 |
break; |
| 14425 |
} |
| 14426 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 14427 |
attribute); |
| 14428 |
break; |
| 14429 |
} |
| 14430 |
case 'y': |
| 14431 |
case 'Y': |
| 14432 |
{ |
| 14433 |
if (LocaleCompare(attribute,"y") == 0) |
| 14434 |
{ |
| 14435 |
region.y=SvIV(ST(i)); |
| 14436 |
break; |
| 14437 |
} |
| 14438 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 14439 |
attribute); |
| 14440 |
break; |
| 14441 |
} |
| 14442 |
default: |
| 14443 |
{ |
| 14444 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 14445 |
attribute); |
| 14446 |
break; |
| 14447 |
} |
| 14448 |
} |
| 14449 |
} |
| 14450 |
(void) SetImageStorageClass(image,DirectClass,exception); |
| 14451 |
channel_mask=SetImageChannelMask(image,channel); |
| 14452 |
q=GetAuthenticPixels(image,region.x,region.y,1,1,exception); |
| 14453 |
if ((q == (Quantum *) NULL) || (av == (AV *) NULL) || |
| 14454 |
(SvTYPE(av) != SVt_PVAV)) |
| 14455 |
PUSHs(&sv_undef); |
| 14456 |
else |
| 14457 |
{ |
| 14458 |
double |
| 14459 |
scale; |
| 14460 |
|
| 14461 |
ssize_t |
| 14462 |
i; |
| 14463 |
|
| 14464 |
i=0; |
| 14465 |
scale=1.0; |
| 14466 |
if (normalize != MagickFalse) |
| 14467 |
scale=QuantumRange; |
| 14468 |
if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) && |
| 14469 |
(i <= av_len(av))) |
| 14470 |
{ |
| 14471 |
SetPixelRed(image,ClampToQuantum(scale*SvNV(*( |
| 14472 |
av_fetch(av,i,0)))),q); |
| 14473 |
i++; |
| 14474 |
} |
| 14475 |
if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) && |
| 14476 |
(i <= av_len(av))) |
| 14477 |
{ |
| 14478 |
SetPixelGreen(image,ClampToQuantum(scale*SvNV(*( |
| 14479 |
av_fetch(av,i,0)))),q); |
| 14480 |
i++; |
| 14481 |
} |
| 14482 |
if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) && |
| 14483 |
(i <= av_len(av))) |
| 14484 |
{ |
| 14485 |
SetPixelBlue(image,ClampToQuantum(scale*SvNV(*( |
| 14486 |
av_fetch(av,i,0)))),q); |
| 14487 |
i++; |
| 14488 |
} |
| 14489 |
if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 14490 |
(image->colorspace == CMYKColorspace)) && (i <= av_len(av))) |
| 14491 |
{ |
| 14492 |
SetPixelBlack(image,ClampToQuantum(scale* |
| 14493 |
SvNV(*(av_fetch(av,i,0)))),q); |
| 14494 |
i++; |
| 14495 |
} |
| 14496 |
if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
| 14497 |
(i <= av_len(av))) |
| 14498 |
{ |
| 14499 |
SetPixelAlpha(image,ClampToQuantum(scale* |
| 14500 |
SvNV(*(av_fetch(av,i,0)))),q); |
| 14501 |
i++; |
| 14502 |
} |
| 14503 |
(void) SyncAuthenticPixels(image,exception); |
| 14504 |
} |
| 14505 |
(void) SetImageChannelMask(image,channel_mask); |
| 14506 |
|
| 14507 |
PerlException: |
| 14508 |
InheritPerlException(exception,perl_exception); |
| 14509 |
exception=DestroyExceptionInfo(exception); |
| 14510 |
SvREFCNT_dec(perl_exception); |
| 14511 |
} |
| 14512 |
|
| 14513 |
# |
| 14514 |
############################################################################### |
| 14515 |
# # |
| 14516 |
# # |
| 14517 |
# # |
| 14518 |
# S e t P i x e l s # |
| 14519 |
# # |
| 14520 |
# # |
| 14521 |
# # |
| 14522 |
############################################################################### |
| 14523 |
# |
| 14524 |
# |
| 14525 |
void |
| 14526 |
SetPixels(ref,...) |
| 14527 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 14528 |
ALIAS: |
| 14529 |
setpixels = 1 |
| 14530 |
setPixels = 2 |
| 14531 |
PPCODE: |
| 14532 |
{ |
| 14533 |
AV |
| 14534 |
*av; |
| 14535 |
|
| 14536 |
char |
| 14537 |
*attribute; |
| 14538 |
|
| 14539 |
ChannelType |
| 14540 |
channel, |
| 14541 |
channel_mask; |
| 14542 |
|
| 14543 |
ExceptionInfo |
| 14544 |
*exception; |
| 14545 |
|
| 14546 |
Image |
| 14547 |
*image; |
| 14548 |
|
| 14549 |
Quantum |
| 14550 |
*q; |
| 14551 |
|
| 14552 |
RectangleInfo |
| 14553 |
region; |
| 14554 |
|
| 14555 |
ssize_t |
| 14556 |
i; |
| 14557 |
|
| 14558 |
struct PackageInfo |
| 14559 |
*info; |
| 14560 |
|
| 14561 |
SV |
| 14562 |
*perl_exception, |
| 14563 |
*reference; /* reference is the SV* of ref=SvIV(reference) */ |
| 14564 |
|
| 14565 |
PERL_UNUSED_VAR(ref); |
| 14566 |
PERL_UNUSED_VAR(ix); |
| 14567 |
exception=AcquireExceptionInfo(); |
| 14568 |
perl_exception=newSVpv("",0); |
| 14569 |
reference=SvRV(ST(0)); |
| 14570 |
av=(AV *) reference; |
| 14571 |
info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL, |
| 14572 |
exception); |
| 14573 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 14574 |
if (image == (Image *) NULL) |
| 14575 |
{ |
| 14576 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 14577 |
PackageName); |
| 14578 |
goto PerlException; |
| 14579 |
} |
| 14580 |
av=(AV *) NULL; |
| 14581 |
region.x=0; |
| 14582 |
region.y=0; |
| 14583 |
region.width=image->columns; |
| 14584 |
region.height=1; |
| 14585 |
if (items == 1) |
| 14586 |
(void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion); |
| 14587 |
channel=DefaultChannels; |
| 14588 |
for (i=2; i < items; i+=2) |
| 14589 |
{ |
| 14590 |
attribute=(char *) SvPV(ST(i-1),na); |
| 14591 |
switch (*attribute) |
| 14592 |
{ |
| 14593 |
case 'C': |
| 14594 |
case 'c': |
| 14595 |
{ |
| 14596 |
if (LocaleCompare(attribute,"channel") == 0) |
| 14597 |
{ |
| 14598 |
ssize_t |
| 14599 |
option; |
| 14600 |
|
| 14601 |
option=ParseChannelOption(SvPV(ST(i),na)); |
| 14602 |
if (option < 0) |
| 14603 |
{ |
| 14604 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 14605 |
SvPV(ST(i),na)); |
| 14606 |
return; |
| 14607 |
} |
| 14608 |
channel=(ChannelType) option; |
| 14609 |
break; |
| 14610 |
} |
| 14611 |
if (LocaleCompare(attribute,"color") == 0) |
| 14612 |
{ |
| 14613 |
if (SvTYPE(ST(i)) != SVt_RV) |
| 14614 |
{ |
| 14615 |
char |
| 14616 |
message[MagickPathExtent]; |
| 14617 |
|
| 14618 |
(void) FormatLocaleString(message,MagickPathExtent, |
| 14619 |
"invalid %.60s value",attribute); |
| 14620 |
ThrowPerlException(exception,OptionError,message, |
| 14621 |
SvPV(ST(i),na)); |
| 14622 |
} |
| 14623 |
av=(AV *) SvRV(ST(i)); |
| 14624 |
break; |
| 14625 |
} |
| 14626 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 14627 |
attribute); |
| 14628 |
break; |
| 14629 |
} |
| 14630 |
case 'g': |
| 14631 |
case 'G': |
| 14632 |
{ |
| 14633 |
if (LocaleCompare(attribute,"geometry") == 0) |
| 14634 |
{ |
| 14635 |
(void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion); |
| 14636 |
break; |
| 14637 |
} |
| 14638 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 14639 |
attribute); |
| 14640 |
break; |
| 14641 |
} |
| 14642 |
case 'h': |
| 14643 |
case 'H': |
| 14644 |
{ |
| 14645 |
if (LocaleCompare(attribute,"height") == 0) |
| 14646 |
{ |
| 14647 |
region.height=(size_t) SvIV(ST(i)); |
| 14648 |
break; |
| 14649 |
} |
| 14650 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 14651 |
attribute); |
| 14652 |
break; |
| 14653 |
} |
| 14654 |
case 'w': |
| 14655 |
case 'W': |
| 14656 |
{ |
| 14657 |
if (LocaleCompare(attribute,"width") == 0) |
| 14658 |
{ |
| 14659 |
region.width=(size_t) SvIV(ST(i)); |
| 14660 |
break; |
| 14661 |
} |
| 14662 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 14663 |
attribute); |
| 14664 |
break; |
| 14665 |
} |
| 14666 |
case 'x': |
| 14667 |
case 'X': |
| 14668 |
{ |
| 14669 |
if (LocaleCompare(attribute,"x") == 0) |
| 14670 |
{ |
| 14671 |
region.x=SvIV(ST(i)); |
| 14672 |
break; |
| 14673 |
} |
| 14674 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 14675 |
attribute); |
| 14676 |
break; |
| 14677 |
} |
| 14678 |
case 'y': |
| 14679 |
case 'Y': |
| 14680 |
{ |
| 14681 |
if (LocaleCompare(attribute,"y") == 0) |
| 14682 |
{ |
| 14683 |
region.y=SvIV(ST(i)); |
| 14684 |
break; |
| 14685 |
} |
| 14686 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 14687 |
attribute); |
| 14688 |
break; |
| 14689 |
} |
| 14690 |
default: |
| 14691 |
{ |
| 14692 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 14693 |
attribute); |
| 14694 |
break; |
| 14695 |
} |
| 14696 |
} |
| 14697 |
} |
| 14698 |
(void) SetImageStorageClass(image,DirectClass,exception); |
| 14699 |
channel_mask=SetImageChannelMask(image,channel); |
| 14700 |
q=GetAuthenticPixels(image,region.x,region.y,region.width,region.height, |
| 14701 |
exception); |
| 14702 |
if ((q == (Quantum *) NULL) || (av == (AV *) NULL) || |
| 14703 |
(SvTYPE(av) != SVt_PVAV)) |
| 14704 |
PUSHs(&sv_undef); |
| 14705 |
else |
| 14706 |
{ |
| 14707 |
double |
| 14708 |
scale; |
| 14709 |
|
| 14710 |
ssize_t |
| 14711 |
i, |
| 14712 |
n, |
| 14713 |
number_pixels; |
| 14714 |
|
| 14715 |
i=0; |
| 14716 |
n=0; |
| 14717 |
scale=(double) QuantumRange; |
| 14718 |
number_pixels=(ssize_t) (region.width*region.height); |
| 14719 |
while ((n < number_pixels) && (i < av_len(av))) |
| 14720 |
{ |
| 14721 |
if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) && |
| 14722 |
(i <= av_len(av))) |
| 14723 |
{ |
| 14724 |
SetPixelRed(image,ClampToQuantum(scale*SvNV(*( |
| 14725 |
av_fetch(av,i,0)))),q); |
| 14726 |
i++; |
| 14727 |
} |
| 14728 |
if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) && |
| 14729 |
(i <= av_len(av))) |
| 14730 |
{ |
| 14731 |
SetPixelGreen(image,ClampToQuantum(scale*SvNV(*( |
| 14732 |
av_fetch(av,i,0)))),q); |
| 14733 |
i++; |
| 14734 |
} |
| 14735 |
if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) && |
| 14736 |
(i <= av_len(av))) |
| 14737 |
{ |
| 14738 |
SetPixelBlue(image,ClampToQuantum(scale*SvNV(*( |
| 14739 |
av_fetch(av,i,0)))),q); |
| 14740 |
i++; |
| 14741 |
} |
| 14742 |
if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && |
| 14743 |
(image->colorspace == CMYKColorspace)) && (i <= av_len(av))) |
| 14744 |
{ |
| 14745 |
SetPixelBlack(image,ClampToQuantum(scale* |
| 14746 |
SvNV(*(av_fetch(av,i,0)))),q); |
| 14747 |
i++; |
| 14748 |
} |
| 14749 |
if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && |
| 14750 |
(i <= av_len(av))) |
| 14751 |
{ |
| 14752 |
SetPixelAlpha(image,ClampToQuantum(scale* |
| 14753 |
SvNV(*(av_fetch(av,i,0)))),q); |
| 14754 |
i++; |
| 14755 |
} |
| 14756 |
n++; |
| 14757 |
q+=image->number_channels; |
| 14758 |
} |
| 14759 |
(void) SyncAuthenticPixels(image,exception); |
| 14760 |
} |
| 14761 |
(void) SetImageChannelMask(image,channel_mask); |
| 14762 |
|
| 14763 |
PerlException: |
| 14764 |
InheritPerlException(exception,perl_exception); |
| 14765 |
exception=DestroyExceptionInfo(exception); |
| 14766 |
SvREFCNT_dec(perl_exception); |
| 14767 |
} |
| 14768 |
|
| 14769 |
# |
| 14770 |
############################################################################### |
| 14771 |
# # |
| 14772 |
# # |
| 14773 |
# # |
| 14774 |
# S m u s h # |
| 14775 |
# # |
| 14776 |
# # |
| 14777 |
# # |
| 14778 |
############################################################################### |
| 14779 |
# |
| 14780 |
# |
| 14781 |
void |
| 14782 |
Smush(ref,...) |
| 14783 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 14784 |
ALIAS: |
| 14785 |
SmushImage = 1 |
| 14786 |
smush = 2 |
| 14787 |
smushimage = 3 |
| 14788 |
PPCODE: |
| 14789 |
{ |
| 14790 |
AV |
| 14791 |
*av; |
| 14792 |
|
| 14793 |
char |
| 14794 |
*attribute; |
| 14795 |
|
| 14796 |
ExceptionInfo |
| 14797 |
*exception; |
| 14798 |
|
| 14799 |
HV |
| 14800 |
*hv; |
| 14801 |
|
| 14802 |
Image |
| 14803 |
*image; |
| 14804 |
|
| 14805 |
ssize_t |
| 14806 |
i, |
| 14807 |
offset, |
| 14808 |
stack; |
| 14809 |
|
| 14810 |
struct PackageInfo |
| 14811 |
*info; |
| 14812 |
|
| 14813 |
SV |
| 14814 |
*av_reference, |
| 14815 |
*perl_exception, |
| 14816 |
*reference, |
| 14817 |
*rv, |
| 14818 |
*sv; |
| 14819 |
|
| 14820 |
PERL_UNUSED_VAR(ref); |
| 14821 |
PERL_UNUSED_VAR(ix); |
| 14822 |
exception=AcquireExceptionInfo(); |
| 14823 |
perl_exception=newSVpv("",0); |
| 14824 |
sv=NULL; |
| 14825 |
attribute=NULL; |
| 14826 |
av=NULL; |
| 14827 |
if (sv_isobject(ST(0)) == 0) |
| 14828 |
{ |
| 14829 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 14830 |
PackageName); |
| 14831 |
goto PerlException; |
| 14832 |
} |
| 14833 |
reference=SvRV(ST(0)); |
| 14834 |
hv=SvSTASH(reference); |
| 14835 |
av=newAV(); |
| 14836 |
av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv)); |
| 14837 |
SvREFCNT_dec(av); |
| 14838 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 14839 |
if (image == (Image *) NULL) |
| 14840 |
{ |
| 14841 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 14842 |
PackageName); |
| 14843 |
goto PerlException; |
| 14844 |
} |
| 14845 |
info=GetPackageInfo(aTHX_ (void *) av,info,exception); |
| 14846 |
/* |
| 14847 |
Get options. |
| 14848 |
*/ |
| 14849 |
offset=0; |
| 14850 |
stack=MagickTrue; |
| 14851 |
for (i=2; i < items; i+=2) |
| 14852 |
{ |
| 14853 |
attribute=(char *) SvPV(ST(i-1),na); |
| 14854 |
switch (*attribute) |
| 14855 |
{ |
| 14856 |
case 'O': |
| 14857 |
case 'o': |
| 14858 |
{ |
| 14859 |
if (LocaleCompare(attribute,"offset") == 0) |
| 14860 |
{ |
| 14861 |
offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na)); |
| 14862 |
break; |
| 14863 |
} |
| 14864 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 14865 |
attribute); |
| 14866 |
break; |
| 14867 |
} |
| 14868 |
case 'S': |
| 14869 |
case 's': |
| 14870 |
{ |
| 14871 |
if (LocaleCompare(attribute,"stack") == 0) |
| 14872 |
{ |
| 14873 |
stack=ParseCommandOption(MagickBooleanOptions,MagickFalse, |
| 14874 |
SvPV(ST(i),na)); |
| 14875 |
if (stack < 0) |
| 14876 |
{ |
| 14877 |
ThrowPerlException(exception,OptionError,"UnrecognizedType", |
| 14878 |
SvPV(ST(i),na)); |
| 14879 |
return; |
| 14880 |
} |
| 14881 |
break; |
| 14882 |
} |
| 14883 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 14884 |
attribute); |
| 14885 |
break; |
| 14886 |
} |
| 14887 |
default: |
| 14888 |
{ |
| 14889 |
ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", |
| 14890 |
attribute); |
| 14891 |
break; |
| 14892 |
} |
| 14893 |
} |
| 14894 |
} |
| 14895 |
image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset, |
| 14896 |
exception); |
| 14897 |
if (image == (Image *) NULL) |
| 14898 |
goto PerlException; |
| 14899 |
for ( ; image; image=image->next) |
| 14900 |
{ |
| 14901 |
AddImageToRegistry(sv,image); |
| 14902 |
rv=newRV(sv); |
| 14903 |
av_push(av,sv_bless(rv,hv)); |
| 14904 |
SvREFCNT_dec(sv); |
| 14905 |
} |
| 14906 |
exception=DestroyExceptionInfo(exception); |
| 14907 |
ST(0)=av_reference; |
| 14908 |
SvREFCNT_dec(perl_exception); |
| 14909 |
XSRETURN(1); |
| 14910 |
|
| 14911 |
PerlException: |
| 14912 |
InheritPerlException(exception,perl_exception); |
| 14913 |
exception=DestroyExceptionInfo(exception); |
| 14914 |
sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); |
| 14915 |
SvPOK_on(perl_exception); |
| 14916 |
ST(0)=sv_2mortal(perl_exception); |
| 14917 |
XSRETURN(1); |
| 14918 |
} |
| 14919 |
|
| 14920 |
# |
| 14921 |
############################################################################### |
| 14922 |
# # |
| 14923 |
# # |
| 14924 |
# # |
| 14925 |
# S t a t i s t i c s # |
| 14926 |
# # |
| 14927 |
# # |
| 14928 |
# # |
| 14929 |
############################################################################### |
| 14930 |
# |
| 14931 |
# |
| 14932 |
void |
| 14933 |
Statistics(ref) |
| 14934 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 14935 |
ALIAS: |
| 14936 |
StatisticsImage = 1 |
| 14937 |
statistics = 2 |
| 14938 |
statisticsimage = 3 |
| 14939 |
PPCODE: |
| 14940 |
{ |
| 14941 |
#define ChannelStatistics(channel) \ |
| 14942 |
{ \ |
| 14943 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 14944 |
(double) channel_statistics[channel].depth); \ |
| 14945 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 14946 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 14947 |
channel_statistics[channel].minima/QuantumRange); \ |
| 14948 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 14949 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 14950 |
channel_statistics[channel].maxima/QuantumRange); \ |
| 14951 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 14952 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 14953 |
channel_statistics[channel].mean/QuantumRange); \ |
| 14954 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 14955 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 14956 |
channel_statistics[channel].standard_deviation/QuantumRange); \ |
| 14957 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 14958 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 14959 |
channel_statistics[channel].kurtosis); \ |
| 14960 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 14961 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 14962 |
channel_statistics[channel].skewness); \ |
| 14963 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 14964 |
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ |
| 14965 |
channel_statistics[channel].entropy); \ |
| 14966 |
PUSHs(sv_2mortal(newSVpv(message,0))); \ |
| 14967 |
} |
| 14968 |
|
| 14969 |
AV |
| 14970 |
*av; |
| 14971 |
|
| 14972 |
char |
| 14973 |
message[MagickPathExtent]; |
| 14974 |
|
| 14975 |
ChannelStatistics |
| 14976 |
*channel_statistics; |
| 14977 |
|
| 14978 |
ExceptionInfo |
| 14979 |
*exception; |
| 14980 |
|
| 14981 |
Image |
| 14982 |
*image; |
| 14983 |
|
| 14984 |
ssize_t |
| 14985 |
count; |
| 14986 |
|
| 14987 |
struct PackageInfo |
| 14988 |
*info; |
| 14989 |
|
| 14990 |
SV |
| 14991 |
*perl_exception, |
| 14992 |
*reference; |
| 14993 |
|
| 14994 |
PERL_UNUSED_VAR(ref); |
| 14995 |
PERL_UNUSED_VAR(ix); |
| 14996 |
exception=AcquireExceptionInfo(); |
| 14997 |
perl_exception=newSVpv("",0); |
| 14998 |
av=NULL; |
| 14999 |
if (sv_isobject(ST(0)) == 0) |
| 15000 |
{ |
| 15001 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 15002 |
PackageName); |
| 15003 |
goto PerlException; |
| 15004 |
} |
| 15005 |
reference=SvRV(ST(0)); |
| 15006 |
av=newAV(); |
| 15007 |
SvREFCNT_dec(av); |
| 15008 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 15009 |
if (image == (Image *) NULL) |
| 15010 |
{ |
| 15011 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 15012 |
PackageName); |
| 15013 |
goto PerlException; |
| 15014 |
} |
| 15015 |
count=0; |
| 15016 |
for ( ; image; image=image->next) |
| 15017 |
{ |
| 15018 |
ssize_t |
| 15019 |
i; |
| 15020 |
|
| 15021 |
channel_statistics=GetImageStatistics(image,exception); |
| 15022 |
if (channel_statistics == (ChannelStatistics *) NULL) |
| 15023 |
continue; |
| 15024 |
count++; |
| 15025 |
for (i=0; i < (ssize_t) GetPixelChannels(image); i++) |
| 15026 |
{ |
| 15027 |
PixelChannel channel=GetPixelChannelChannel(image,i); |
| 15028 |
PixelTrait traits=GetPixelChannelTraits(image,channel); |
| 15029 |
if (traits == UndefinedPixelTrait) |
| 15030 |
continue; |
| 15031 |
EXTEND(sp,8*(i+1)*count); |
| 15032 |
ChannelStatistics(channel); |
| 15033 |
} |
| 15034 |
EXTEND(sp,8*(i+1)*count); |
| 15035 |
ChannelStatistics(CompositePixelChannel); |
| 15036 |
channel_statistics=(ChannelStatistics *) |
| 15037 |
RelinquishMagickMemory(channel_statistics); |
| 15038 |
} |
| 15039 |
|
| 15040 |
PerlException: |
| 15041 |
InheritPerlException(exception,perl_exception); |
| 15042 |
exception=DestroyExceptionInfo(exception); |
| 15043 |
SvREFCNT_dec(perl_exception); |
| 15044 |
} |
| 15045 |
|
| 15046 |
# |
| 15047 |
############################################################################### |
| 15048 |
# # |
| 15049 |
# # |
| 15050 |
# # |
| 15051 |
# S y n c A u t h e n t i c P i x e l s # |
| 15052 |
# # |
| 15053 |
# # |
| 15054 |
# # |
| 15055 |
############################################################################### |
| 15056 |
# |
| 15057 |
# |
| 15058 |
void |
| 15059 |
SyncAuthenticPixels(ref,...) |
| 15060 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 15061 |
ALIAS: |
| 15062 |
Syncauthenticpixels = 1 |
| 15063 |
SyncImagePixels = 2 |
| 15064 |
syncimagepixels = 3 |
| 15065 |
CODE: |
| 15066 |
{ |
| 15067 |
ExceptionInfo |
| 15068 |
*exception; |
| 15069 |
|
| 15070 |
Image |
| 15071 |
*image; |
| 15072 |
|
| 15073 |
MagickBooleanType |
| 15074 |
status; |
| 15075 |
|
| 15076 |
struct PackageInfo |
| 15077 |
*info; |
| 15078 |
|
| 15079 |
SV |
| 15080 |
*perl_exception, |
| 15081 |
*reference; |
| 15082 |
|
| 15083 |
PERL_UNUSED_VAR(ref); |
| 15084 |
PERL_UNUSED_VAR(ix); |
| 15085 |
exception=AcquireExceptionInfo(); |
| 15086 |
perl_exception=newSVpv("",0); |
| 15087 |
if (sv_isobject(ST(0)) == 0) |
| 15088 |
{ |
| 15089 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 15090 |
PackageName); |
| 15091 |
goto PerlException; |
| 15092 |
} |
| 15093 |
|
| 15094 |
reference=SvRV(ST(0)); |
| 15095 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 15096 |
if (image == (Image *) NULL) |
| 15097 |
{ |
| 15098 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 15099 |
PackageName); |
| 15100 |
goto PerlException; |
| 15101 |
} |
| 15102 |
|
| 15103 |
status=SyncAuthenticPixels(image,exception); |
| 15104 |
if (status != MagickFalse) |
| 15105 |
return; |
| 15106 |
|
| 15107 |
PerlException: |
| 15108 |
InheritPerlException(exception,perl_exception); |
| 15109 |
exception=DestroyExceptionInfo(exception); |
| 15110 |
SvREFCNT_dec(perl_exception); /* throw away all errors */ |
| 15111 |
} |
| 15112 |
|
| 15113 |
|
| 15114 |
# |
| 15115 |
############################################################################### |
| 15116 |
# # |
| 15117 |
# # |
| 15118 |
# # |
| 15119 |
# W r i t e # |
| 15120 |
# # |
| 15121 |
# # |
| 15122 |
# # |
| 15123 |
############################################################################### |
| 15124 |
# |
| 15125 |
# |
| 15126 |
void |
| 15127 |
Write(ref,...) |
| 15128 |
Image::Magick::Q16HDRI ref = NO_INIT |
| 15129 |
ALIAS: |
| 15130 |
WriteImage = 1 |
| 15131 |
write = 2 |
| 15132 |
writeimage = 3 |
| 15133 |
PPCODE: |
| 15134 |
{ |
| 15135 |
char |
| 15136 |
filename[MagickPathExtent]; |
| 15137 |
|
| 15138 |
ExceptionInfo |
| 15139 |
*exception; |
| 15140 |
|
| 15141 |
Image |
| 15142 |
*image, |
| 15143 |
*next; |
| 15144 |
|
| 15145 |
ssize_t |
| 15146 |
i, |
| 15147 |
number_images, |
| 15148 |
scene; |
| 15149 |
|
| 15150 |
struct PackageInfo |
| 15151 |
*info, |
| 15152 |
*package_info; |
| 15153 |
|
| 15154 |
SV |
| 15155 |
*perl_exception, |
| 15156 |
*reference; |
| 15157 |
|
| 15158 |
PERL_UNUSED_VAR(ref); |
| 15159 |
PERL_UNUSED_VAR(ix); |
| 15160 |
exception=AcquireExceptionInfo(); |
| 15161 |
perl_exception=newSVpv("",0); |
| 15162 |
number_images=0; |
| 15163 |
package_info=(struct PackageInfo *) NULL; |
| 15164 |
if (sv_isobject(ST(0)) == 0) |
| 15165 |
{ |
| 15166 |
ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", |
| 15167 |
PackageName); |
| 15168 |
goto PerlException; |
| 15169 |
} |
| 15170 |
reference=SvRV(ST(0)); |
| 15171 |
image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); |
| 15172 |
if (image == (Image *) NULL) |
| 15173 |
{ |
| 15174 |
ThrowPerlException(exception,OptionError,"NoImagesDefined", |
| 15175 |
PackageName); |
| 15176 |
goto PerlException; |
| 15177 |
} |
| 15178 |
scene=0; |
| 15179 |
for (next=image; next; next=next->next) |
| 15180 |
next->scene=(size_t) scene++; |
| 15181 |
package_info=ClonePackageInfo(info,exception); |
| 15182 |
if (items == 2) |
| 15183 |
SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception); |
| 15184 |
else |
| 15185 |
if (items > 2) |
| 15186 |
for (i=2; i < items; i+=2) |
| 15187 |
SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i), |
| 15188 |
exception); |
| 15189 |
(void) CopyMagickString(filename,package_info->image_info->filename, |
| 15190 |
MagickPathExtent); |
| 15191 |
for (next=image; next; next=next->next) |
| 15192 |
(void) CopyMagickString(next->filename,filename,MagickPathExtent); |
| 15193 |
*package_info->image_info->magick='\0'; |
| 15194 |
SetImageInfo(package_info->image_info,(unsigned int) |
| 15195 |
GetImageListLength(image),exception); |
| 15196 |
for (next=image; next; next=next->next) |
| 15197 |
{ |
| 15198 |
(void) WriteImage(package_info->image_info,next,exception); |
| 15199 |
number_images++; |
| 15200 |
if (package_info->image_info->adjoin) |
| 15201 |
break; |
| 15202 |
} |
| 15203 |
|
| 15204 |
PerlException: |
| 15205 |
if (package_info != (struct PackageInfo *) NULL) |
| 15206 |
DestroyPackageInfo(package_info); |
| 15207 |
InheritPerlException(exception,perl_exception); |
| 15208 |
exception=DestroyExceptionInfo(exception); |
| 15209 |
sv_setiv(perl_exception,(IV) number_images); |
| 15210 |
SvPOK_on(perl_exception); |
| 15211 |
ST(0)=sv_2mortal(perl_exception); |
| 15212 |
XSRETURN(1); |
| 15213 |
} |