]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/geometry.c
(no commit message)
[imagemagick] / MagickCore / geometry.c
index 2484311d2b57d36a5984f5c63e12ac62dce0dd2a..9ae2849a4f43a6217d25e45d0f58594db146870a 100644 (file)
 %                       MagickCore Geometry Methods                           %
 %                                                                             %
 %                             Software Design                                 %
-%                               John Cristy                                   %
+%                                  Cristy                                     %
 %                              January 2003                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
@@ -192,6 +192,8 @@ MagickExport MagickStatusType GetGeometry(const char *geometry,ssize_t *x,
       case '8':
       case '9':
       case 215:
+      case 'e':
+      case 'E':
       {
         p++;
         break;
@@ -286,18 +288,15 @@ MagickExport MagickStatusType GetGeometry(const char *geometry,ssize_t *x,
             *y=(-*y);
         }
     }
-  if ((flags & SeparatorValue) == 0)
+  if ((flags & PercentValue) != 0)
     {
-      if (((flags & PercentValue) != 0) && ((flags & WidthValue) == 0))
-        {
-          *width=(*height);
-          flags|=WidthValue;
-        }
-      if (((flags & PercentValue) != 0) && ((flags & HeightValue) == 0))
+      if (((flags & SeparatorValue) == 0) && ((flags & HeightValue) == 0))
         {
           *height=(*width);
           flags|=HeightValue;
         }
+      if (((flags & SeparatorValue) != 0) && ((flags & WidthValue) == 0))
+        *width=(*height);
     }
 #if 0
   /* Debugging Geometry */
@@ -358,7 +357,7 @@ MagickExport char *GetPageGeometry(const char *page_geometry)
       { "a2",  "1191x1684" },
       { "a3",  "842x1191" },
       { "a4",  "595x842" },
-      { "a4smaLL", "595x842" },
+      { "a4small", "595x842" },
       { "a5",  "420x595" },
       { "a6",  "297x420" },
       { "a7",  "210x297" },
@@ -414,7 +413,7 @@ MagickExport char *GetPageGeometry(const char *page_geometry)
       { "ledger",  "1224x792" },
       { "legal",  "612x1008" },
       { "letter", "612x792" },
-      { "lettersmaLL",  "612x792" },
+      { "lettersmall",  "612x792" },
       { "quarto",  "610x780" },
       { "statement",  "396x612" },
       { "tabloid",  "792x1224" },
@@ -787,7 +786,7 @@ MagickExport MagickStatusType ParseAffineGeometry(const char *geometry,
 %  and ^) flags present. It does not report the location of the percentage
 %  relative to the values.
 %
-%  Values may also be seperated by commas, colons, or slashes, and offsets.
+%  Values may also be separated by commas, colons, or slashes, and offsets.
 %  Offsets may be prefixed by multiple signs to make offset string
 %  substitutions easier to handle from shell scripts.
 %  For example: "-10-10", "-+10-+10", or "+-10+-10" will generate negtive
@@ -908,6 +907,8 @@ MagickExport MagickStatusType ParseGeometry(const char *geometry,
       case '/':
       case ':':
       case 215:
+      case 'e':
+      case 'E':
       {
         p++;
         break;
@@ -1072,18 +1073,12 @@ MagickExport MagickStatusType ParseGeometry(const char *geometry,
       flags|=SigmaValue;
       flags&=(~XiValue);
     }
-  if ((flags & SeparatorValue) == 0)
+  if ((flags & PercentValue) != 0)
     {
-      if (((flags & PercentValue) != 0) && ((flags & RhoValue) == 0))
-        {
-          geometry_info->rho=geometry_info->sigma;
-          flags|=RhoValue;
-        }
-      if (((flags & PercentValue) != 0) && ((flags & SigmaValue) == 0))
-        {
-          geometry_info->sigma=geometry_info->rho;
-          flags|=SigmaValue;
-        }
+      if (((flags & SeparatorValue) == 0) && ((flags & SigmaValue) == 0))
+        geometry_info->sigma=geometry_info->rho;
+      if (((flags & SeparatorValue) != 0) && ((flags & RhoValue) == 0))
+        geometry_info->rho=geometry_info->sigma;
     }
 #if 0
   /* Debugging Geometry */
@@ -1156,7 +1151,7 @@ MagickExport MagickStatusType ParseGravityGeometry(const Image *image,
   if (flags == NoValue)
     {
       (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
-        "InvalidGeometry","'%s'",geometry);
+        "InvalidGeometry","`%s'",geometry);
       return(flags);
     }
   if ((flags & PercentValue) != 0)
@@ -1300,11 +1295,7 @@ MagickExport MagickStatusType ParseMetaGeometry(const char *geometry,ssize_t *x,
       if ((flags & SigmaValue) == 0)
         scale.y=scale.x;
       *width=(size_t) floor(scale.x*former_width/100.0+0.5);
-      if (*width == 0)
-        *width=1;
       *height=(size_t) floor(scale.y*former_height/100.0+0.5);
-      if (*height == 0)
-        *height=1;
       former_width=(*width);
       former_height=(*height);
     }
@@ -1386,12 +1377,12 @@ MagickExport MagickStatusType ParseMetaGeometry(const char *geometry,ssize_t *x,
       (void) ParseGeometry(geometry,&geometry_info);
       area=geometry_info.rho;
       distance=sqrt((double) former_width*former_height);
-      scale.x=(double) former_width/(distance/sqrt((double) area));
-      scale.y=(double) former_height/(distance/sqrt((double) area));
+      scale.x=former_width/(distance/sqrt(area));
+      scale.y=former_height/(distance/sqrt(area));
       if ((scale.x < (double) *width) || (scale.y < (double) *height))
         {
-          *width=(size_t) (former_width/(distance/sqrt(area))+0.5);
-          *height=(size_t) (former_height/(distance/sqrt(area))+0.5);
+          *width=(unsigned long) (former_width/(distance/sqrt(area)));
+          *height=(unsigned long) (former_height/(distance/sqrt(area)));
         }
       former_width=(*width);
       former_height=(*height);
@@ -1447,7 +1438,7 @@ MagickExport MagickStatusType ParsePageGeometry(const Image *image,
   if (flags == NoValue)
     {
       (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
-        "InvalidGeometry","'%s'",geometry);
+        "InvalidGeometry","`%s'",geometry);
       return(flags);
     }
   if ((flags & PercentValue) != 0)
@@ -1457,6 +1448,14 @@ MagickExport MagickStatusType ParsePageGeometry(const Image *image,
     }
   flags=ParseMetaGeometry(geometry,&region_info->x,&region_info->y,
     &region_info->width,&region_info->height);
+  if ((((flags & WidthValue) != 0) || ((flags & HeightValue) != 0)) &&
+      (((flags & PercentValue) != 0) || ((flags & SeparatorValue) == 0)))
+    {
+      if ((flags & WidthValue) == 0)
+        region_info->width=region_info->height;
+      if ((flags & HeightValue) == 0)
+        region_info->height=region_info->width;
+    }
   return(flags);
 }
 \f
@@ -1504,7 +1503,7 @@ MagickExport MagickStatusType ParseRegionGeometry(const Image *image,
     &region_info->width,&region_info->height);
   if (flags == NoValue)
     (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
-      "InvalidGeometry","'%s'",geometry);
+      "InvalidGeometry","`%s'",geometry);
   return(flags);
 }
 \f