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/coders/msl.c

Go to the documentation of this file.
00001 /* 00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00003 % % 00004 % % 00005 % % 00006 % M M SSSSS L % 00007 % MM MM SS L % 00008 % M M M SSS L % 00009 % M M SS L % 00010 % M M SSSSS LLLLL % 00011 % % 00012 % % 00013 % Execute Magick Scripting Language Scripts. % 00014 % % 00015 % Software Design % 00016 % John Cristy % 00017 % Leonard Rosenthol % 00018 % William Radcliffe % 00019 % December 2001 % 00020 % % 00021 % % 00022 % Copyright 1999-2004 ImageMagick Studio LLC, a non-profit organization % 00023 % dedicated to making software imaging solutions freely available. % 00024 % % 00025 % You may not use this file except in compliance with the License. You may % 00026 % obtain a copy of the License at % 00027 % % 00028 % http://www.imagemagick.org/www/Copyright.html % 00029 % % 00030 % Unless required by applicable law or agreed to in writing, software % 00031 % distributed under the License is distributed on an "AS IS" BASIS, % 00032 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % 00033 % See the License for the specific language governing permissions and % 00034 % limitations under the License. % 00035 % % 00036 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00037 % 00038 % 00039 */ 00040 00041 /* 00042 Include declarations. 00043 */ 00044 #include "magick/studio.h" 00045 #include "magick/attribute.h" 00046 #include "magick/blob.h" 00047 #include "magick/blob_private.h" 00048 #include "magick/color.h" 00049 #include "magick/color_private.h" 00050 #include "magick/composite.h" 00051 #include "magick/constitute.h" 00052 #include "magick/decorate.h" 00053 #include "magick/draw.h" 00054 #include "magick/effect.h" 00055 #include "magick/enhance.h" 00056 #include "magick/error.h" 00057 #include "magick/error_private.h" 00058 #include "magick/fx.h" 00059 #include "magick/geometry.h" 00060 #include "magick/image.h" 00061 #include "magick/image_private.h" 00062 #include "magick/list.h" 00063 #include "magick/log.h" 00064 #include "magick/magick.h" 00065 #include "magick/memory_.h" 00066 #include "magick/option.h" 00067 #include "magick/paint.h" 00068 #include "magick/resize.h" 00069 #include "magick/shear.h" 00070 #include "magick/static.h" 00071 #include "magick/string_.h" 00072 #include "magick/transform.h" 00073 #include "magick/utility.h" 00074 #if defined(HasXML) 00075 # if defined(__WINDOWS__) 00076 # if defined(__MINGW32__) 00077 # define _MSC_VER 00078 # endif 00079 # include <win32config.h> 00080 # endif 00081 # include <libxml/parser.h> 00082 # include <libxml/xmlmemory.h> 00083 # include <libxml/parserInternals.h> 00084 # include <libxml/xmlerror.h> 00085 #endif 00086 00087 /* 00088 Define Declatations. 00089 */ 00090 #define ThrowMSLException(severity,tag,reason) \ 00091 (void) ThrowMagickException(msl_info->exception,GetMagickModule(),severity, \ 00092 tag,reason); 00093 00094 /* 00095 Typedef declaractions. 00096 */ 00097 typedef struct _MSLGroupInfo 00098 { 00099 unsigned long 00100 numImages; /* how many images are in this group */ 00101 } MSLGroupInfo; 00102 00103 typedef struct _MSLInfo 00104 { 00105 ExceptionInfo 00106 *exception; 00107 00108 long 00109 n, 00110 00111 nGroups; 00112 00113 ImageInfo 00114 **image_info; 00115 00116 DrawInfo 00117 **draw_info; 00118 00119 Image 00120 **attributes, 00121 **image; 00122 00123 MSLGroupInfo 00124 *group_info; 00125 00126 #if defined(HasXML) 00127 xmlParserCtxtPtr 00128 parser; 00129 00130 xmlDocPtr 00131 document; 00132 #endif 00133 } MSLInfo; 00134 00135 /* 00136 Forward declarations. 00137 */ 00138 #if defined(HasXML) 00139 static MagickBooleanType 00140 WriteMSLImage(const ImageInfo *,Image *); 00141 #endif 00142 00143 #if defined(HasXML) 00144 /* 00145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00146 % % 00147 % % 00148 % % 00149 % R e a d M S L I m a g e % 00150 % % 00151 % % 00152 % % 00153 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00154 % 00155 % ReadMSLImage() reads a Magick Scripting Language file and returns it. 00156 % It allocates the memory necessary for the new Image structure and returns a 00157 % pointer to the new image. 00158 % 00159 % The format of the ReadMSLImage method is: 00160 % 00161 % Image *ReadMSLImage(const ImageInfo *image_info,ExceptionInfo *exception) 00162 % 00163 % A description of each parameter follows: 00164 % 00165 % o image_info: The image info. 00166 % 00167 % o exception: return any errors or warnings in this structure. 00168 % 00169 % 00170 */ 00171 00172 #if defined(__cplusplus) || defined(c_plusplus) 00173 extern "C" { 00174 #endif 00175 00176 static int MSLIsStandalone(void *context) 00177 { 00178 MSLInfo 00179 *msl_info; 00180 00181 /* 00182 Is this document tagged standalone? 00183 */ 00184 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.MSLIsStandalone()"); 00185 msl_info=(MSLInfo *) context; 00186 return(msl_info->document->standalone == 1); 00187 } 00188 00189 static int MSLHasInternalSubset(void *context) 00190 { 00191 MSLInfo 00192 *msl_info; 00193 00194 /* 00195 Does this document has an internal subset? 00196 */ 00197 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 00198 " SAX.MSLHasInternalSubset()"); 00199 msl_info=(MSLInfo *) context; 00200 return(msl_info->document->intSubset != NULL); 00201 } 00202 00203 static int MSLHasExternalSubset(void *context) 00204 { 00205 MSLInfo 00206 *msl_info; 00207 00208 /* 00209 Does this document has an external subset? 00210 */ 00211 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 00212 " SAX.MSLHasExternalSubset()"); 00213 msl_info=(MSLInfo *) context; 00214 return(msl_info->document->extSubset != NULL); 00215 } 00216 00217 static void MSLInternalSubset(void *context,const xmlChar *name, 00218 const xmlChar *external_id,const xmlChar *system_id) 00219 { 00220 MSLInfo 00221 *msl_info; 00222 00223 /* 00224 Does this document has an internal subset? 00225 */ 00226 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 00227 " SAX.internalSubset(%s %s %s)",name, 00228 (external_id != (const xmlChar *) NULL ? (char *) external_id : " "), 00229 (system_id != (const xmlChar *) NULL ? (char *) system_id : " ")); 00230 msl_info=(MSLInfo *) context; 00231 (void) xmlCreateIntSubset(msl_info->document,name,external_id,system_id); 00232 } 00233 00234 static xmlParserInputPtr MSLResolveEntity(void *context, 00235 const xmlChar *public_id,const xmlChar *system_id) 00236 { 00237 MSLInfo 00238 *msl_info; 00239 00240 xmlParserInputPtr 00241 stream; 00242 00243 /* 00244 Special entity resolver, better left to the parser, it has more 00245 context than the application layer. The default behaviour is to 00246 not resolve the entities, in that case the ENTITY_REF nodes are 00247 built in the structure (and the parameter values). 00248 */ 00249 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 00250 " SAX.resolveEntity(%s, %s)", 00251 (public_id != (const xmlChar *) NULL ? (char *) public_id : "none"), 00252 (system_id != (const xmlChar *) NULL ? (char *) system_id : "none")); 00253 msl_info=(MSLInfo *) context; 00254 stream=xmlLoadExternalEntity((const char *) system_id,(const char *) 00255 public_id,msl_info->parser); 00256 return(stream); 00257 } 00258 00259 static xmlEntityPtr MSLGetEntity(void *context,const xmlChar *name) 00260 { 00261 MSLInfo 00262 *msl_info; 00263 00264 /* 00265 Get an entity by name. 00266 */ 00267 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 00268 " SAX.MSLGetEntity(%s)",(char *) name); 00269 msl_info=(MSLInfo *) context; 00270 return(xmlGetDocEntity(msl_info->document,name)); 00271 } 00272 00273 static xmlEntityPtr MSLGetParameterEntity(void *context,const xmlChar *name) 00274 { 00275 MSLInfo 00276 *msl_info; 00277 00278 /* 00279 Get a parameter entity by name. 00280 */ 00281 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 00282 " SAX.getParameterEntity(%s)",(char *) name); 00283 msl_info=(MSLInfo *) context; 00284 return(xmlGetParameterEntity(msl_info->document,name)); 00285 } 00286 00287 static void MSLEntityDeclaration(void *context,const xmlChar *name,int type, 00288 const xmlChar *public_id,const xmlChar *system_id,xmlChar *content) 00289 { 00290 MSLInfo 00291 *msl_info; 00292 00293 /* 00294 An entity definition has been parsed. 00295 */ 00296 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 00297 " SAX.entityDecl(%s, %d, %s, %s, %s)",name,type, 00298 public_id != (const xmlChar *) NULL ? (char *) public_id : "none", 00299 system_id != (const xmlChar *) NULL ? (char *) system_id : "none",content); 00300 msl_info=(MSLInfo *) context; 00301 if (msl_info->parser->inSubset == 1) 00302 (void) xmlAddDocEntity(msl_info->document,name,type,public_id,system_id, 00303 content); 00304 else 00305 if (msl_info->parser->inSubset == 2) 00306 (void) xmlAddDtdEntity(msl_info->document,name,type,public_id,system_id, 00307 content); 00308 } 00309 00310 static void MSLAttributeDeclaration(void *context,const xmlChar *element, 00311 const xmlChar *name,int type,int value,const xmlChar *default_value, 00312 xmlEnumerationPtr tree) 00313 { 00314 MSLInfo 00315 *msl_info; 00316 00317 xmlChar 00318 *fullname, 00319 *prefix; 00320 00321 xmlParserCtxtPtr 00322 parser; 00323 00324 /* 00325 An attribute definition has been parsed. 00326 */ 00327 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 00328 " SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",element, 00329 name,type,value,default_value); 00330 msl_info=(MSLInfo *) context; 00331 fullname=(xmlChar *) NULL; 00332 prefix=(xmlChar *) NULL; 00333 parser=msl_info->parser; 00334 fullname=(xmlChar *) xmlSplitQName(parser,name,&prefix); 00335 if (parser->inSubset == 1) 00336 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->intSubset, 00337 element,fullname,prefix,(xmlAttributeType) type, 00338 (xmlAttributeDefault) value,default_value,tree); 00339 else 00340 if (parser->inSubset == 2) 00341 (void) xmlAddAttributeDecl(&parser->vctxt,msl_info->document->extSubset, 00342 element,fullname,prefix,(xmlAttributeType) type, 00343 (xmlAttributeDefault) value,default_value,tree); 00344 if (prefix != (xmlChar *) NULL) 00345 xmlFree(prefix); 00346 if (fullname != (xmlChar *) NULL) 00347 xmlFree(fullname); 00348 } 00349 00350 static void MSLElementDeclaration(void *context,const xmlChar *name,int type, 00351 xmlElementContentPtr content) 00352 { 00353 MSLInfo 00354 *msl_info; 00355 00356 xmlParserCtxtPtr 00357 parser; 00358 00359 /* 00360 An element definition has been parsed. 00361 */ 00362 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 00363 " SAX.elementDecl(%s, %d, ...)",name,type); 00364 msl_info=(MSLInfo *) context; 00365 parser=msl_info->parser; 00366 if (parser->inSubset == 1) 00367 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->intSubset, 00368 name,(xmlElementTypeVal) type,content); 00369 else 00370 if (parser->inSubset == 2) 00371 (void) xmlAddElementDecl(&parser->vctxt,msl_info->document->extSubset, 00372 name,(xmlElementTypeVal) type,content); 00373 } 00374 00375 static void MSLNotationDeclaration(void *context,const xmlChar *name, 00376 const xmlChar *public_id,const xmlChar *system_id) 00377 { 00378 MSLInfo 00379 *msl_info; 00380 00381 xmlParserCtxtPtr 00382 parser; 00383 00384 /* 00385 What to do when a notation declaration has been parsed. 00386 */ 00387 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 00388 " SAX.notationDecl(%s, %s, %s)",name, 00389 public_id != (const xmlChar *) NULL ? (char *) public_id : "none", 00390 system_id != (const xmlChar *) NULL ? (char *) system_id : "none"); 00391 msl_info=(MSLInfo *) context; 00392 parser=msl_info->parser; 00393 if (parser->inSubset == 1) 00394 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset, 00395 name,public_id,system_id); 00396 else 00397 if (parser->inSubset == 2) 00398 (void) xmlAddNotationDecl(&parser->vctxt,msl_info->document->intSubset, 00399 name,public_id,system_id); 00400 } 00401 00402 static void MSLUnparsedEntityDeclaration(void *context,const xmlChar *name, 00403 const xmlChar *public_id,const xmlChar *system_id,const xmlChar *notation) 00404 { 00405 MSLInfo 00406 *msl_info; 00407 00408 /* 00409 What to do when an unparsed entity declaration is parsed. 00410 */ 00411 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 00412 " SAX.unparsedEntityDecl(%s, %s, %s, %s)",name, 00413 public_id != (const xmlChar *) NULL ? (char *) public_id : "none", 00414 system_id != (const xmlChar *) NULL ? (char *) system_id : "none",notation); 00415 msl_info=(MSLInfo *) context; 00416 (void) xmlAddDocEntity(msl_info->document,name, 00417 XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,public_id,system_id,notation); 00418 00419 } 00420 00421 static void MSLSetDocumentLocator(void *context,xmlSAXLocatorPtr location) 00422 { 00423 MSLInfo 00424 *msl_info; 00425 00426 /* 00427 Receive the document locator at startup, actually xmlDefaultSAXLocator. 00428 */ 00429 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 00430 " SAX.setDocumentLocator()\n"); 00431 msl_info=(MSLInfo *) context; 00432 } 00433 00434 static void MSLStartDocument(void *context) 00435 { 00436 MSLInfo 00437 *msl_info; 00438 00439 xmlParserCtxtPtr 00440 parser; 00441 00442 /* 00443 Called when the document start being processed. 00444 */ 00445 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 00446 " SAX.startDocument()"); 00447 msl_info=(MSLInfo *) context; 00448 parser=msl_info->parser; 00449 msl_info->document=xmlNewDoc(parser->version); 00450 if (msl_info->document == (xmlDocPtr) NULL) 00451 return; 00452 if (parser->encoding == NULL) 00453 msl_info->document->encoding=NULL; 00454 else 00455 msl_info->document->encoding=xmlStrdup(parser->encoding); 00456 msl_info->document->standalone=parser->standalone; 00457 } 00458 00459 static void MSLEndDocument(void *context) 00460 { 00461 MSLInfo 00462 *msl_info; 00463 00464 /* 00465 Called when the document end has been detected. 00466 */ 00467 msl_info=(MSLInfo *) context; 00468 (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.endDocument()"); 00469 } 00470 00471 static void MSLPushImage(MSLInfo *msl_info,Image *image) 00472 { 00473 const ImageAttribute 00474 *attribute; 00475 00476 long 00477 n; 00478 00479 (void) LogMagickEvent(TraceEvent,GetMagickModule(),image->filename); 00480 assert(msl_info != (MSLInfo *) NULL); 00481 msl_info->n++; 00482 n=msl_info->n; 00483 msl_info->image_info=(ImageInfo **) ResizeMagickMemory(msl_info->image_info, 00484 (n+1)*sizeof(*msl_info->image_info)); 00485 msl_info->draw_info=(DrawInfo **) 00486 ResizeMagickMemory(msl_info->draw_info,(n+1)*sizeof(*msl_info->draw_info)); 00487 msl_info->attributes=(Image **) ResizeMagickMemory(msl_info->attributes, 00488 (n+1)*sizeof(*msl_info->attributes)); 00489 msl_info->image=(Image **) 00490 ResizeMagickMemory(msl_info->image,(n+1)*sizeof(*msl_info->image)); 00491 if ((msl_info->image_info == (ImageInfo **) NULL) || 00492 (msl_info->draw_info == (DrawInfo **) NULL) || 00493 (msl_info->attributes == (Image **) NULL) || 00494 (msl_info->image == (Image **) NULL)) 00495 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl"); 00496 msl_info->image_info[n]=CloneImageInfo(msl_info->image_info[n-1]); 00497 msl_info->draw_info[n]= 00498 CloneDrawInfo(msl_info->image_info[n-1], msl_info->draw_info[n-1]); 00499 msl_info->attributes[n]=AllocateImage(msl_info->image_info[n]); 00500 msl_info->image[n]=(Image *) image; 00501 if ((msl_info->image_info[n] == (ImageInfo *) NULL) || 00502 (msl_info->attributes[n] == (Image *) NULL)) 00503 ThrowMSLException(ResourceLimitFatalError,"MemoryAllocationFailed","msl"); 00504 if ( msl_info->nGroups ) 00505 msl_info->group_info[msl_info->nGroups-1].numImages++; 00506 attribute=GetImageAttribute(msl_info->attributes[n-1],(char *) NULL); 00507 while (attribute != (const ImageAttribute *) NULL) 00508 { 00509 (void) SetImageAttribute(msl_info->attributes[n],attribute->key, 00510 attribute->value); 00511 attribute=attribute->next; 00512 } 00513 } 00514 00515 static void MSLPopImage(MSLInfo *msl_info) 00516 { 00517 /* 00518 only dispose of images when they aren't in a group 00519 */ 00520 if ( msl_info->nGroups == 0 ) 00521 { 00522 if (msl_info->image[msl_info->n] != (Image *) NULL) 00523 msl_info->image[msl_info->n]=DestroyImage(msl_info->image[msl_info->n]); 00524 msl_info->attributes[msl_info->n]=DestroyImage(msl_info->attributes[msl_info->n]); 00525 msl_info->image_info[msl_info->n]=DestroyImageInfo(msl_info->image_info[msl_info->n]); 00526 msl_info->n--; 00527 } 00528 } 00529 00530 static void MSLStartElement(void *context,const xmlChar *name, 00531 const xmlChar **attributes) 00532 { 00533 char 00534 key[MaxTextExtent], 00535 *value = NULL; 00536 00537 const char 00538 *keyword; 00539 00540 ExceptionInfo 00541 exception; 00542 00543 GeometryInfo 00544 geometry_info; 00545 00546 long 00547 n, 00548 x, 00549 y; 00550 00551 MSLInfo 00552 *msl_info; 00553 00554 register long 00555 i, j; 00556 00557 unsigned long 00558 height, 00559 width; 00560 00561 /* 00562 Called when an opening tag has been processed. 00563 */ 00564 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 00565 " SAX.startElement(%s",name); 00566 GetExceptionInfo(&exception); 00567 msl_info=(MSLInfo *) context; 00568 n=msl_info->n; 00569 keyword=(const char *) NULL; 00570 switch (*name) 00571 { 00572 case 'B': 00573 case 'b': 00574 { 00575 if (LocaleCompare((char *) name, "blur") == 0) 00576 { 00577 double radius = 0.0, 00578 sigma = 1.0; 00579 00580 if (msl_info->image[n] == (Image *) NULL) 00581 { 00582 ThrowMSLException(OptionError,"NoImagesDefined",(char *) name); 00583 break; 00584 } 00585 /* 00586 NOTE: blur can have no attributes, since we use all the defaults! 00587 */ 00588 if (attributes != (const xmlChar **) NULL) 00589 { 00590 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) 00591 { 00592 keyword=(const char *) attributes[i++]; 00593 CloneString(&value,TranslateText(msl_info->image_info[n], 00594 msl_info->attributes[n],(char *) attributes[i])); 00595 switch (*keyword) 00596 { 00597 case 'R': 00598 case 'r': 00599 { 00600 if (LocaleCompare(keyword, "radius") == 0) 00601 { 00602 radius = atof( value ); 00603 break; 00604 } 00605 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 00606 break; 00607 } 00608 case 'S': 00609 case 's': 00610 { 00611 if (LocaleCompare(keyword,"sigma") == 0) 00612 { 00613 sigma = atoi( value ); 00614 break; 00615 } 00616 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 00617 break; 00618 } 00619 default: 00620 { 00621 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 00622 break; 00623 } 00624 } 00625 } 00626 } 00627 00628 /* 00629 blur image. 00630 */ 00631 { 00632 Image 00633 *newImage; 00634 00635 newImage=BlurImage(msl_info->image[n],radius,sigma,&msl_info->image[n]->exception); 00636 if (newImage == (Image *) NULL) 00637 break; 00638 msl_info->image[n]=DestroyImage(msl_info->image[n]); 00639 msl_info->image[n]=newImage; 00640 break; 00641 } 00642 } 00643 else if (LocaleCompare((char *) name,"border") == 0) 00644 { 00645 /* init the values */ 00646 width = height = 6; /* this is the value that Magick++ uses */ 00647 x = y = 0; 00648 00649 if (msl_info->image[n] == (Image *) NULL) 00650 { 00651 ThrowMSLException(OptionError,"NoImagesDefined",(char *) name); 00652 break; 00653 } 00654 /* 00655 NOTE: border can have no attributes, since we use all the defaults! 00656 */ 00657 if (attributes != (const xmlChar **) NULL) 00658 { 00659 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) 00660 { 00661 keyword=(const char *) attributes[i++]; 00662 CloneString(&value,TranslateText(msl_info->image_info[n], 00663 msl_info->attributes[n],(char *) attributes[i])); 00664 switch (*keyword) 00665 { 00666 case 'F': 00667 case'f': 00668 { 00669 if (LocaleCompare(keyword, "fill") == 0) 00670 { 00671 (void) QueryColorDatabase(value, 00672 &msl_info->image[n]->border_color,&exception); 00673 break; 00674 } 00675 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 00676 break; 00677 } 00678 case 'G': 00679 case 'g': 00680 { 00681 if (LocaleCompare(keyword,"geometry") == 0) 00682 { 00683 (void) ParseMetaGeometry(value,&x,&y,&width,&height); 00684 break; 00685 } 00686 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 00687 break; 00688 } 00689 case 'H': 00690 case 'h': 00691 { 00692 if (LocaleCompare(keyword,"height") == 0) 00693 { 00694 height = atoi( value ); 00695 break; 00696 } 00697 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 00698 break; 00699 } 00700 case 'W': 00701 case 'w': 00702 { 00703 if (LocaleCompare(keyword,"width") == 0) 00704 { 00705 width = atoi( value ); 00706 break; 00707 } 00708 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 00709 break; 00710 } 00711 default: 00712 { 00713 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 00714 break; 00715 } 00716 } 00717 } 00718 } 00719 00720 /* 00721 border image. 00722 */ 00723 { 00724 Image 00725 *border_image; 00726 RectangleInfo 00727 rectInfo; 00728 00729 rectInfo.height = height; 00730 rectInfo.width = width; 00731 rectInfo.x = x; 00732 rectInfo.y = y; 00733 00734 border_image=BorderImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception); 00735 if (border_image == (Image *) NULL) 00736 break; 00737 msl_info->image[n]=DestroyImage(msl_info->image[n]); 00738 msl_info->image[n]=border_image; 00739 } 00740 00741 break; 00742 } 00743 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) name); 00744 } 00745 case 'C': 00746 case 'c': 00747 { 00748 if (LocaleCompare((char *) name, "charcoal") == 0) 00749 { 00750 double radius = 0.0, 00751 sigma = 1.0; 00752 00753 if (msl_info->image[n] == (Image *) NULL) 00754 { 00755 ThrowMSLException(OptionError,"NoImagesDefined",(char *) name); 00756 break; 00757 } 00758 /* 00759 NOTE: charcoal can have no attributes, since we use all the defaults! 00760 */ 00761 if (attributes != (const xmlChar **) NULL) 00762 { 00763 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) 00764 { 00765 keyword=(const char *) attributes[i++]; 00766 CloneString(&value,TranslateText(msl_info->image_info[n], 00767 msl_info->attributes[n],(char *) attributes[i])); 00768 switch (*keyword) 00769 { 00770 case 'R': 00771 case 'r': 00772 { 00773 if (LocaleCompare(keyword, "radius") == 0) 00774 { 00775 radius = atof( value ); 00776 break; 00777 } 00778 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 00779 break; 00780 } 00781 case 'S': 00782 case 's': 00783 { 00784 if (LocaleCompare(keyword,"sigma") == 0) 00785 { 00786 sigma = atoi( value ); 00787 break; 00788 } 00789 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 00790 break; 00791 } 00792 default: 00793 { 00794 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 00795 break; 00796 } 00797 } 00798 } 00799 } 00800 00801 /* 00802 charcoal image. 00803 */ 00804 { 00805 Image 00806 *newImage; 00807 00808 newImage=CharcoalImage(msl_info->image[n],radius,sigma,&msl_info->image[n]->exception); 00809 if (newImage == (Image *) NULL) 00810 break; 00811 msl_info->image[n]=DestroyImage(msl_info->image[n]); 00812 msl_info->image[n]=newImage; 00813 break; 00814 } 00815 } 00816 else if (LocaleCompare((char *) name,"chop") == 0) 00817 { 00818 /* init the values */ 00819 width=msl_info->image[n]->columns; 00820 height=msl_info->image[n]->rows; 00821 x = y = 0; 00822 00823 if (msl_info->image[n] == (Image *) NULL) 00824 { 00825 ThrowMSLException(OptionError,"NoImagesDefined",(char *) name); 00826 break; 00827 } 00828 if (attributes == (const xmlChar **) NULL) 00829 break; 00830 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) 00831 { 00832 keyword=(const char *) attributes[i++]; 00833 CloneString(&value,TranslateText(msl_info->image_info[n], 00834 msl_info->attributes[n],(char *) attributes[i])); 00835 switch (*keyword) 00836 { 00837 case 'G': 00838 case 'g': 00839 { 00840 if (LocaleCompare(keyword,"geometry") == 0) 00841 { 00842 (void) ParseMetaGeometry(value,&x,&y,&width,&height); 00843 break; 00844 } 00845 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 00846 break; 00847 } 00848 case 'H': 00849 case 'h': 00850 { 00851 if (LocaleCompare(keyword,"height") == 0) 00852 { 00853 height = atoi( value ); 00854 break; 00855 } 00856 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 00857 break; 00858 } 00859 case 'W': 00860 case 'w': 00861 { 00862 if (LocaleCompare(keyword,"width") == 0) 00863 { 00864 width = atoi( value ); 00865 break; 00866 } 00867 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 00868 break; 00869 } 00870 case 'X': 00871 case 'x': 00872 { 00873 if (LocaleCompare(keyword,"x") == 0) 00874 { 00875 x = atoi( value ); 00876 break; 00877 } 00878 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 00879 break; 00880 } 00881 case 'Y': 00882 case 'y': 00883 { 00884 if (LocaleCompare(keyword,"y") == 0) 00885 { 00886 y = atoi( value ); 00887 break; 00888 } 00889 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 00890 break; 00891 } 00892 default: 00893 { 00894 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 00895 break; 00896 } 00897 } 00898 } 00899 00900 /* 00901 process image. 00902 */ 00903 { 00904 Image 00905 *newImage; 00906 RectangleInfo 00907 rectInfo; 00908 00909 rectInfo.height = height; 00910 rectInfo.width = width; 00911 rectInfo.x = x; 00912 rectInfo.y = y; 00913 00914 newImage=ChopImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception); 00915 if (newImage == (Image *) NULL) 00916 break; 00917 msl_info->image[n]=DestroyImage(msl_info->image[n]); 00918 msl_info->image[n]=newImage; 00919 } 00920 00921 break; 00922 } 00923 else if (LocaleCompare((char *) name, "composite") == 0 ) 00924 { 00925 char 00926 composite_geometry[MaxTextExtent]; 00927 00928 Image * 00929 srcImage = (Image*)NULL; 00930 CompositeOperator 00931 compositeOp = OverCompositeOp; 00932 GravityType 00933 gravity = CenterGravity; 00934 00935 RectangleInfo 00936 geometry; 00937 00938 SetGeometry(msl_info->image[n],&geometry); 00939 00940 if (msl_info->image[n] == (Image *) NULL) 00941 { 00942 ThrowMSLException(OptionError,"NoImagesDefined",(char *) name); 00943 break; 00944 } 00945 if (attributes == (const xmlChar **) NULL) 00946 break; 00947 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) 00948 { 00949 keyword=(const char *) attributes[i++]; 00950 CloneString(&value,TranslateText(msl_info->image_info[n], 00951 msl_info->attributes[n],(char *) attributes[i])); 00952 switch (*keyword) 00953 { 00954 case 'C': 00955 case 'c': 00956 { 00957 if (LocaleCompare(keyword, "compose") == 0) 00958 { 00959 if (LocaleCompare(value, "Over") == 0) 00960 compositeOp = OverCompositeOp; 00961 else if (LocaleCompare(value, "In") == 0) 00962 compositeOp = InCompositeOp; 00963 else if (LocaleCompare(value, "Out") == 0) 00964 compositeOp = OutCompositeOp; 00965 else if (LocaleCompare(value, "Atop") == 0) 00966 compositeOp = AtopCompositeOp; 00967 else if (LocaleCompare(value, "Xor") == 0) 00968 compositeOp = XorCompositeOp; 00969 else if (LocaleCompare(value, "Plus") == 0) 00970 compositeOp = PlusCompositeOp; 00971 else if (LocaleCompare(value, "Minus") == 0) 00972 compositeOp = MinusCompositeOp; 00973 else if (LocaleCompare(value, "Add") == 0) 00974 compositeOp = AddCompositeOp; 00975 else if (LocaleCompare(value, "Subtract") == 0) 00976 compositeOp = SubtractCompositeOp; 00977 else if (LocaleCompare(value, "Difference") == 0) 00978 compositeOp = DifferenceCompositeOp; 00979 else if (LocaleCompare(value, "Multiply") == 0) 00980 compositeOp = MultiplyCompositeOp; 00981 else if (LocaleCompare(value, "Bumpmap") == 0) 00982 compositeOp = BumpmapCompositeOp; 00983 else if (LocaleCompare(value, "Copy") == 0) 00984 compositeOp = CopyCompositeOp; 00985 else if (LocaleCompare(value, "CopyRed") == 0) 00986 compositeOp = CopyRedCompositeOp; 00987 else if (LocaleCompare(value, "CopyCyan") == 0) 00988 compositeOp = CopyCyanCompositeOp; 00989 else if (LocaleCompare(value, "CopyGreen") == 0) 00990 compositeOp = CopyGreenCompositeOp; 00991 else if (LocaleCompare(value, "CopyMagenta") == 0) 00992 compositeOp = CopyMagentaCompositeOp; 00993 else if (LocaleCompare(value, "CopyBlue") == 0) 00994 compositeOp = CopyBlueCompositeOp; 00995 else if (LocaleCompare(value, "CopyYellow") == 0) 00996 compositeOp = CopyYellowCompositeOp; 00997 else if (LocaleCompare(value, "CopyOpacity") == 0) 00998 compositeOp = CopyOpacityCompositeOp; 00999 else if (LocaleCompare(value, "CopyBlack") == 0) 01000 compositeOp = CopyBlackCompositeOp; 01001 else if (LocaleCompare(value, "Dissolve") == 0) 01002 compositeOp = DissolveCompositeOp; 01003 else if (LocaleCompare(value, "Clear") == 0) 01004 compositeOp = ClearCompositeOp; 01005 else if (LocaleCompare(value, "Displace") == 0) 01006 compositeOp = DisplaceCompositeOp; 01007 else if (LocaleCompare(value, "Modulate") == 0) 01008 compositeOp = ModulateCompositeOp; 01009 else if (LocaleCompare(value, "Threshold") == 0) 01010 compositeOp = ThresholdCompositeOp; 01011 else if (LocaleCompare(value, "Darken") == 0) 01012 compositeOp = DarkenCompositeOp; 01013 else if (LocaleCompare(value, "Lighten") == 0) 01014 compositeOp = LightenCompositeOp; 01015 else if (LocaleCompare(value, "Hue") == 0) 01016 compositeOp = HueCompositeOp; 01017 else if (LocaleCompare(value, "Saturate") == 0) 01018 compositeOp = SaturateCompositeOp; 01019 else if (LocaleCompare(value, "Colorize") == 0) 01020 compositeOp = ColorizeCompositeOp; 01021 else if (LocaleCompare(value, "Luminize") == 0) 01022 compositeOp = LuminizeCompositeOp; 01023 else if (LocaleCompare(value, "Screen") == 0) 01024 compositeOp = ScreenCompositeOp; 01025 else if (LocaleCompare(value, "Overlay") == 0) 01026 compositeOp = OverlayCompositeOp; 01027 else 01028 ThrowMSLException(OptionError,"UnrecognizedComposeOperator", 01029 value); 01030 break; 01031 } 01032 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01033 break; 01034 } 01035 case 'G': 01036 case 'g': 01037 { 01038 if (LocaleCompare(keyword,"geometry") == 0) 01039 { 01040 (void) ParseGravityGeometry(msl_info->image[n],value,&geometry); 01041 break; 01042 } 01043 else if (LocaleCompare(keyword,"gravity") == 0) 01044 { 01045 long 01046 i; 01047 01048 i = ParseMagickOption(MagickGravityOptions,MagickFalse,value); 01049 if (i < 0) 01050 ThrowMSLException(OptionError,"UnrecognizedComposeOperator", 01051 value); 01052 gravity = (GravityType) i; 01053 break; 01054 } 01055 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01056 break; 01057 } 01058 case 'I': 01059 case 'i': 01060 { 01061 if (LocaleCompare(keyword,"image") == 0) 01062 { 01063 for (j=0; j<msl_info->n;j++) 01064 { 01065 const ImageAttribute * 01066 theAttr = GetImageAttribute(msl_info->attributes[j], "id"); 01067 if (theAttr && LocaleCompare(theAttr->value, value) == 0) 01068 { 01069 srcImage = msl_info->image[j]; 01070 break; 01071 } 01072 } 01073 break; 01074 } 01075 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01076 break; 01077 } 01078 case 'X': 01079 case 'x': 01080 { 01081 if (LocaleCompare(keyword,"x") == 0) 01082 { 01083 geometry.x = atoi( value ); 01084 break; 01085 } 01086 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01087 break; 01088 } 01089 case 'Y': 01090 case 'y': 01091 { 01092 if (LocaleCompare(keyword,"y") == 0) 01093 { 01094 geometry.y = atoi( value ); 01095 break; 01096 } 01097 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01098 break; 01099 } 01100 default: 01101 { 01102 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01103 break; 01104 } 01105 } 01106 } 01107 01108 /* 01109 process image. 01110 */ 01111 if (srcImage != (Image*)NULL) 01112 { 01113 unsigned int 01114 result; 01115 01116 (void) FormatMagickString(composite_geometry,MaxTextExtent, 01117 "%lux%lu%+ld%+ld",msl_info->image[n]->columns, 01118 msl_info->image[n]->rows,geometry.x,geometry.y); 01119 (void) ParseGravityGeometry(msl_info->image[n],composite_geometry, 01120 &geometry); 01121 result = CompositeImage(msl_info->image[n], compositeOp, srcImage, geometry.x, geometry.y); 01122 break; 01123 } else 01124 ThrowMSLException(OptionError,"no composite image defined", 01125 (char *) name); 01126 01127 break; 01128 } 01129 else if (LocaleCompare((char *) name, "contrast") == 0) 01130 { 01131 MagickBooleanType 01132 sharpen = MagickFalse; 01133 01134 if (msl_info->image[n] == (Image *) NULL) 01135 { 01136 ThrowMSLException(OptionError,"NoImagesDefined",(char *) name); 01137 break; 01138 } 01139 if (attributes == (const xmlChar **) NULL) 01140 break; 01141 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) 01142 { 01143 keyword=(const char *) attributes[i++]; 01144 CloneString(&value,(char *) attributes[i]); 01145 (void) CopyMagickString(key,value,MaxTextExtent); 01146 switch (*keyword) 01147 { 01148 case 'S': 01149 case 's': 01150 { 01151 if (LocaleCompare(keyword,"sharpen") == 0) 01152 { 01153 sharpen = (MagickBooleanType) atoi( value ); 01154 break; 01155 } 01156 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01157 break; 01158 } 01159 default: 01160 { 01161 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01162 break; 01163 } 01164 } 01165 } 01166 01167 /* process image */ 01168 { 01169 ContrastImage ( msl_info->image[n], sharpen ); 01170 break; 01171 } 01172 } 01173 else if (LocaleCompare((char *) name,"crop") == 0) 01174 { 01175 /* init the values */ 01176 width=msl_info->image[n]->columns; 01177 height=msl_info->image[n]->rows; 01178 x = y = 0; 01179 01180 if (msl_info->image[n] == (Image *) NULL) 01181 { 01182 ThrowMSLException(OptionError,"NoImagesDefined",(char *) name); 01183 break; 01184 } 01185 if (attributes == (const xmlChar **) NULL) 01186 break; 01187 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) 01188 { 01189 keyword=(const char *) attributes[i++]; 01190 CloneString(&value,TranslateText(msl_info->image_info[n], 01191 msl_info->attributes[n],(char *) attributes[i])); 01192 switch (*keyword) 01193 { 01194 case 'G': 01195 case 'g': 01196 { 01197 if (LocaleCompare(keyword,"geometry") == 0) 01198 { 01199 (void) ParseMetaGeometry(value,&x,&y,&width,&height); 01200 break; 01201 } 01202 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01203 break; 01204 } 01205 case 'H': 01206 case 'h': 01207 { 01208 if (LocaleCompare(keyword,"height") == 0) 01209 { 01210 height = atoi( value ); 01211 break; 01212 } 01213 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01214 break; 01215 } 01216 case 'W': 01217 case 'w': 01218 { 01219 if (LocaleCompare(keyword,"width") == 0) 01220 { 01221 width = atoi( value ); 01222 break; 01223 } 01224 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01225 break; 01226 } 01227 case 'X': 01228 case 'x': 01229 { 01230 if (LocaleCompare(keyword,"x") == 0) 01231 { 01232 x = atoi( value ); 01233 break; 01234 } 01235 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01236 break; 01237 } 01238 case 'Y': 01239 case 'y': 01240 { 01241 if (LocaleCompare(keyword,"y") == 0) 01242 { 01243 y = atoi( value ); 01244 break; 01245 } 01246 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01247 break; 01248 } 01249 default: 01250 { 01251 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01252 break; 01253 } 01254 } 01255 } 01256 01257 /* 01258 process image. 01259 */ 01260 { 01261 Image 01262 *newImage; 01263 RectangleInfo 01264 rectInfo; 01265 01266 rectInfo.height = height; 01267 rectInfo.width = width; 01268 rectInfo.x = x; 01269 rectInfo.y = y; 01270 01271 newImage=CropImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception); 01272 if (newImage == (Image *) NULL) 01273 break; 01274 msl_info->image[n]=DestroyImage(msl_info->image[n]); 01275 msl_info->image[n]=newImage; 01276 } 01277 01278 break; 01279 } 01280 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) name); 01281 } 01282 case 'D': 01283 case 'd': 01284 { 01285 if (LocaleCompare((char *) name, "despeckle") == 0) 01286 { 01287 if (msl_info->image[n] == (Image *) NULL) 01288 { 01289 ThrowMSLException(OptionError,"NoImagesDefined",(char *) name); 01290 break; 01291 } 01292 01293 /* no attributes here */ 01294 01295 /* process the image */ 01296 { 01297 Image 01298 *newImage; 01299 01300 newImage=DespeckleImage(msl_info->image[n],&msl_info->image[n]->exception); 01301 if (newImage == (Image *) NULL) 01302 break; 01303 msl_info->image[n]=DestroyImage(msl_info->image[n]); 01304 msl_info->image[n]=newImage; 01305 break; 01306 } 01307 } 01308 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) name); 01309 } 01310 case 'E': 01311 case 'e': 01312 { 01313 if (LocaleCompare((char *) name, "edge") == 0) 01314 { 01315 double radius = 0.0; 01316 01317 if (msl_info->image[n] == (Image *) NULL) 01318 { 01319 ThrowMSLException(OptionError,"NoImagesDefined",(char *) name); 01320 break; 01321 } 01322 /* 01323 NOTE: edge can have no attributes, since we use all the defaults! 01324 */ 01325 if (attributes != (const xmlChar **) NULL) 01326 { 01327 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) 01328 { 01329 keyword=(const char *) attributes[i++]; 01330 CloneString(&value,TranslateText(msl_info->image_info[n], 01331 msl_info->attributes[n],(char *) attributes[i])); 01332 switch (*keyword) 01333 { 01334 case 'R': 01335 case 'r': 01336 { 01337 if (LocaleCompare(keyword, "radius") == 0) 01338 { 01339 radius = atof( value ); 01340 break; 01341 } 01342 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01343 break; 01344 } 01345 default: 01346 { 01347 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01348 break; 01349 } 01350 } 01351 } 01352 } 01353 01354 /* 01355 edge image. 01356 */ 01357 { 01358 Image 01359 *newImage; 01360 01361 newImage=EdgeImage(msl_info->image[n],radius,&msl_info->image[n]->exception); 01362 if (newImage == (Image *) NULL) 01363 break; 01364 msl_info->image[n]=DestroyImage(msl_info->image[n]); 01365 msl_info->image[n]=newImage; 01366 break; 01367 } 01368 } 01369 else if (LocaleCompare((char *) name, "emboss") == 0) 01370 { 01371 double radius = 0.0, 01372 sigma = 1.0; 01373 01374 if (msl_info->image[n] == (Image *) NULL) 01375 { 01376 ThrowMSLException(OptionError,"NoImagesDefined",(char *) name); 01377 break; 01378 } 01379 /* 01380 NOTE: emboss can have no attributes, since we use all the defaults! 01381 */ 01382 if (attributes != (const xmlChar **) NULL) 01383 { 01384 for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) 01385 { 01386 keyword=(const char *) attributes[i++]; 01387 CloneString(&value,TranslateText(msl_info->image_info[n], 01388 msl_info->attributes[n],(char *) attributes[i])); 01389 switch (*keyword) 01390 { 01391 case 'R': 01392 case 'r': 01393 { 01394 if (LocaleCompare(keyword, "radius") == 0) 01395 { 01396 radius = atof( value ); 01397 break; 01398 } 01399 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01400 break; 01401 } 01402 case 'S': 01403 case 's': 01404 { 01405 if (LocaleCompare(keyword,"sigma") == 0) 01406 { 01407 sigma = atoi( value ); 01408 break; 01409 } 01410 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01411 break; 01412 } 01413 default: 01414 { 01415 ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); 01416 break; 01417 } 01418 } 01419 } 01420 } 01421 01422 /* 01423 emboss image. 01424 */ 01425 { 01426 Image 01427 *newImage; 01428 01429 newImage=EmbossImage(msl_info->image[n],radius,sigma,&msl_info->image[n]->exception); 01430 if (newImage == (Image *) NULL) 01431 break; 01432 msl_info->image[n]=DestroyImage(msl_info->image[n]); 01433 msl_info->image[n]=newImage; 01434 break; 01435 } 01436 } 01437 else if (LocaleCompare((char *) name, "enhance") == 0) 01438 { 01439 if (msl_info->image[n] == (Image *) NULL) 01440 { 01441 ThrowMSLException(OptionError,"NoImagesDefined",(char *) name); 01442 break; 01443 } 01444 01445 /* no attributes here */ 01446 01447 /* process the image */ 01448 { 01449 Image 01450 *newImage; 01451 01452 newImage=EnhanceImage(msl_info->image[n],&msl_info->image[n]->exception); 01453 if (newImage == (Image *) NULL) 01454 break; 01455 msl_info->image[n]=DestroyImage(msl_info->image[n]); 01456 msl_info->image[n]=newImage; 01457 break; 01458 } 01459 } 01460 else if (LocaleCompare((char *) name, "equalize") == 0) 01461 { 01462 if (msl_info->image[n] == (Image *) NULL) 01463 { 01464 ThrowMSLException(OptionError,"NoImagesDefined",(char *) name); 01465 break; 01466 } 01467 01468 /* no attributes here */ 01469 01470 /* process the image */ 01471 { 01472 EqualizeImage(msl_info->image[n]); /* why doesn't this take an exception or return the changed image */ 01473 break; 01474 } 01475 } 01476 ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) name); 01477 } 01478 case 'F': 01479 case 'f': 01480 { 01481 if (LocaleCompare((char *) name, "flatten") == 0) 01482 { 01483 if (msl_info->image[n] == (Image *) NULL) 01484 { 01485 ThrowMSLException(OptionError,"NoImagesDefined",(char *) name); 01486 break; 01487 } 01488 01489 /* no attributes here */ 01490 01491 /* process the image */ 01492 { 01493 Image 01494 *newImage; 01495 01496 newImage=FlattenImages(msl_info->image[n],&msl_info->image[n]->exception); 01497 if (newImage == (Image *) NULL) 01498 break; 01499 msl_info->image[n]=DestroyImage(msl_info->image[n]); 01500 msl_info->image[n]=newImage; 01501 break; 01502 } 01503 } 01504 else if (LocaleCompare((char *) name, "flip") == 0) 01505 { 01506 if (msl_info->image[n] == (Image *) NULL) 01507 { 01508 ThrowMSLException(OptionError,"NoImagesDefined",(char *) name); 01509 break; 01510 } 01511 01512 /* no attributes here */ 01513 01514 /* process the image */ 01515 { 01516 Image 01517 *newImage; 01518 01519 newImage=FlipImage(msl_info->image[n],&msl_info->image[n]->exception); 01520 if (newImage == (Image *) NULL) 01521 break; 01522 msl_info->image[n]=DestroyImage(msl_info->image[n]); 01523 msl_info->image[n]=newImage; 01524 break; 01525 } 01526 } 01527 else if (LocaleCompare((char *) name, "flop") == 0) 01528 { 01529 if (msl_info->image[n] == (Image *) NULL) 01530 { 01531 ThrowMSLException(OptionError,"NoImagesDefined",(char *) name); 01532 break; 01533 } 01534 01535 /* no attributes here */ 01536 01537 /* process the image */ 01538 { 01539 Image 01540 *newImage; 01541 01542 newImage=FlopImage(msl_info->image[n],&msl_info->image[n]->exception); 01543 if (newImage == (Image *) NULL) 01544 break; 01545 msl_info->image[n]=