geometry.c

Go to the documentation of this file.
00001 /*
00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00003 %                                                                             %
00004 %                                                                             %
00005 %                                                                             %
00006 %           GGGG   EEEEE   OOO   M   M  EEEEE  TTTTT  RRRR   Y   Y            %
00007 %           G      E      O   O  MM MM  E        T    R   R   Y Y             %
00008 %           G  GG  EEE    O   O  M M M  EEE      T    RRRR     Y              %
00009 %           G   G  E      O   O  M   M  E        T    R R      Y              %
00010 %            GGGG  EEEEE   OOO   M   M  EEEEE    T    R  R     Y              %
00011 %                                                                             %
00012 %                                                                             %
00013 %                       MagickCore Geometry Methods                           %
00014 %                                                                             %
00015 %                             Software Design                                 %
00016 %                               John Cristy                                   %
00017 %                              January 2003                                   %
00018 %                                                                             %
00019 %                                                                             %
00020 %  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
00021 %  dedicated to making software imaging solutions freely available.           %
00022 %                                                                             %
00023 %  You may not use this file except in compliance with the License.  You may  %
00024 %  obtain a copy of the License at                                            %
00025 %                                                                             %
00026 %    http://www.imagemagick.org/script/license.php                            %
00027 %                                                                             %
00028 %  Unless required by applicable law or agreed to in writing, software        %
00029 %  distributed under the License is distributed on an "AS IS" BASIS,          %
00030 %  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
00031 %  See the License for the specific language governing permissions and        %
00032 %  limitations under the License.                                             %
00033 %                                                                             %
00034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00035 %
00036 %
00037 */
00038 
00039 /*
00040   Include declarations.
00041 */
00042 #include "magick/studio.h"
00043 #include "magick/constitute.h"
00044 #include "magick/draw.h"
00045 #include "magick/exception.h"
00046 #include "magick/exception-private.h"
00047 #include "magick/geometry.h"
00048 #include "magick/memory_.h"
00049 #include "magick/string_.h"
00050 #include "magick/token.h"
00051 
00052 /*
00053 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00054 %                                                                             %
00055 %                                                                             %
00056 %                                                                             %
00057 %   G e t G e o m e t r y                                                     %
00058 %                                                                             %
00059 %                                                                             %
00060 %                                                                             %
00061 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00062 %
00063 %  GetGeometry() parses a geometry specification and returns the width,
00064 %  height, x, and y values.  It also returns flags that indicates which
00065 %  of the four values (width, height, x, y) were located in the string, and
00066 %  whether the x or y values are negative.  In addition, there are flags to
00067 %  report any meta characters (%, !, <, or >).
00068 %
00069 %  The format of the GetGeometry method is:
00070 %
00071 %      MagickStatusType GetGeometry(const char *geometry,long *x,long *y,
00072 %        unsigned long *width,unsigned long *height)
00073 %
00074 %  A description of each parameter follows:
00075 %
00076 %    o geometry:  The geometry.
00077 %
00078 %    o x,y:  The x and y offset as determined by the geometry specification.
00079 %
00080 %    o width,height:  The width and height as determined by the geometry
00081 %      specification.
00082 %
00083 */
00084 MagickExport MagickStatusType GetGeometry(const char *geometry,long *x,long *y,
00085   unsigned long *width,unsigned long *height)
00086 {
00087   char
00088     *p,
00089     pedantic_geometry[MaxTextExtent],
00090     *q;
00091 
00092   double
00093     value;
00094 
00095   MagickStatusType
00096     flags;
00097 
00098   /*
00099     Remove whitespace and meta characters from geometry specification.
00100   */
00101   flags=NoValue;
00102   if ((geometry == (char *) NULL) || (*geometry == '\0'))
00103     return(flags);
00104   if (strlen(geometry) >= MaxTextExtent)
00105     return(flags);
00106   (void) CopyMagickString(pedantic_geometry,geometry,MaxTextExtent);
00107   for (p=pedantic_geometry; *p != '\0'; )
00108   {
00109     if (isspace((int) ((unsigned char) *p)) != 0)
00110       {
00111         (void) CopyMagickString(p,p+1,MaxTextExtent);
00112         continue;
00113       }
00114     switch (*p)
00115     {
00116       case '%':
00117       {
00118         flags|=PercentValue;
00119         (void) CopyMagickString(p,p+1,MaxTextExtent);
00120         break;
00121       }
00122       case '!':
00123       {
00124         flags|=AspectValue;
00125         (void) CopyMagickString(p,p+1,MaxTextExtent);
00126         break;
00127       }
00128       case '<':
00129       {
00130         flags|=LessValue;
00131         (void) CopyMagickString(p,p+1,MaxTextExtent);
00132         break;
00133       }
00134       case '>':
00135       {
00136         flags|=GreaterValue;
00137         (void) CopyMagickString(p,p+1,MaxTextExtent);
00138         break;
00139       }
00140       case '^':
00141       {
00142         flags|=MinimumValue;
00143         (void) CopyMagickString(p,p+1,MaxTextExtent);
00144         break;
00145       }
00146       case '@':
00147       {
00148         flags|=AreaValue;
00149         (void) CopyMagickString(p,p+1,MaxTextExtent);
00150         break;
00151       }
00152       case '(':
00153       case ')':
00154       {
00155         (void) CopyMagickString(p,p+1,MaxTextExtent);
00156         break;
00157       }
00158       case '-':
00159       case '.':
00160       case ',':
00161       case '+':
00162       case '0':
00163       case '1':
00164       case '2':
00165       case '3':
00166       case '4':
00167       case '5':
00168       case '6':
00169       case '7':
00170       case '8':
00171       case '9':
00172       case -41:
00173       case 'x':
00174       case 'X':
00175       {
00176         p++;
00177         break;
00178       }
00179       default:
00180         return(flags);
00181     }
00182   }
00183   /*
00184     Parse width, height, x, and y.
00185   */
00186   p=pedantic_geometry;
00187   if (*p == '\0')
00188     return(flags);
00189   q=p;
00190   value=strtod(p,&q);
00191   if (LocaleNCompare(p,"0x",2) == 0)
00192     value=(double) strtol(p,&q,10);
00193   if (((int) *q == -41) || (*q == 'x') || (*q == 'X') || (*q == '\0'))
00194     {
00195       /*
00196         Parse width.
00197       */
00198       q=p;
00199       if (LocaleNCompare(p,"0x",2) == 0)
00200         *width=(unsigned long) strtol(p,&p,10);
00201       else
00202         *width=(unsigned long) floor(strtod(p,&p)+0.5);
00203       if (p != q)
00204         flags|=WidthValue;
00205     }
00206   if (((int) *p == -41) || (*p == 'x') || (*p == 'X'))
00207     {
00208       p++;
00209       if ((*p != '+') && (*p != '-'))
00210         {
00211           /*
00212             Parse height.
00213           */
00214           q=p;
00215           *height=(unsigned long) floor(strtod(p,&p)+0.5);
00216           if (p != q)
00217             flags|=HeightValue;
00218         }
00219     }
00220   if ((*p == '+') || (*p == '-'))
00221     {
00222       /*
00223         Parse x value.
00224       */
00225       if (*p == '-')
00226         flags|=XNegative;
00227       q=p;
00228       *x=(long) ceil(strtod(p,&p)-0.5);
00229       if (p != q)
00230         flags|=XValue;
00231       if ((*p == '+') || (*p == '-'))
00232         {
00233           /*
00234             Parse y value.
00235           */
00236           if (*p == '-')
00237             flags|=YNegative;
00238           q=p;
00239           *y=(long) ceil(strtod(p,&p)-0.5);
00240           if (p != q)
00241             flags|=YValue;
00242         }
00243     }
00244   return(flags);
00245 }
00246 
00247 /*
00248 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00249 %                                                                             %
00250 %                                                                             %
00251 %                                                                             %
00252 %  G e t P a g e G e o m e t r y                                              %
00253 %                                                                             %
00254 %                                                                             %
00255 %                                                                             %
00256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00257 %
00258 %  GetPageGeometry() replaces any page mneumonic with the equivalent size in
00259 %  picas.
00260 %
00261 %  The format of the GetPageGeometry method is:
00262 %
00263 %      char *GetPageGeometry(const char *page_geometry)
00264 %
00265 %  A description of each parameter follows.
00266 %
00267 %   o  page_geometry:  Specifies a pointer to an array of characters.
00268 %      The string is either a Postscript page name (e.g. A4) or a postscript
00269 %      page geometry (e.g. 612x792+36+36).
00270 %
00271 */
00272 MagickExport char *GetPageGeometry(const char *page_geometry)
00273 {
00274   static const char
00275     *PageSizes[][2]=
00276     {
00277       { "4x6",  "288x432" },
00278       { "5x7",  "360x504" },
00279       { "7x9",  "504x648" },
00280       { "8x10", "576x720" },
00281       { "9x11",  "648x792" },
00282       { "9x12",  "648x864" },
00283       { "10x13",  "720x936" },
00284       { "10x14",  "720x1008" },
00285       { "11x17",  "792x1224" },
00286       { "a0",  "2384x3370" },
00287       { "a1",  "1684x2384" },
00288       { "a10", "73x105" },
00289       { "a2",  "1191x1684" },
00290       { "a3",  "842x1191" },
00291       { "a4",  "595x842" },
00292       { "a4smaLL", "595x842" },
00293       { "a5",  "420x595" },
00294       { "a6",  "297x420" },
00295       { "a7",  "210x297" },
00296       { "a8",  "148x210" },
00297       { "a9",  "105x148" },
00298       { "archa", "648x864" },
00299       { "archb", "864x1296" },
00300       { "archC", "1296x1728" },
00301       { "archd", "1728x2592" },
00302       { "arche", "2592x3456" },
00303       { "b0",  "2920x4127" },
00304       { "b1",  "2064x2920" },
00305       { "b10", "91x127" },
00306       { "b2",  "1460x2064" },
00307       { "b3",  "1032x1460" },
00308       { "b4",  "729x1032" },
00309       { "b5",  "516x729" },
00310       { "b6",  "363x516" },
00311       { "b7",  "258x363" },
00312       { "b8",  "181x258" },
00313       { "b9",  "127x181" },
00314       { "c0",  "2599x3676" },
00315       { "c1",  "1837x2599" },
00316       { "c2",  "1298x1837" },
00317       { "c3",  "918x1296" },
00318       { "c4",  "649x918" },
00319       { "c5",  "459x649" },
00320       { "c6",  "323x459" },
00321       { "c7",  "230x323" },
00322       { "executive", "540x720" },
00323       { "flsa", "612x936" },
00324       { "flse", "612x936" },
00325       { "folio",  "612x936" },
00326       { "halfletter", "396x612" },
00327       { "isob0", "2835x4008" },
00328       { "isob1", "2004x2835" },
00329       { "isob10", "88x125" },
00330       { "isob2", "1417x2004" },
00331       { "isob3", "1001x1417" },
00332       { "isob4", "709x1001" },
00333       { "isob5", "499x709" },
00334       { "isob6", "354x499" },
00335       { "isob7", "249x354" },
00336       { "isob8", "176x249" },
00337       { "isob9", "125x176" },
00338       { "jisb0", "1030x1456" },
00339       { "jisb1", "728x1030" },
00340       { "jisb2", "515x728" },
00341       { "jisb3", "364x515" },
00342       { "jisb4", "257x364" },
00343       { "jisb5", "182x257" },
00344       { "jisb6", "128x182" },
00345       { "ledger",  "1224x792" },
00346       { "legal",  "612x1008" },
00347       { "letter", "612x792" },
00348       { "lettersmaLL",  "612x792" },
00349       { "quarto",  "610x780" },
00350       { "statement",  "396x612" },
00351       { "tabloid",  "792x1224" },
00352       { (char *) NULL, (char *) NULL }
00353     };
00354 
00355   char
00356     *page;
00357 
00358   register long
00359     i;
00360 
00361   assert(page_geometry != (char *) NULL);
00362   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",page_geometry);
00363   page=AcquireString(page_geometry);
00364   for (i=0; *PageSizes[i] != (char *) NULL; i++)
00365     if (LocaleNCompare(PageSizes[i][0],page,strlen(PageSizes[i][0])) == 0)
00366       {
00367         RectangleInfo
00368           geometry;
00369 
00370         MagickStatusType
00371           flags;
00372 
00373         /*
00374           Replace mneumonic with the equivalent size in dots-per-inch.
00375         */
00376         (void) CopyMagickString(page,PageSizes[i][1],MaxTextExtent);
00377         (void) ConcatenateMagickString(page,page_geometry+
00378           strlen(PageSizes[i][0]),MaxTextExtent);
00379         flags=GetGeometry(page,&geometry.x,&geometry.y,&geometry.width,
00380           &geometry.height);
00381         if ((flags & GreaterValue) == 0)
00382           (void) ConcatenateMagickString(page,">",MaxTextExtent);
00383         break;
00384       }
00385   return(page);
00386 }
00387 
00388 /*
00389 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00390 %                                                                             %
00391 %                                                                             %
00392 %                                                                             %
00393 %   G r a v i t y A d j u s t G e o m e t r y                                 %
00394 %                                                                             %
00395 %                                                                             %
00396 %                                                                             %
00397 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00398 %
00399 %  GravityAdjustGeometry() adjusts the offset of a region with regard to the
00400 %  given: width, height and gravity; against which it is positioned.
00401 %
00402 %  The region should also have an appropriate width and height to correctly
00403 %  set the right offset of the top left corner of the region.
00404 %
00405 %  The format of the GravityAdjustGeometry method is:
00406 %
00407 %      void GravityAdjustGeometry(const unsigned long width,
00408 %        const unsigned long height,const GravityType gravity,
00409 %        RectangleInfo *region);
00410 %
00411 %  A description of each parameter follows:
00412 %
00413 %    o width, height:  the larger area the region is relative to
00414 %
00415 %    o gravity: the edge/corner the current offset is relative to
00416 %
00417 %    o region:  The region requiring a offset adjustment relative to gravity
00418 %
00419 */
00420 MagickExport void GravityAdjustGeometry(const unsigned long width,
00421   const unsigned long height,const GravityType gravity,RectangleInfo *region)
00422 {
00423   if (region->height == 0)
00424     region->height=height;
00425   if (region->width == 0)
00426     region->width=width;
00427   switch (gravity)
00428   {
00429     case NorthEastGravity:
00430     case EastGravity:
00431     case SouthEastGravity:
00432     {
00433       region->x=(long) (width-region->width-region->x);
00434       break;
00435     }
00436     case NorthGravity:
00437     case SouthGravity:
00438     case CenterGravity:
00439     case StaticGravity:
00440     {
00441       region->x+=(long) (width/2-region->width/2);
00442       break;
00443     }
00444     case ForgetGravity:
00445     case NorthWestGravity:
00446     case WestGravity:
00447     case SouthWestGravity:
00448     default:
00449       break;
00450   }
00451   switch (gravity)
00452   {
00453     case SouthWestGravity:
00454     case SouthGravity:
00455     case SouthEastGravity:
00456     {
00457       region->y=(long) (height-region->height-region->y);
00458       break;
00459     }
00460     case EastGravity:
00461     case WestGravity:
00462     case CenterGravity:
00463     case StaticGravity:
00464     {
00465       region->y+=(long) (height/2-region->height/2);
00466       break;
00467     }
00468     case ForgetGravity:
00469     case NorthWestGravity:
00470     case NorthGravity:
00471     case NorthEastGravity:
00472     default:
00473       break;
00474   }
00475   return;
00476 }
00477 
00478 /*
00479 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00480 %                                                                             %
00481 %                                                                             %
00482 %                                                                             %
00483 +     I s G e o m e t r y                                                     %
00484 %                                                                             %
00485 %                                                                             %
00486 %                                                                             %
00487 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00488 %
00489 %  IsGeometry() returns MagickTrue if the geometry specification is valid.
00490 %  Examples are 100, 100x200, x200, 100x200+10+20, +10+20, 200%, 200x200!, etc.
00491 %
00492 %  The format of the IsGeometry method is:
00493 %
00494 %      MagickBooleanType IsGeometry(const char *geometry)
00495 %
00496 %  A description of each parameter follows:
00497 %
00498 %    o geometry: This string is the geometry specification.
00499 %
00500 */
00501 MagickExport MagickBooleanType IsGeometry(const char *geometry)
00502 {
00503   GeometryInfo
00504     geometry_info;
00505 
00506   MagickStatusType
00507     flags;
00508 
00509   if (geometry == (const char *) NULL)
00510     return(MagickFalse);
00511   flags=ParseGeometry(geometry,&geometry_info);
00512   if (flags == NoValue)
00513     flags=ParseGeometry(geometry+1,&geometry_info);  /* i.e. +-4+-4 */
00514   return(flags != NoValue ? MagickTrue : MagickFalse);
00515 }
00516 
00517 /*
00518 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00519 %                                                                             %
00520 %                                                                             %
00521 %                                                                             %
00522 +     I s S c e n e G e o m e t r y                                           %
00523 %                                                                             %
00524 %                                                                             %
00525 %                                                                             %
00526 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00527 %
00528 %  IsSceneGeometry() returns MagickTrue if the geometry is a valid scene
00529 %  specification (e.g. [1], [1-9], [1,7,4]).
00530 %
00531 %  The format of the IsSceneGeometry method is:
00532 %
00533 %      MagickBooleanType IsSceneGeometry(const char *geometry,
00534 %        const MagickBooleanType pedantic)
00535 %
00536 %  A description of each parameter follows:
00537 %
00538 %    o geometry: This string is the geometry specification.
00539 %
00540 %    o pedantic: A value other than 0 invokes a more restrictive set of
00541 %      conditions for a valid specification (e.g. [1], [1-4], [4-1]).
00542 %
00543 */
00544 MagickExport MagickBooleanType IsSceneGeometry(const char *geometry,
00545   const MagickBooleanType pedantic)
00546 {
00547   char
00548     *p;
00549 
00550   double
00551     value;
00552 
00553   if (geometry == (const char *) NULL)
00554     return(MagickFalse);
00555   p=(char *) geometry;
00556   value=strtod(geometry,&p);
00557   if (p == geometry)
00558     return(MagickFalse);
00559   if (strspn(geometry,"0123456789-, ") != strlen(geometry))
00560     return(MagickFalse);
00561   if ((pedantic != MagickFalse) && (strchr(geometry,',') != (char *) NULL))
00562     return(MagickFalse);
00563   return(MagickTrue);
00564 }
00565 
00566 /*
00567 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00568 %                                                                             %
00569 %                                                                             %
00570 %                                                                             %
00571 %   P a r s e A b s o l u t e G e o m e t r y                                 %
00572 %                                                                             %
00573 %                                                                             %
00574 %                                                                             %
00575 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00576 %
00577 %  ParseAbsoluteGeometry() returns a region as defined by the geometry string.
00578 %
00579 %  The format of the ParseAbsoluteGeometry method is:
00580 %
00581 %      MagickStatusType ParseAbsoluteGeometry(const char *geometry,
00582 %        RectangleInfo *region_info)
00583 %
00584 %  A description of each parameter follows:
00585 %
00586 %    o geometry:  The geometry (e.g. 100x100+10+10).
00587 %
00588 %    o region_info: the region as defined by the geometry string.
00589 %
00590 */
00591 MagickExport MagickStatusType ParseAbsoluteGeometry(const char *geometry,
00592   RectangleInfo *region_info)
00593 {
00594   MagickStatusType
00595     flags;
00596 
00597   flags=GetGeometry(geometry,&region_info->x,&region_info->y,
00598     &region_info->width,&region_info->height);
00599   return(flags);
00600 }
00601 
00602 /*
00603 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00604 %                                                                             %
00605 %                                                                             %
00606 %                                                                             %
00607 %   P a r s e A f f i n e G e o m e t r y                                     %
00608 %                                                                             %
00609 %                                                                             %
00610 %                                                                             %
00611 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00612 %
00613 %  ParseAffineGeometry() returns an affine matrix as defined by the geometry
00614 %  string.
00615 %
00616 %  The format of the ParseAffineGeometry method is:
00617 %
00618 %      MagickStatusType ParseAffineGeometry(const char *geometry,
00619 %        AffineMatrix *affine_matrix,ExceptionInfo *exception)
00620 %
00621 %  A description of each parameter follows:
00622 %
00623 %    o geometry:  The geometry (e.g. 1.0,0.0,0.0,1.0,3.2,1.2).
00624 %
00625 %    o affine_matrix: the affine matrix as defined by the geometry string.
00626 %
00627 %    o exception: return any errors or warnings in this structure.
00628 %
00629 */
00630 MagickExport MagickStatusType ParseAffineGeometry(const char *geometry,
00631   AffineMatrix *affine_matrix,ExceptionInfo *exception)
00632 {
00633   char
00634     token[MaxTextExtent];
00635 
00636   const char
00637     *p;
00638 
00639   double
00640     determinant;
00641 
00642   MagickStatusType
00643     flags;
00644 
00645   register long
00646     i;
00647 
00648   GetAffineMatrix(affine_matrix);
00649   flags=NoValue;
00650   p=(char *) geometry;
00651   for (i=0; (*p != '\0') && (i < 6); i++)
00652   {
00653     GetMagickToken(p,&p,token);
00654     if (*token == ',')
00655       GetMagickToken(p,&p,token);
00656     switch (i)
00657     {
00658       case 0: affine_matrix->sx=atof(token); break;
00659       case 1: affine_matrix->rx=atof(token); break;
00660       case 2: affine_matrix->ry=atof(token); break;
00661       case 3: affine_matrix->sy=atof(token); break;
00662       case 4: affine_matrix->tx=atof(token); flags|=XValue; break;
00663       case 5: affine_matrix->ty=atof(token); flags|=YValue; break;
00664     }
00665   }
00666   determinant=(affine_matrix->sx*affine_matrix->sy-affine_matrix->rx*
00667     affine_matrix->ry);
00668   if (fabs(determinant) < MagickEpsilon)
00669     (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
00670       "InvalidGeometry","`%s'",geometry);
00671   return(flags);
00672 }
00673 
00674 /*
00675 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00676 %                                                                             %
00677 %                                                                             %
00678 %                                                                             %
00679 %   P a r s e G e o m e t r y                                                 %
00680 %                                                                             %
00681 %                                                                             %
00682 %                                                                             %
00683 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00684 %
00685 %  ParseGeometry() parses a geometry specification and returns the sigma,
00686 %  rho, xi, and psi values.  It also returns flags that indicates which
00687 %  of the four values (sigma, rho, xi, psi) were located in the string, and
00688 %  whether the xi or pi values are negative.  In addition, there are flags to
00689 %  report any meta characters (%, !, <, or >).
00690 %
00691 %  The format of the ParseGeometry method is:
00692 %
00693 %      MagickStatusType ParseGeometry(const char *geometry,
00694 %        GeometryInfo *geometry_info)
00695 %
00696 %  A description of each parameter follows:
00697 %
00698 %    o geometry:  The geometry.
00699 %
00700 %    o geometry_info:  returns the parsed width/height/x/y in this structure.
00701 %
00702 */
00703 MagickExport MagickStatusType ParseGeometry(const char *geometry,
00704   GeometryInfo *geometry_info)
00705 {
00706   char
00707     *p,
00708     pedantic_geometry[MaxTextExtent],
00709     *q;
00710 
00711   double
00712     value;
00713 
00714   MagickStatusType
00715     flags;
00716 
00717   /*
00718     Remove whitespaces meta characters from geometry specification.
00719   */
00720   assert(geometry_info != (GeometryInfo *) NULL);
00721   flags=NoValue;
00722   if ((geometry == (char *) NULL) || (*geometry == '\0'))
00723     return(flags);
00724   if (strlen(geometry) >= MaxTextExtent)
00725     return(flags);
00726   (void) CopyMagickString(pedantic_geometry,geometry,MaxTextExtent);
00727   for (p=pedantic_geometry; *p != '\0'; )
00728   {
00729     if (isspace((int) ((unsigned char) *p)) != 0)
00730       {
00731         (void) CopyMagickString(p,p+1,MaxTextExtent);
00732         continue;
00733       }
00734     switch (*p)
00735     {
00736       case '%':
00737       {
00738         flags|=PercentValue;
00739         (void) CopyMagickString(p,p+1,MaxTextExtent);
00740         break;
00741       }
00742       case '!':
00743       {
00744         flags|=AspectValue;
00745         (void) CopyMagickString(p,p+1,MaxTextExtent);
00746         break;
00747       }
00748       case '<':
00749       {
00750         flags|=LessValue;
00751         (void) CopyMagickString(p,p+1,MaxTextExtent);
00752         break;
00753       }
00754       case '>':
00755       {
00756         flags|=GreaterValue;
00757         (void) CopyMagickString(p,p+1,MaxTextExtent);
00758         break;
00759       }
00760       case '^':
00761       {
00762         flags|=MinimumValue;
00763         (void) CopyMagickString(p,p+1,MaxTextExtent);
00764         break;
00765       }
00766       case '@':
00767       {
00768         flags|=AreaValue;
00769         (void) CopyMagickString(p,p+1,MaxTextExtent);
00770         break;
00771       }
00772       case '(':
00773       case ')':
00774       {
00775         (void) CopyMagickString(p,p+1,MaxTextExtent);
00776         break;
00777       }
00778       case '-':
00779       case '+':
00780       case ',':
00781       case '0':
00782       case '1':
00783       case '2':
00784       case '3':
00785       case '4':
00786       case '5':
00787       case '6':
00788       case '7':
00789       case '8':
00790       case '9':
00791       case -41:
00792       case 'x':
00793       case 'X':
00794       case '/':
00795       case ':':
00796       {
00797         p++;
00798         break;
00799       }
00800       case '.':
00801       {
00802         p++;
00803         flags|=DecimalValue;
00804         break;
00805       }
00806       default:
00807         return(flags);
00808     }
00809   }
00810   /*
00811     Parse rho, sigma, xi, psi, and optionally chi.
00812   */
00813   p=pedantic_geometry;
00814   if (*p == '\0')
00815     return(flags);
00816   q=p;
00817   value=strtod(p,&q);
00818   if (LocaleNCompare(p,"0x",2) == 0)
00819     value=(double) strtol(p,&q,10);
00820   if (((int) *q == -41) || (*q == 'x') || (*q == 'X') || (*q == ',') ||
00821       (*q == '/') || (*q == ':') || (*q =='\0'))
00822     {
00823       /*
00824         Parse rho.
00825       */
00826       q=p;
00827       if (LocaleNCompare(p,"0x",2) == 0)
00828         value=(double) strtol(p,&p,10);
00829       else
00830         value=strtod(p,&p);
00831       if (p != q)
00832         {
00833           flags|=RhoValue;
00834           geometry_info->rho=value;
00835         }
00836     }
00837   q=p;
00838   if (((int) *p == -41) || (*p == 'x') || (*p == 'X') || (*p == ',') ||
00839       (*p == '/') || (*p == ':'))
00840     {
00841       /*
00842         Parse sigma.
00843       */
00844       p++;
00845       while (isspace((int) ((unsigned char) *p)) != 0)
00846         p++;
00847       if ((((int) *q != -41) && (*q != 'x') && (*q != 'X')) ||
00848           ((*p != '+') && (*p != '-')))
00849         {
00850           q=p;
00851           value=strtod(p,&p);
00852           if (p != q)
00853             {
00854               flags|=SigmaValue;
00855               geometry_info->sigma=value;
00856             }
00857         }
00858     }
00859   while (isspace((int) ((unsigned char) *p)) != 0)
00860     p++;
00861   if ((*p == '+') || (*p == '-') || (*p == ',') || (*p == '/') || (*p == ':'))
00862     {
00863       /*
00864         Parse xi value.
00865       */
00866       if ((*p == ',') || (*p == '/') || (*p == ':'))
00867         p++;
00868       q=p;
00869       value=strtod(p,&p);
00870       if (p != q)
00871         {
00872           flags|=XiValue;
00873           if (*q == '-')
00874             flags|=XiNegative;
00875           geometry_info->xi=value;
00876         }
00877       while (isspace((int) ((unsigned char) *p)) != 0)
00878         p++;
00879       if ((*p == '+') || (*p == '-') || (*p == ',') || (*p == '/') ||
00880           (*p == ':'))
00881         {
00882           /*
00883             Parse psi value.
00884           */
00885           if ((*p == ',') || (*p == '/') || (*p == ':'))
00886             p++;
00887           q=p;
00888           value=strtod(p,&p);
00889           if (p != q)
00890             {
00891               flags|=PsiValue;
00892               if (*q == '-')
00893                 flags|=PsiNegative;
00894               geometry_info->psi=value;
00895             }
00896         }
00897       while (isspace((int) ((unsigned char) *p)) != 0)
00898         p++;
00899       if ((*p == '+') || (*p == '-') || (*p == ',') || (*p == '/') ||
00900           (*p == ':'))
00901         {
00902           /*
00903             Parse chi value.
00904           */
00905           if ((*p == ',') || (*p == '/') || (*p == ':'))
00906             p++;
00907           q=p;
00908           value=strtod(p,&p);
00909           if (p != q)
00910             {
00911               flags|=ChiValue;
00912               if (*q == '-')
00913                 flags|=ChiNegative;
00914               geometry_info->chi=value;
00915             }
00916         }
00917     }
00918   if (strchr(pedantic_geometry,':') != (char *) NULL)
00919     {
00920       /*
00921         Normalize sampling factor (e.g. 4:2:2 => 2x1).
00922       */
00923       geometry_info->rho/=geometry_info->sigma;
00924       geometry_info->sigma=1.0;
00925       if (geometry_info->xi == 0.0)
00926         geometry_info->sigma=2.0;
00927     }
00928   if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0) &&
00929       ((flags & PsiValue) == 0))
00930     {
00931       /*
00932         Support negative height values (e.g. 30x-20).
00933       */
00934       geometry_info->sigma=geometry_info->xi;
00935       geometry_info->xi=0.0;
00936       flags|=SigmaValue;
00937       flags&=(~XiValue);
00938     }
00939   return(flags);
00940 }
00941 
00942 /*
00943 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00944 %                                                                             %
00945 %                                                                             %
00946 %                                                                             %
00947 %   P a r s e G r a v i t y G e o m e t r y                                   %
00948 %                                                                             %
00949 %                                                                             %
00950 %                                                                             %
00951 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00952 %
00953 %  ParseGravityGeometry() returns a region as defined by the geometry string
00954 %  with respect to the image dimensions and its gravity.
00955 %
00956 %  The format of the ParseGravityGeometry method is:
00957 %
00958 %      MagickStatusType ParseGravityGeometry(Image *image,const char *geometry,
00959 %        RectangeInfo *region_info,ExceptionInfo *exception)
00960 %
00961 %  A description of each parameter follows:
00962 %
00963 %    o geometry:  The geometry (e.g. 100x100+10+10).
00964 %
00965 %    o region_info: the region as defined by the geometry string with
00966 %      respect to the image dimensions and its gravity.
00967 %
00968 %    o exception: return any errors or warnings in this structure.
00969 %
00970 */
00971 MagickExport MagickStatusType ParseGravityGeometry(const Image *image,
00972   const char *geometry,RectangleInfo *region_info,ExceptionInfo *exception)
00973 {
00974   MagickStatusType
00975     flags;
00976 
00977   unsigned long
00978     height,
00979     width;
00980 
00981   SetGeometry(image,region_info);
00982   if (image->page.width != 0)
00983     region_info->width=image->page.width;
00984   if (image->page.height != 0)
00985     region_info->height=image->page.height;
00986   flags=ParseAbsoluteGeometry(geometry,region_info);
00987   if (flags == NoValue)
00988     {
00989       (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
00990         "InvalidGeometry","`%s'",geometry);
00991       return(flags);
00992     }
00993   if ((flags & PercentValue) != 0)
00994     {
00995       GeometryInfo
00996         geometry_info;
00997 
00998       MagickStatusType
00999         status;
01000 
01001       PointInfo
01002         scale;
01003 
01004       /*
01005         Geometry is a percentage of the image size.
01006       */
01007       if (image->gravity != UndefinedGravity)
01008         flags|=XValue | YValue;
01009       status=ParseGeometry(geometry,&geometry_info);
01010       scale.x=geometry_info.rho;
01011       if ((status & RhoValue) == 0)
01012         scale.x=100.0;
01013       scale.y=geometry_info.sigma;
01014       if ((status & SigmaValue) == 0)
01015         scale.y=scale.x;
01016       region_info->width=(unsigned long) ((scale.x*image->columns/100.0)+0.5);
01017       region_info->height=(unsigned long) ((scale.y*image->rows/100.0)+0.5);
01018     }
01019   /*
01020     If a region width of 0 is given by the user, use the images virtual canvas
01021     size for the gravity offset adjustments-- restore afterward.
01022   */
01023   width=region_info->width;
01024   height=region_info->height;
01025   if (width == 0)
01026     region_info->width=image->page.width | image->columns;
01027   if (height == 0)
01028     region_info->height=image->page.height | image->rows;
01029   GravityAdjustGeometry(image->columns,image->rows,image->gravity,region_info);
01030   region_info->width=width;
01031   region_info->height=height;
01032   return(flags);
01033 }
01034 
01035 /*
01036 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01037 %                                                                             %
01038 %                                                                             %
01039 %                                                                             %
01040 +   P a r s e M e t a G e o m e t r y                                         %
01041 %                                                                             %
01042 %                                                                             %
01043 %                                                                             %
01044 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01045 %
01046 %  ParseMetaGeometry() is similar to GetGeometry() except the returned
01047 %  geometry is modified as determined by the meta characters:  %, !, <, >,
01048 %  and ~.
01049 %
01050 %  The format of the ParseMetaGeometry method is:
01051 %
01052 %      MagickStatusType ParseMetaGeometry(const char *geometry,long *x,long *y,
01053 %        unsigned long *width,unsigned long *height)
01054 %
01055 %  A description of each parameter follows:
01056 %
01057 %    o geometry:  The geometry.
01058 %
01059 %    o x,y:  The x and y offset as determined by the geometry specification.
01060 %
01061 %    o width,height:  The width and height as determined by the geometry
01062 %      specification.
01063 %
01064 */
01065 
01066 static inline unsigned long MagickMax(const unsigned long x,
01067   const unsigned long y)
01068 {
01069   if (x > y)
01070     return(x);
01071   return(y);
01072 }
01073 
01074 MagickExport MagickStatusType ParseMetaGeometry(const char *geometry,long *x,
01075   long *y,unsigned long *width,unsigned long *height)
01076 {
01077   GeometryInfo
01078     geometry_info;
01079 
01080   MagickStatusType
01081     flags;
01082 
01083   unsigned long
01084     former_height,
01085     former_width;
01086 
01087   /*
01088     Ensure the image geometry is valid.
01089   */
01090   assert(x != (long *) NULL);
01091   assert(y != (long *) NULL);
01092   assert(width != (unsigned long *) NULL);
01093   assert(height != (unsigned long *) NULL);
01094   if ((geometry == (char *) NULL) || (*geometry == '\0'))
01095     return(NoValue);
01096   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",geometry);
01097   /*
01098     Parse geometry using GetGeometry.
01099   */
01100   SetGeometryInfo(&geometry_info);
01101   former_width=(*width);
01102   former_height=(*height);
01103   flags=GetGeometry(geometry,x,y,width,height);
01104   if ((flags & PercentValue) != 0)
01105     {
01106       MagickStatusType
01107         flags;
01108 
01109       PointInfo
01110         scale;
01111 
01112       /*
01113         Geometry is a percentage of the image size.
01114       */
01115       flags=ParseGeometry(geometry,&geometry_info);
01116       scale.x=geometry_info.rho;
01117       if ((flags & RhoValue) == 0)
01118         scale.x=100.0;
01119       scale.y=geometry_info.sigma;
01120       if ((flags & SigmaValue) == 0)
01121         scale.y=scale.x;
01122       *width=(unsigned long) (scale.x*former_width/100.0+0.5);
01123       if (*width == 0)
01124         *width=1;
01125       *height=(unsigned long) (scale.y*former_height/100.0+0.5);
01126       if (*height == 0)
01127         *height=1;
01128       former_width=(*width);
01129       former_height=(*height);
01130     }
01131   if (((flags & AspectValue) == 0) && ((*width != former_width) ||
01132       (*height != former_height)))
01133     {
01134       MagickRealType
01135         scale_factor;
01136 
01137       /*
01138         Respect aspect ratio of the image.
01139       */
01140       if ((former_width == 0) || (former_height == 0))
01141         scale_factor=1.0;
01142       else
01143         if (((flags & RhoValue) != 0) && (flags & SigmaValue) != 0)
01144           {
01145             scale_factor=(MagickRealType) *width/(MagickRealType) former_width;
01146             if ((flags & MinimumValue) == 0)
01147               {
01148                 if (scale_factor > ((MagickRealType) *height/
01149                     (MagickRealType) former_height))
01150                   scale_factor=(MagickRealType) *height/(MagickRealType)
01151                     former_height;
01152               }
01153             else
01154               if (scale_factor < ((MagickRealType) *height/
01155                   (MagickRealType) former_height))
01156                 scale_factor=(MagickRealType) *height/(MagickRealType)
01157                   former_height;
01158           }
01159         else
01160           if ((flags & RhoValue) != 0)
01161             {
01162               scale_factor=(MagickRealType) *width/(MagickRealType)
01163                 former_width;
01164               if (((flags & MinimumValue) != 0) &&
01165                   (scale_factor < ((MagickRealType) *width/
01166                     (MagickRealType) former_height)))
01167                 scale_factor=(MagickRealType) *width/(MagickRealType)
01168                   former_height;
01169             }
01170           else
01171             {
01172               scale_factor=(MagickRealType) *height/(MagickRealType)
01173                 former_height;
01174               if (((flags & MinimumValue) != 0) &&
01175                   (scale_factor < ((MagickRealType) *height/
01176                     (MagickRealType) former_width)))
01177                 scale_factor=(MagickRealType) *height/(MagickRealType)
01178                   former_width;
01179             }
01180       *width=MagickMax((unsigned long) (scale_factor*former_width+0.5),1UL);
01181       *height=MagickMax((unsigned long) (scale_factor*former_height+0.5),1UL);
01182     }
01183   if ((flags & GreaterValue) != 0)
01184     {
01185       if (former_width < *width)
01186         *width=former_width;
01187       if (former_height < *height)
01188         *height=former_height;
01189     }
01190   if ((flags & LessValue) != 0)
01191     {
01192       if (former_width > *width)
01193         *width=former_width;
01194       if (former_height > *height)
01195         *height=former_height;
01196     }
01197   if ((flags & AreaValue) != 0)
01198     {
01199       MagickRealType
01200         area,
01201         distance;
01202 
01203       PointInfo
01204         scale;
01205 
01206       /*
01207         Geometry is a maximum area in pixels.
01208       */
01209       (void) ParseGeometry(geometry,&geometry_info);
01210       area=geometry_info.rho;
01211       distance=sqrt((double) former_width*former_height);
01212       scale.x=(double) former_width/(double) (distance/sqrt((double) area));
01213       scale.y=(double) former_height/(double) (distance/sqrt((double) area));
01214       if ((scale.x < (double) *width) || (scale.y < (double) *height))
01215         {
01216           *width=(unsigned long) (former_width/(distance/sqrt((double) area)));
01217           *height=(unsigned long) (former_height/(distance/
01218             sqrt((double) area)));
01219         }
01220       former_width=(*width);
01221       former_height=(*height);
01222     }
01223   return(flags);
01224 }
01225 
01226 /*
01227 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01228 %                                                                             %
01229 %                                                                             %
01230 %                                                                             %
01231 %   P a r s e P a g e G e o m e t r y                                         %
01232 %                                                                             %
01233 %                                                                             %
01234 %                                                                             %
01235 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01236 %
01237 %  ParsePageGeometry() returns a region as defined by the geometry string with
01238 %  respect to the image dimensions.
01239 %
01240 %  The format of the ParsePageGeometry method is:
01241 %
01242 %      MagickStatusType ParsePageGeometry(const Image *image,
01243 %        const char *geometry,RectangeInfo *region_info,
01244 %        ExceptionInfo *exception)
01245 %
01246 %  A description of each parameter follows:
01247 %
01248 %    o geometry:  The geometry (e.g. 100x100+10+10).
01249 %
01250 %    o region_info: the region as defined by the geometry string with
01251 %      respect to the image and its gravity.
01252 %
01253 %    o exception: return any errors or warnings in this structure.
01254 %
01255 */
01256 MagickExport MagickStatusType ParsePageGeometry(const Image *image,
01257   const char *geometry,RectangleInfo *region_info,ExceptionInfo *exception)
01258 {
01259   MagickStatusType
01260     flags;
01261 
01262   SetGeometry(image,region_info);
01263   if (image->page.width != 0)
01264     region_info->width=image->page.width;
01265   if (image->page.height != 0)
01266     region_info->height=image->page.height;
01267   flags=ParseAbsoluteGeometry(geometry,region_info);
01268   if (flags == NoValue)
01269     {
01270       (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
01271         "InvalidGeometry","`%s'",geometry);
01272       return(flags);
01273     }
01274   if ((flags & PercentValue) != 0)
01275     {
01276       region_info->width=image->columns;
01277       region_info->height=image->rows;
01278     }
01279   flags=ParseMetaGeometry(geometry,&region_info->x,&region_info->y,
01280     &region_info->width,&region_info->height);
01281   return(flags);
01282 }
01283 
01284 /*
01285 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01286 %                                                                             %
01287 %                                                                             %
01288 %                                                                             %
01289 %   P a r s e R e g i o n G e o m e t r y                                     %
01290 %                                                                             %
01291 %                                                                             %
01292 %                                                                             %
01293 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01294 %
01295 %  ParseRegionGeometry() returns a region as defined by the geometry string
01296 %  with respect to the image dimensions and aspect ratio.
01297 %
01298 %  The format of the ParseRegionGeometry method is:
01299 %
01300 %      MagickStatusType ParseRegionGeometry(const Image *image,
01301 %        const char *geometry,RectangeInfo *region_info,
01302 %        ExceptionInfo *exception)
01303 %
01304 %  A description of each parameter follows:
01305 %
01306 %    o geometry:  The geometry (e.g. 100x100+10+10).
01307 %
01308 %    o region_info: the region as defined by the geometry string.
01309 %
01310 %    o exception: return any errors or warnings in this structure.
01311 %
01312 */
01313 MagickExport MagickStatusType ParseRegionGeometry(const Image *image,
01314   const char *geometry,RectangleInfo *region_info,ExceptionInfo *exception)
01315 {
01316   MagickStatusType
01317     flags;
01318 
01319   SetGeometry(image,region_info);
01320   flags=ParseMetaGeometry(geometry,&region_info->x,&region_info->y,
01321     &region_info->width,&region_info->height);
01322   if (flags == NoValue)
01323     (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
01324       "InvalidGeometry","`%s'",geometry);
01325   return(flags);
01326 }
01327 
01328 /*
01329 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01330 %                                                                             %
01331 %                                                                             %
01332 %                                                                             %
01333 %   S e t G e o m e t r y                                                     %
01334 %                                                                             %
01335 %                                                                             %
01336 %                                                                             %
01337 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01338 %
01339 %  SetGeometry() sets the geometry to its default values.
01340 %
01341 %  The format of the SetGeometry method is:
01342 %
01343 %      SetGeometry(const Image *image,RectangleInfo *geometry)
01344 %
01345 %  A description of each parameter follows:
01346 %
01347 %    o image: the image.
01348 %
01349 %    o geometry: the geometry.
01350 %
01351 */
01352 MagickExport void SetGeometry(const Image *image,RectangleInfo *geometry)
01353 {
01354   assert(image != (Image *) NULL);
01355   assert(image->signature == MagickSignature);
01356   if (image->debug != MagickFalse)
01357     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
01358   assert(geometry != (RectangleInfo *) NULL);
01359   (void) ResetMagickMemory(geometry,0,sizeof(*geometry));
01360   geometry->width=image->columns;
01361   geometry->height=image->rows;
01362 }
01363 
01364 /*
01365 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01366 %                                                                             %
01367 %                                                                             %
01368 %                                                                             %
01369 %   S e t G e o m e t r y I n f o                                             %
01370 %                                                                             %
01371 %                                                                             %
01372 %                                                                             %
01373 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01374 %
01375 %  SetGeometryInfo sets the GeometryInfo structure to its default values.
01376 %
01377 %  The format of the SetGeometryInfo method is:
01378 %
01379 %      SetGeometryInfo(GeometryInfo *geometry_info)
01380 %
01381 %  A description of each parameter follows:
01382 %
01383 %    o geometry_info: the geometry info structure.
01384 %
01385 */
01386 MagickExport void SetGeometryInfo(GeometryInfo *geometry_info)
01387 {
01388   assert(geometry_info != (GeometryInfo *) NULL);
01389   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
01390   (void) ResetMagickMemory(geometry_info,0,sizeof(*geometry_info));
01391 }

Generated on Thu Jul 2 12:03:19 2009 for MagickCore by  doxygen 1.5.8