Powered by Pair ImageMagick logo
Image Magick
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages

ImageMagick-6.1.1/PerlMagick/Magick.c

Go to the documentation of this file.
00001 /* 00002 * This file was generated automatically by xsubpp version 1.9508 from the 00003 * contents of Magick.xs. Do not edit this file, edit Magick.xs instead. 00004 * 00005 * ANY CHANGES MADE HERE WILL BE LOST! 00006 * 00007 */ 00008 00009 #line 1 "Magick.xs" 00010 /* 00011 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00012 % % 00013 % % 00014 % PPPP EEEEE RRRR L % 00015 % P P E R R L % 00016 % PPPP EEE RRRR L % 00017 % P E R R L % 00018 % P EEEEE R R LLLLL % 00019 % % 00020 % M M AAA GGGG IIIII CCCC K K % 00021 % MM MM A A G I C K K % 00022 % M M M AAAAA G GGG I C KKK % 00023 % M M A A G G I C K K % 00024 % M M A A GGGG IIIII CCCC K K % 00025 % % 00026 % % 00027 % Object-oriented Perl interface to ImageMagick % 00028 % % 00029 % Software Design % 00030 % Kyle Shorter % 00031 % John Cristy % 00032 % February 1997 % 00033 % % 00034 % % 00035 % Copyright 1999-2004 ImageMagick Studio LLC, a non-profit organization % 00036 % dedicated to making software imaging solutions freely available. % 00037 % % 00038 % You may not use this file except in compliance with the License. You may % 00039 % obtain a copy of the License at % 00040 % % 00041 % http://www.imagemagick.org/www/Copyright.html % 00042 % % 00043 % Unless required by applicable law or agreed to in writing, software % 00044 % distributed under the License is distributed on an "AS IS" BASIS, % 00045 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % 00046 % See the License for the specific language governing permissions and % 00047 % limitations under the License. % 00048 % % 00049 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00050 % 00051 % PerlMagick is an objected-oriented Perl interface to ImageMagick. Use 00052 % the module to read, manipulate, or write an image or image sequence from 00053 % within a Perl script. This makes PerlMagick suitable for Web CGI scripts. 00054 % 00055 */ 00056 00057 /* 00058 Include declarations. 00059 */ 00060 #if !defined(WIN32) 00061 #define MagickExport 00062 #endif 00063 00064 #ifdef __cplusplus 00065 extern "C" { 00066 #endif 00067 #define PERL_NO_GET_CONTEXT /* faster */ 00068 #include "EXTERN.h" 00069 #include "perl.h" 00070 #include "XSUB.h" 00071 #include <math.h> 00072 #include <magick/api.h> 00073 #undef tainted 00074 #if !defined(__WINDOWS__) 00075 #include <magick/xwindow.h> 00076 #include <setjmp.h> 00077 #else 00078 #undef setjmp 00079 #undef longjmp 00080 #include <setjmpex.h> 00081 #endif 00082 00083 #ifdef __cplusplus 00084 } 00085 #endif 00086 00087 /* 00088 Define declarations. 00089 */ 00090 #ifndef aTHX_ 00091 #define aTHX_ 00092 #define pTHX_ 00093 #define dTHX 00094 #endif 00095 #define EndOf(array) (&array[NumberOf(array)]) 00096 #define MaxArguments 28 00097 #define MY_CXT_KEY PackageName "::ContextKey_" XS_VERSION 00098 #ifndef START_MY_CXT 00099 #define MY_CXT_INIT 00100 #define MY_CXT my_cxt 00101 #define dMY_CXT 00102 #endif 00103 #ifndef na 00104 #define na PL_na 00105 #endif 00106 #define NumberOf(array) (sizeof(array)/sizeof(*array)) 00107 #define PackageName "Image::Magick" 00108 #ifndef sv_undef 00109 #define sv_undef PL_sv_undef 00110 #endif 00111 #define ThrowPerlException(severity,tag,reason) \ 00112 { \ 00113 ExceptionInfo \ 00114 exception; \ 00115 \ 00116 GetExceptionInfo(&exception); \ 00117 (void) ThrowMagickException(&exception,GetMagickModule(),severity, \ 00118 tag,reason); \ 00119 CatchException(&exception); \ 00120 DestroyExceptionInfo(&exception); \ 00121 } 00122 00123 /* 00124 Typedef and structure declarations. 00125 */ 00126 typedef enum 00127 { 00128 ArrayReference = (~0), 00129 RealReference = (~0)-1, 00130 FileReference = (~0)-2, 00131 ImageReference = (~0)-3, 00132 IntegerReference = (~0)-4, 00133 StringReference = (~0)-5 00134 } MagickReference; 00135 00136 typedef struct _Arguments 00137 { 00138 char 00139 *method; 00140 00141 long 00142 type; 00143 } Arguments; 00144 00145 struct ArgumentList 00146 { 00147 long 00148 long_reference; 00149 00150 MagickRealType 00151 real_reference; 00152 00153 char 00154 *string_reference; 00155 00156 Image 00157 *image_reference; 00158 00159 SV 00160 *array_reference; 00161 00162 FILE 00163 *file_reference; 00164 00165 size_t 00166 length; 00167 }; 00168 00169 typedef struct _my_cxt_t 00170 { 00171 jmp_buf 00172 *error_jump; /* long jump return for FATAL errors */ 00173 00174 SV 00175 *error_list; /* Perl variable for storing messages */ 00176 } my_cxt_t; 00177 00178 struct PackageInfo 00179 { 00180 ImageInfo 00181 *image_info; 00182 00183 DrawInfo 00184 *draw_info; 00185 00186 QuantizeInfo 00187 *quantize_info; 00188 }; 00189 00190 typedef void 00191 *Image__Magick; /* data type for the Image::Magick package */ 00192 00193 /* 00194 Static declarations. 00195 */ 00196 static struct 00197 Methods 00198 { 00199 char 00200 *name; 00201 00202 Arguments 00203 arguments[MaxArguments]; 00204 } Methods[] = 00205 { 00206 { "comment", { {"comment", StringReference} } }, 00207 { "label", { {"label", StringReference} } }, 00208 { "AddNoise", { {"noise", MagickNoiseOptions} } }, 00209 { "Colorize", { {"fill", StringReference}, {"opacity", StringReference} } }, 00210 { "Border", { {"geometry", StringReference}, {"width", IntegerReference}, 00211 {"height", IntegerReference}, {"fill", StringReference}, 00212 {"color", StringReference} } }, 00213 { "Blur", { {"geometry", StringReference}, {"radius", RealReference}, 00214 {"sigma", RealReference}, {"channel", MagickChannelOptions} } }, 00215 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference}, 00216 {"height", IntegerReference}, {"x", IntegerReference}, 00217 {"y", IntegerReference} } }, 00218 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference}, 00219 {"height", IntegerReference}, {"x", IntegerReference}, 00220 {"y", IntegerReference}, {"fuzz", StringReference} } }, 00221 { "Despeckle", }, 00222 { "Edge", { {"radius", RealReference} } }, 00223 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference}, 00224 {"sigma", RealReference} } }, 00225 { "Enhance", }, 00226 { "Flip", }, 00227 { "Flop", }, 00228 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference}, 00229 {"height", IntegerReference}, {"inner", IntegerReference}, 00230 {"outer", IntegerReference}, {"fill", StringReference}, 00231 {"color", StringReference} } }, 00232 { "Implode", { {"amount", RealReference} } }, 00233 { "Magnify", }, 00234 { "MedianFilter", { {"radius", RealReference} } }, 00235 { "Minify", }, 00236 { "OilPaint", { {"radius", RealReference} } }, 00237 { "ReduceNoise", { {"radius", RealReference} } }, 00238 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference}, 00239 {"y", IntegerReference} } }, 00240 { "Rotate", { {"degrees", RealReference}, 00241 {"color", StringReference} } }, 00242 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference}, 00243 {"height", IntegerReference} } }, 00244 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference}, 00245 {"height", IntegerReference} } }, 00246 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference}, 00247 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } }, 00248 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference}, 00249 {"sigma", RealReference}, {"channel", MagickChannelOptions} } }, 00250 { "Shear", { {"geometry", StringReference}, {"x", IntegerReference}, 00251 {"y", RealReference}, {"color", StringReference} } }, 00252 { "Spread", { {"radius", RealReference} } }, 00253 { "Swirl", { {"degrees", RealReference} } }, 00254 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference}, 00255 {"height", IntegerReference}, {"filter", MagickFilterOptions}, 00256 {"blur", RealReference } } }, 00257 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference}, 00258 {"height", IntegerReference}, {"filter", MagickFilterOptions}, 00259 {"blur", RealReference } } }, 00260 { "Annotate", { {"text", StringReference}, {"font", StringReference}, 00261 {"point", RealReference}, {"density", StringReference}, 00262 {"undercolor", StringReference}, {"stroke", StringReference}, 00263 {"fill", StringReference}, {"geometry", StringReference}, 00264 {"sans", StringReference}, {"x", RealReference}, 00265 {"y", RealReference}, {"gravity", MagickGravityOptions}, 00266 {"translate", StringReference}, {"scale", StringReference}, 00267 {"rotate", RealReference}, {"skewX", RealReference}, 00268 {"skewY", RealReference}, {"strokewidth", IntegerReference}, 00269 {"antialias", MagickBooleanOptions}, {"family", StringReference}, 00270 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions}, 00271 {"weight", IntegerReference}, {"align", MagickAlignOptions}, 00272 {"encoding", StringReference}, {"affine", ArrayReference}, 00273 {"pen", StringReference} } }, 00274 { "ColorFloodfill", { {"geometry", StringReference}, 00275 {"x", IntegerReference}, {"y", IntegerReference}, 00276 {"fill", StringReference}, {"bordercolor", StringReference}, 00277 {"fuzz", StringReference} } }, 00278 { "Composite", { {"image", ImageReference}, 00279 {"compose", MagickCompositeOptions}, {"geometry", StringReference}, 00280 {"x", IntegerReference}, {"y", IntegerReference}, 00281 {"gravity", MagickGravityOptions}, {"opacity", StringReference}, 00282 {"tile", MagickBooleanOptions}, {"rotate", RealReference}, 00283 {"color", StringReference}, {"mask", ImageReference} } }, 00284 { "Contrast", { {"sharp", MagickBooleanOptions} } }, 00285 { "CycleColormap", { {"display", IntegerReference} } }, 00286 { "Draw", { {"primitive", MagickPrimitiveOptions}, 00287 {"points", StringReference}, {"method", MagickMethodOptions}, 00288 {"stroke", StringReference}, {"fill", StringReference}, 00289 {"strokewidth", RealReference}, {"font", StringReference}, 00290 {"bordercolor", StringReference}, {"x", RealReference}, 00291 {"y", RealReference}, {"translate", StringReference}, 00292 {"scale", StringReference}, {"rotate", RealReference}, 00293 {"skewX", RealReference}, {"skewY", RealReference}, 00294 {"tile", ImageReference}, {"pointsize", RealReference}, 00295 {"antialias", MagickBooleanOptions}, {"density", StringReference}, 00296 {"linewidth", RealReference}, {"affine", ArrayReference} } }, 00297 { "Equalize", }, 00298 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions}, 00299 {"red", RealReference}, {"green", RealReference}, 00300 {"blue", RealReference} } }, 00301 { "Map", { {"image", ImageReference}, {"dither", MagickBooleanOptions} } }, 00302 { "MatteFloodfill", { {"geometry", StringReference}, 00303 {"x", IntegerReference}, {"y", IntegerReference}, 00304 {"opacity", StringReference}, {"bordercolor", StringReference}, 00305 {"fuzz", StringReference} } }, 00306 { "Modulate", { {"factor", StringReference}, {"hue", RealReference}, 00307 {"saturation", RealReference}, {"whiteness", RealReference}, 00308 {"brightness", RealReference}, {"luminosity", RealReference}, 00309 {"blackness", RealReference} } }, 00310 { "Negate", { {"gray", MagickBooleanOptions}, 00311 {"channel", MagickChannelOptions} } }, 00312 { "Normalize", }, 00313 { "NumberColors", }, 00314 { "Opaque", { {"color", StringReference}, {"fill", StringReference}, 00315 {"fuzz", StringReference} } }, 00316 { "Quantize", { {"colors", IntegerReference}, {"tree", IntegerReference}, 00317 {"colorspace", MagickColorspaceOptions}, 00318 {"dither", MagickBooleanOptions}, {"measure", MagickBooleanOptions}, 00319 {"global", MagickBooleanOptions} } }, 00320 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference}, 00321 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } }, 00322 { "Segment", { {"geometry", StringReference}, {"cluster", RealReference}, 00323 {"smooth", RealReference}, {"colorspace", MagickColorspaceOptions}, 00324 {"verbose", MagickBooleanOptions} } }, 00325 { "Signature", }, 00326 { "Solarize", { {"threshold", RealReference} } }, 00327 { "Sync", }, 00328 { "Texture", { {"texture", ImageReference} } }, 00329 { "Evaluate", { {"value", RealReference}, 00330 {"operator", MagickEvaluateOptions}, 00331 {"channel", MagickChannelOptions} } }, 00332 { "Transparent", { {"color", StringReference}, 00333 {"opacity", StringReference}, {"fuzz", StringReference} } }, 00334 { "Threshold", { {"threshold", StringReference}, 00335 {"channel", MagickChannelOptions} } }, 00336 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference}, 00337 {"sigma", RealReference} } }, 00338 { "Trim", { {"fuzz", StringReference} } }, 00339 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference}, 00340 {"wavelength", RealReference} } }, 00341 { "Separate", { {"channel", MagickChannelOptions} } }, 00342 { "Condense", }, 00343 { "Stereo", { {"image", ImageReference} } }, 00344 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } }, 00345 { "Deconstruct", }, 00346 { "GaussianBlur", { {"geometry", StringReference}, 00347 {"radius", RealReference}, {"sigma", RealReference}, 00348 {"channel", MagickChannelOptions} } }, 00349 { "Convolve", { {"coefficients", ArrayReference}, 00350 {"channel", MagickChannelOptions}, {"bias", StringReference} } }, 00351 { "Profile", { {"name", StringReference}, {"profile", StringReference} } }, 00352 { "UnsharpMask", { {"geometry", StringReference}, 00353 {"radius", RealReference}, {"sigma", RealReference}, 00354 {"amount", RealReference}, {"threshold", RealReference}, 00355 {"channel", MagickChannelOptions} } }, 00356 { "MotionBlur", { {"geometry", StringReference}, 00357 {"radius", RealReference}, {"sigma", RealReference}, 00358 {"angle", RealReference} } }, 00359 { "OrderedDither", }, 00360 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference}, 00361 {"height", IntegerReference} } }, 00362 { "Level", { {"level", StringReference}, {"black-point", RealReference}, 00363 {"white-point", RealReference}, {"gamma", RealReference}, 00364 {"channel", MagickChannelOptions} } }, 00365 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } }, 00366 { "AffineTransform", { {"affine", ArrayReference}, 00367 {"translate", StringReference}, {"scale", StringReference}, 00368 {"rotate", RealReference}, {"skewX", RealReference}, 00369 {"skewY", RealReference} } }, 00370 { "Compare", { {"image", ImageReference} } }, 00371 { "AdaptiveThreshold", { {"geometry", StringReference}, 00372 {"width", IntegerReference}, {"height", IntegerReference}, 00373 {"offset", IntegerReference} } }, 00374 { "Resample", { {"density", StringReference}, {"x", RealReference}, 00375 {"y", RealReference}, {"filter", MagickFilterOptions}, 00376 {"blur", RealReference } } }, 00377 { "Describe", { {"file", FileReference} } }, 00378 { "BlackThreshold", { {"threshold", StringReference} } }, 00379 { "WhiteThreshold", { {"threshold", StringReference} } }, 00380 { "RadialBlur", { {"angle", RealReference} } }, 00381 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference}, 00382 {"height", IntegerReference} } }, 00383 { "Strip", }, 00384 { "Tint", { {"fill", StringReference}, {"opacity", StringReference} } }, 00385 { "Channel", { {"channel", MagickChannelOptions} } }, 00386 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference}, 00387 {"height", IntegerReference}, {"x", IntegerReference}, 00388 {"y", IntegerReference}, {"fuzz", StringReference} } }, 00389 { "Posterize", { {"levels", IntegerReference}, 00390 {"dither", MagickBooleanOptions} } }, 00391 }; 00392 00393 #ifdef START_MY_CXT 00394 START_MY_CXT 00395 #else 00396 static my_cxt_t 00397 my_cxt = { (jmp_buf *) NULL, (SV *) NULL }; 00398 #endif 00399 00400 /* 00401 Forward declarations. 00402 */ 00403 static Image 00404 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***); 00405 00406 static int 00407 strEQcase(const char *,const char *); 00408 00409 /* 00410 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00411 % % 00412 % % 00413 % % 00414 % C l o n e P a c k a g e I n f o % 00415 % % 00416 % % 00417 % % 00418 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00419 % 00420 % Method ClonePackageInfo makes a duplicate of the given info, or if info is 00421 % NULL, a new one. 00422 % 00423 % The format of the ClonePackageInfo routine is: 00424 % 00425 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info) 00426 % 00427 % A description of each parameter follows: 00428 % 00429 % o clone_info: Method ClonePackageInfo returns a duplicate of the given 00430 % info, or if info is NULL, a new one. 00431 % 00432 % o info: a structure of type info. 00433 % 00434 % 00435 */ 00436 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info) 00437 { 00438 struct PackageInfo 00439 *clone_info; 00440 00441 clone_info=(struct PackageInfo *) AcquireMagickMemory(sizeof(*clone_info)); 00442 if (clone_info == (struct PackageInfo *) NULL) 00443 { 00444 ThrowPerlException(ResourceLimitError,"UnableToClonePackageInfo", 00445 PackageName); 00446 return((struct PackageInfo *) NULL); 00447 } 00448 if (!info) 00449 { 00450 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL); 00451 clone_info->draw_info= 00452 CloneDrawInfo(clone_info->image_info,(DrawInfo *) NULL); 00453 clone_info->quantize_info=CloneQuantizeInfo((QuantizeInfo *) NULL); 00454 return(clone_info); 00455 } 00456 *clone_info=(*info); 00457 clone_info->image_info=CloneImageInfo(info->image_info); 00458 clone_info->draw_info=CloneDrawInfo(info->image_info,info->draw_info); 00459 clone_info->quantize_info=CloneQuantizeInfo(info->quantize_info); 00460 return(clone_info); 00461 } 00462 00463 /* 00464 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00465 % % 00466 % % 00467 % % 00468 % c o n s t a n t % 00469 % % 00470 % % 00471 % % 00472 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00473 % 00474 % constant() returns a double value for the specified name. 00475 % 00476 % The format of the constant routine is: 00477 % 00478 % double constant(char *name,int sans) 00479 % 00480 % A description of each parameter follows: 00481 % 00482 % o value: Method constant returns a double value for the specified name. 00483 % 00484 % o name: The name of the constant. 00485 % 00486 % o sans: This integer value is not used. 00487 % 00488 % 00489 */ 00490 static double constant(char *name,int sans) 00491 { 00492 errno=0; 00493 switch (*name) 00494 { 00495 case 'B': 00496 { 00497 if (strEQ(name,"BlobError")) 00498 return(BlobError); 00499 if (strEQ(name,"BlobWarning")) 00500 return(BlobWarning); 00501 break; 00502 } 00503 case 'C': 00504 { 00505 if (strEQ(name,"CacheError")) 00506 return(CacheError); 00507 if (strEQ(name,"CacheWarning")) 00508 return(CacheWarning); 00509 if (strEQ(name,"CoderError")) 00510 return(CoderError); 00511 if (strEQ(name,"CoderWarning")) 00512 return(CoderWarning); 00513 if (strEQ(name,"ConfigureError")) 00514 return(ConfigureError); 00515 if (strEQ(name,"ConfigureWarning")) 00516 return(ConfigureWarning); 00517 if (strEQ(name,"CorruptImageError")) 00518 return(CorruptImageError); 00519 if (strEQ(name,"CorruptImageWarning")) 00520 return(CorruptImageWarning); 00521 break; 00522 } 00523 case 'D': 00524 { 00525 if (strEQ(name,"DelegateError")) 00526 return(DelegateError); 00527 if (strEQ(name,"DelegateWarning")) 00528 return(DelegateWarning); 00529 if (strEQ(name,"DrawError")) 00530 return(DrawError); 00531 if (strEQ(name,"DrawWarning")) 00532 return(DrawWarning); 00533 break; 00534 } 00535 case 'E': 00536 { 00537 if (strEQ(name,"ErrorException")) 00538 return(ErrorException); 00539 if (strEQ(name,"ExceptionError")) 00540 return(CoderError); 00541 if (strEQ(name,"ExceptionWarning")) 00542 return(CoderWarning); 00543 break; 00544 } 00545 case 'F': 00546 { 00547 if (strEQ(name,"FatalErrorException")) 00548 return(FatalErrorException); 00549 if (strEQ(name,"FileOpenError")) 00550 return(FileOpenError); 00551 if (strEQ(name,"FileOpenWarning")) 00552 return(FileOpenWarning); 00553 break; 00554 } 00555 case 'I': 00556 { 00557 if (strEQ(name,"ImageError")) 00558 return(ImageError); 00559 if (strEQ(name,"ImageWarning")) 00560 return(ImageWarning); 00561 break; 00562 } 00563 case 'M': 00564 { 00565 if (strEQ(name,"MaxRGB")) 00566 return(MaxRGB); 00567 if (strEQ(name,"MissingDelegateError")) 00568 return(MissingDelegateError); 00569 if (strEQ(name,"MissingDelegateWarning")) 00570 return(MissingDelegateWarning); 00571 if (strEQ(name,"ModuleError")) 00572 return(ModuleError); 00573 if (strEQ(name,"ModuleWarning")) 00574 return(ModuleWarning); 00575 break; 00576 } 00577 case 'O': 00578 { 00579 if (strEQ(name,"Opaque")) 00580 return(OpaqueOpacity); 00581 if (strEQ(name,"OptionError")) 00582 return(OptionError); 00583 if (strEQ(name,"OptionWarning")) 00584 return(OptionWarning); 00585 break; 00586 } 00587 case 'Q': 00588 { 00589 if (strEQ(name,"QuantumDepth")) 00590 return(QuantumDepth); 00591 break; 00592 } 00593 case 'R': 00594 { 00595 if (strEQ(name,"ResourceLimitError")) 00596 return(ResourceLimitError); 00597 if (strEQ(name,"ResourceLimitWarning")) 00598 return(ResourceLimitWarning); 00599 if (strEQ(name,"RegistryError")) 00600 return(RegistryError); 00601 if (strEQ(name,"RegistryWarning")) 00602 return(RegistryWarning); 00603 break; 00604 } 00605 case 'S': 00606 { 00607 if (strEQ(name,"StreamError")) 00608 return(StreamError); 00609 if (strEQ(name,"StreamWarning")) 00610 return(StreamWarning); 00611 if (strEQ(name,"Success")) 00612 return(0); 00613 break; 00614 } 00615 case 'T': 00616 { 00617 if (strEQ(name,"Transparent")) 00618 return(TransparentOpacity); 00619 if (strEQ(name,"TypeError")) 00620 return(TypeError); 00621 if (strEQ(name,"TypeWarning")) 00622 return(TypeWarning); 00623 break; 00624 } 00625 case 'W': 00626 { 00627 if (strEQ(name,"WarningException")) 00628 return(WarningException); 00629 break; 00630 } 00631 case 'X': 00632 { 00633 if (strEQ(name,"XServerError")) 00634 return(XServerError); 00635 if (strEQ(name,"XServerWarning")) 00636 return(XServerWarning); 00637 break; 00638 } 00639 } 00640 errno=EINVAL; 00641 return(0); 00642 } 00643 00644 /* 00645 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00646 % % 00647 % % 00648 % % 00649 % D e s t r o y P a c k a g e I n f o % 00650 % % 00651 % % 00652 % % 00653 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00654 % 00655 % Method DestroyPackageInfo frees a previously created info structure. 00656 % 00657 % The format of the DestroyPackageInfo routine is: 00658 % 00659 % DestroyPackageInfo(struct PackageInfo *info) 00660 % 00661 % A description of each parameter follows: 00662 % 00663 % o info: a structure of type info. 00664 % 00665 % 00666 */ 00667 static void DestroyPackageInfo(struct PackageInfo *info) 00668 { 00669 info->image_info=DestroyImageInfo(info->image_info); 00670 info->draw_info=DestroyDrawInfo(info->draw_info); 00671 info->quantize_info=DestroyQuantizeInfo(info->quantize_info); 00672 info=(struct PackageInfo *) RelinquishMagickMemory(info); 00673 } 00674 00675 /* 00676 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00677 % % 00678 % % 00679 % % 00680 % G e t L i s t % 00681 % % 00682 % % 00683 % % 00684 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00685 % 00686 % Method GetList is recursively called by SetupList to traverse the 00687 % Image__Magick reference. If building an reference_vector (see SetupList), 00688 % *current is the current position in *reference_vector and *last is the final 00689 % entry in *reference_vector. 00690 % 00691 % The format of the GetList routine is: 00692 % 00693 % GetList(info) 00694 % 00695 % A description of each parameter follows: 00696 % 00697 % o info: a structure of type info. 00698 % 00699 % 00700 */ 00701 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,int *current, 00702 int *last) 00703 { 00704 Image 00705 *image; 00706 00707 if (!reference) 00708 return(NULL); 00709 switch (SvTYPE(reference)) 00710 { 00711 case SVt_PVAV: 00712 { 00713 AV 00714 *av; 00715 00716 Image 00717 *head, 00718 *previous; 00719 00720 int 00721 n; 00722 00723 register int 00724 i; 00725 00726 /* 00727 Array of images. 00728 */ 00729 previous=(Image *) NULL; 00730 head=(Image *) NULL; 00731 av=(AV *) reference; 00732 n=av_len(av); 00733 for (i=0; i <= n; i++) 00734 { 00735 SV 00736 **rv; 00737 00738 rv=av_fetch(av,i,0); 00739 if (rv && *rv && sv_isobject(*rv)) 00740 { 00741 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last); 00742 if (image == (Image *) NULL) 00743 continue; 00744 if (image == previous) 00745 { 00746 ExceptionInfo 00747 exception; 00748 00749 GetExceptionInfo(&exception); 00750 image=CloneImage(image,0,0,MagickTrue,&exception); 00751 CatchException(&exception); 00752 DestroyExceptionInfo(&exception); 00753 if (image == (Image *) NULL) 00754 return(NULL); 00755 } 00756 image->previous=previous; 00757 *(previous ? &previous->next : &head)=image; 00758 for (previous=image; previous->next; previous=previous->next); 00759 } 00760 } 00761 return(head); 00762 } 00763 case SVt_PVMG: 00764 { 00765 /* 00766 Blessed scalar, one image. 00767 */ 00768 image=(Image *) SvIV(reference); 00769 if (image == (Image *) NULL) 00770 return(NULL); 00771 image->previous=(Image *) NULL; 00772 image->next=(Image *) NULL; 00773 if (reference_vector) 00774 { 00775 if (*current == *last) 00776 { 00777 *last+=256; 00778 if (!*reference_vector) 00779 *reference_vector=(SV **) 00780 AcquireMagickMemory(*last*sizeof(*reference_vector)); 00781 else 00782 *reference_vector=(SV **) ResizeMagickMemory(*reference_vector, 00783 *last*sizeof(*reference_vector)); 00784 } 00785 if (!*reference_vector) 00786 { 00787 ThrowPerlException(ResourceLimitError,"MemoryAllocationFailed", 00788 PackageName); 00789 return((Image *) NULL); 00790 } 00791 (*reference_vector)[*current]=reference; 00792 (*reference_vector)[++(*current)]=NULL; 00793 } 00794 return(image); 00795 } 00796 } 00797 (void) fprintf(stderr,"GetList: UnrecognizedType %ld\n", 00798 (long) SvTYPE(reference)); 00799 return((Image *) NULL); 00800 } 00801 00802 /* 00803 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00804 % % 00805 % % 00806 % % 00807 % G e t P a c k a g e I n f o % 00808 % % 00809 % % 00810 % % 00811 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00812 % 00813 % Method GetPackageInfo looks up or creates an info structure for the given 00814 % Image__Magick reference. If it does create a new one, the information in 00815 % package_info is used to initialize it. 00816 % 00817 % The format of the GetPackageInfo routine is: 00818 % 00819 % struct PackageInfo *GetPackageInfo(void *reference, 00820 % struct PackageInfo *package_info) 00821 % 00822 % A description of each parameter follows: 00823 % 00824 % o info: a structure of type info. 00825 % 00826 % 00827 */ 00828 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference, 00829 struct PackageInfo *package_info) 00830 { 00831 char 00832 message[MaxTextExtent]; 00833 00834 struct PackageInfo 00835 *clone_info; 00836 00837 SV 00838 *sv; 00839 00840 (void) FormatMagickString(message,MaxTextExtent,"%s::Ref%lx_%s",PackageName, 00841 (long) reference,XS_VERSION); 00842 sv=perl_get_sv(message,(TRUE | 0x02)); 00843 if (!sv) 00844 { 00845 ThrowPerlException(ResourceLimitError,"UnableToGetPackageInfo",message); 00846 return(package_info); 00847 } 00848 if (SvREFCNT(sv) == 0) 00849 (void) SvREFCNT_inc(sv); 00850 if (SvIOKp(sv) && (clone_info=(struct PackageInfo *) SvIV(sv))) 00851 return(clone_info); 00852 clone_info=ClonePackageInfo(package_info); 00853 sv_setiv(sv,(IV) clone_info); 00854 return(clone_info); 00855 } 00856 00857 /* 00858 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00859 % % 00860 % % 00861 % % 00862 % M a g i c k E r r o r H a n d l e r % 00863 % % 00864 % % 00865 % % 00866 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00867 % 00868 % Method MagickErrorHandler replaces ImageMagick's fatal error handler. This 00869 % stores the message in a Perl variable,and longjmp's to return the error to 00870 % Perl. If the error_flag variable is set, it also calls the Perl warn 00871 % routine. Note that this doesn't exit but returns control to Perl; the 00872 % Image::Magick handle may be left in a bad state. 00873 % 00874 % The format of the MagickErrorHandler routine is: 00875 % 00876 % MagickErrorHandler(const ExceptionType severity,const char *reason, 00877 % const char *qualifier) 00878 % 00879 % A description of each parameter follows: 00880 % 00881 % o severity: The severity of the exception. 00882 % 00883 % o reason: The reason of the exception. 00884 % 00885 % o description: The exception description. 00886 % 00887 % 00888 */ 00889 static void MagickErrorHandler(const ExceptionType severity,const char *reason, 00890 const char *description) 00891 { 00892 char 00893 text[MaxTextExtent]; 00894 00895 dTHX; /* perl context */ 00896 dMY_CXT; 00897 (void) FormatMagickString(text,MaxTextExtent, 00898 "Exception %d: %.1024s%s%.1024s%s",severity, 00899 (reason ? GetLocaleExceptionMessage(severity,reason) : "ERROR"), 00900 description ? " (" : "", 00901 description ? GetLocaleExceptionMessage(severity,description) : "", 00902 description ? ")" : ""); 00903 if ((MY_CXT.error_list == NULL) || (MY_CXT.error_jump == NULL)) 00904 { 00905 /* 00906 Set up error buffer. 00907 */ 00908 warn("%s",text); 00909 if (MY_CXT.error_jump == NULL) 00910 exit((int) severity % 100); 00911 } 00912 if (MY_CXT.error_list) 00913 { 00914 if (SvCUR(MY_CXT.error_list)) 00915 sv_catpv(MY_CXT.error_list,"\n"); 00916 sv_catpv(MY_CXT.error_list,text); 00917 } 00918 longjmp(*MY_CXT.error_jump,(int) severity); 00919 } 00920 00921 /* 00922 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00923 % % 00924 % % 00925 % % 00926 % M a g i c k W a r n i n g H a n d l e r % 00927 % % 00928 % % 00929 % % 00930 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00931 % 00932 % Method MagickWarningHandler replaces the ImageMagick warning handler. This 00933 % stores the (possibly multiple) reasons in a Perl variable for later 00934 % returning. 00935 % 00936 % The format of the MagickWarningHandler routine is: 00937 % 00938 % MagickWarningHandler(const ExceptionType severity,const char *reason, 00939 % const char *description) 00940 % 00941 % A description of each parameter follows: 00942 % 00943 % o severity: Specifies the numeric severity category. 00944 % 00945 % o reason: The reason of the exception. 00946 % 00947 % o description: Specifies any description to the reason. 00948 % 00949 % 00950 */ 00951 00952 static void MagickWarningHandler(const ExceptionType severity, 00953 const char *reason,const char *description) 00954 { 00955 char 00956 text[MaxTextExtent]; 00957 00958 dTHX; /* perl context */ 00959 dMY_CXT; 00960 if (!reason) 00961 return; 00962 (void) FormatMagickString(text,MaxTextExtent, 00963 "Exception %d: %.1024s%s%.1024s%s",severity, 00964 (reason ? GetLocaleExceptionMessage(severity,reason) : "WARNING"), 00965 description ? " (" : "", 00966 description ? GetLocaleExceptionMessage(severity,description) : "", 00967 description ? ")" : ""); 00968 if (MY_CXT.error_list == NULL) 00969 { 00970 /* 00971 Set up reason buffer. 00972 */ 00973 warn("%s",text); 00974 if (MY_CXT.error_list == NULL) 00975 return; 00976 } 00977 if (SvCUR(MY_CXT.error_list)) 00978 sv_catpv(MY_CXT.error_list,"\n"); /* add \n separator between reasons */ 00979 sv_catpv(MY_CXT.error_list,text); 00980 } 00981 00982 /* 00983 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00984 % % 00985 % % 00986 % % 00987 % S e t A t t r i b u t e % 00988 % % 00989 % % 00990 % % 00991 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00992 % 00993 % SetAttribute() sets the attribute to the value in sval. This can change 00994 % either or both of image or info. 00995 % 00996 % The format of the SetAttribute routine is: 00997 % 00998 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute, 00999 % SV *sval) 01000 % 01001 % A description of each parameter follows: 01002 % 01003 % o status: Method SetAttribute returns the index of string in the list 01004 % otherwise -1. 01005 % 01006 % o list: a list of strings. 01007 % 01008 % o string: a character string. 01009 % 01010 % 01011 */ 01012 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, 01013 char *attribute,SV *sval) 01014 { 01015 DoublePixelPacket 01016 pixel; 01017 01018 ExceptionInfo 01019 exception; 01020 01021 GeometryInfo 01022 geometry_info; 01023 01024 int 01025 sp; 01026 01027 long 01028 x, 01029 y; 01030 01031 MagickStatusType 01032 flags; 01033 01034 PixelPacket 01035 *color, 01036 target_color; 01037 01038 GetExceptionInfo(&exception); 01039 switch (*attribute) 01040 { 01041 case 'A': 01042 case 'a': 01043 { 01044 if (LocaleCompare(attribute,"adjoin") == 0) 01045 { 01046 sp=SvPOK(sval) ? ParseMagickOption(MagickBooleanOptions,MagickFalse, 01047 SvPV(sval,na)) : SvIV(sval); 01048 if (sp < 0) 01049 { 01050 ThrowPerlException(OptionError,"UnrecognizedType",SvPV(sval,na)); 01051 break; 01052 } 01053 if (info) 01054 info->image_info->adjoin=sp != 0; 01055 break; 01056 } 01057 if (LocaleCompare(attribute,"antialias") == 0) 01058 { 01059 sp=SvPOK(sval) ? ParseMagickOption(MagickBooleanOptions,MagickFalse, 01060 SvPV(sval,na)) : SvIV(sval); 01061 if (sp < 0) 01062 { 01063 ThrowPerlException(OptionError,"UnrecognizedType",SvPV(sval,na)); 01064 break; 01065 } 01066 if (info) 01067 { 01068 info->image_info->antialias=sp != 0; 01069 info->draw_info->text_antialias=sp != 0; 01070 } 01071 break; 01072 } 01073 if (LocaleCompare(attribute,"area-limit") == 0) 01074 { 01075 unsigned long 01076 limit; 01077 01078 limit=(~0UL); 01079 if (LocaleCompare(SvPV(sval,na),"unlimited") == 0) 01080 (void) SetMagickResourceLimit(AreaResource,SvIV(sval)); 01081 break; 01082 } 01083 if (LocaleCompare(attribute,"authenticate") == 0) 01084 { 01085 if (info) 01086 (void) CloneString(&info->image_info->authenticate,SvPV(sval,na)); 01087 break; 01088 } 01089 ThrowPerlException(OptionError,"UnrecognizedAttribute",attribute); 01090 break; 01091 } 01092 case 'B': 01093 case 'b': 01094 { 01095 if (LocaleCompare(attribute,"background") == 0) 01096 { 01097 (void) QueryColorDatabase(SvPV(sval,na),&target_color,&exception); 01098 if (info) 01099 info->image_info->background_color=target_color; 01100 for ( ; image; image=image->next) 01101 image->background_color=target_color; 01102 break; 01103 } 01104 if (LocaleCompare(attribute,"bias") == 0) 01105 { 01106 for ( ; image; image=image->next) 01107 image->bias=StringToDouble(SvPV(sval,na),MaxRGB); 01108 break; 01109 } 01110 if (LocaleCompare(attribute,"blue-primary") == 0) 01111 { 01112 for ( ; image; image=image->next) 01113 { 01114 flags=ParseGeometry(SvPV(sval,na),&geometry_info); 01115 image->chromaticity.blue_primary.x=geometry_info.rho; 01116 image->chromaticity.blue_primary.y=geometry_info.sigma; 01117 if (!(flags & SigmaValue)) 01118 image->chromaticity.blue_primary.y= 01119 image->chromaticity.blue_primary.x; 01120 } 01121 break; 01122 } 01123 if (LocaleCompare(attribute,"bordercolor") == 0) 01124 { 01125 (void) QueryColorDatabase(SvPV(sval,na),&target_color,&exception); 01126 if (info) 01127 { 01128 info->image_info->border_color=target_color; 01129 info->draw_info->border_color=target_color; 01130 } 01131 for ( ; image; image=image->next) 01132 image->border_color=target_color; 01133 break; 01134 } 01135 ThrowPerlException(OptionError,"UnrecognizedAttribute",attribute); 01136 break; 01137 } 01138 case 'C': 01139 case 'c': 01140 { 01141 if (LocaleCompare(attribute,"cache-threshold") == 0) 01142 { 01143 (void) SetMagickResourceLimit(MemoryResource,SvIV(sval)); 01144 (void) SetMagickResourceLimit(MapResource,2*SvIV(sval)); 01145 break; 01146 } 01147 if (LocaleCompare(attribute,"clip-mask") == 0) 01148 { 01149 Image 01150 *clip_mask; 01151 01152 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL); 01153 for ( ; image; image=image->next) 01154 SetImageClipMask(image,clip_mask); 01155 break; 01156 } 01157 if (LocaleNCompare(attribute,"colormap",8) == 0) 01158 { 01159 for ( ; image; image=image->next) 01160 { 01161 int 01162 i; 01163 01164 if (image->storage_class == DirectClass) 01165 continue; 01166 i=0; 01167 (void) sscanf(attribute,"%*[^[][%d",&i); 01168 if (i > (long) image->colors) 01169 i%=image->colors; 01170 if (strchr(SvPV(sval,na),',') == 0) 01171 QueryColorDatabase(SvPV(sval,na),image->colormap+i,&exception); 01172 else 01173 { 01174 color=image->colormap+i; 01175 pixel.red=color->red; 01176 pixel.green=color->green; 01177 pixel.blue=color->blue; 01178 flags=ParseGeometry(SvPV(sval,na),&geometry_info); 01179 pixel.red=geometry_info.rho; 01180 pixel.green=geometry_info.sigma; 01181 pixel.blue=geometry_info.xi; 01182 color->red=RoundToQuantum(pixel.red); 01183 color->green=RoundToQuantum(pixel.green); 01184 color->blue=RoundToQuantum(pixel.blue); 01185 } 01186 } 01187 break; 01188 } 01189 if (LocaleCompare(attribute,"colorspace") == 0) 01190 { 01191 sp=SvPOK(sval) ? ParseMagickOption(MagickColorspaceOptions,MagickFalse, 01192 SvPV(sval,na)) : SvIV(sval); 01193 if (sp < 0) 01194 { 01195 ThrowPerlException(OptionError,"UnrecognizedColorspace", 01196 SvPV(sval,na)); 01197 break; 01198 } 01199 if (info) 01200 info->image_info->colorspace=(ColorspaceType) sp; 01201 for ( ; image; image=image->next) 01202 (void) SetImageColorspace(image,(ColorspaceType) sp); 01203 break; 01204 } 01205 if (LocaleCompare(attribute,"compression") == 0) 01206 { 01207 sp=SvPOK(sval) ? ParseMagickOption(MagickCompressionOptions,MagickFalse, 01208 SvPV(sval,na)) : SvIV(sval); 01209 if (sp < 0) 01210 { 01211 ThrowPerlException(OptionError,"UnrecognizedImageCompression", 01212 SvPV(sval,na)); 01213 break; 01214 } 01215 if (info) 01216 info->image_info->compression=(CompressionType) sp; 01217 for ( ; image; image=image->next) 01218 image->compression=(CompressionType) sp; 01219 break; 01220 } 01221 ThrowPerlException(OptionError,"UnrecognizedAttribute",attribute); 01222 break; 01223 } 01224 case 'D': 01225 case 'd': 01226 { 01227 if (Locale