Parse width.
*/
q=p;
- if (LocaleNCompare(p,"0x",2) == 0)
- *width=(size_t) strtol(p,&p,10);
- else
- *width=(size_t) floor(StringToDouble(p,&p)+0.5);
+ if (width != (size_t *) NULL)
+ {
+ if (LocaleNCompare(p,"0x",2) == 0)
+ *width=(size_t) strtol(p,&p,10);
+ else
+ *width=(size_t) floor(StringToDouble(p,&p)+0.5);
+ }
if (p != q)
flags|=WidthValue;
}
Parse height.
*/
q=p;
- *height=(size_t) floor(StringToDouble(p,&p)+0.5);
+ if (height != (size_t *) NULL)
+ *height=(size_t) floor(StringToDouble(p,&p)+0.5);
if (p != q)
flags|=HeightValue;
}
p++;
}
q=p;
- *x=(ssize_t) ceil(StringToDouble(p,&p)-0.5);
+ if (x != (ssize_t *) NULL)
+ *x=(ssize_t) ceil(StringToDouble(p,&p)-0.5);
if (p != q)
{
flags|=XValue;
- if ((flags & XNegative) != 0)
+ if (((flags & XNegative) != 0) && (x != (ssize_t *) NULL))
*x=(-*x);
}
}
p++;
}
q=p;
- *y=(ssize_t) ceil(StringToDouble(p,&p)-0.5);
+ if (y != (ssize_t *) NULL)
+ *y=(ssize_t) ceil(StringToDouble(p,&p)-0.5);
if (p != q)
{
flags|=YValue;
- if ((flags & YNegative) != 0)
+ if (((flags & YNegative) != 0) && (y != (ssize_t *) NULL))
*y=(-*y);
}
}
{
if (((flags & SeparatorValue) == 0) && ((flags & HeightValue) == 0))
{
- *height=(*width);
+ if ((height != (size_t *) NULL) && (width != (size_t *) NULL))
+ *height=(*width);
flags|=HeightValue;
}
- if (((flags & SeparatorValue) != 0) && ((flags & WidthValue) == 0))
- *width=(*height);
+ if (((flags & SeparatorValue) != 0) && ((flags & WidthValue) == 0) &&
+ (height != (size_t *) NULL) && (width != (size_t *) NULL))
+ *width=(*height);
}
#if 0
/* Debugging Geometry */
static inline void EMFSetDimensions(Image * image,Gdiplus::Image *source)
{
+ if ((image->resolution.x <= 0.0) || (image->resolution.y <= 0.0))
+ return;
+
image->columns=(size_t) floor((Gdiplus::REAL) source->GetWidth()/
source->GetHorizontalResolution()*image->resolution.x+0.5);
image->rows=(size_t)floor((Gdiplus::REAL) source->GetHeight()/
image->resolution.x=source->GetHorizontalResolution();
image->resolution.y=source->GetVerticalResolution();
+ image->columns=(size_t) source->GetWidth();
+ image->rows=(size_t) source->GetHeight();
if (image_info->size != (char *) NULL)
{
- ssize_t
- v;
-
- (void) GetGeometry(image_info->size,&v,&v,&image->columns,&image->rows);
-
+ (void) GetGeometry(image_info->size,(ssize_t *) NULL,(ssize_t *) NULL,
+ &image->columns,&image->rows);
image->resolution.x=source->GetHorizontalResolution()*image->columns/
source->GetWidth();
image->resolution.y=source->GetVerticalResolution()*image->rows/
else
image->resolution.x=image->resolution.y=MagickMin(
image->resolution.x,image->resolution.y);
-
EMFSetDimensions(image,source);
}
- else
+ else if (image_info->density != (char *) NULL)
{
- image->columns=(size_t) source->GetWidth();
- image->rows=(size_t) source->GetHeight();
- if (image_info->density != (char *) NULL)
- {
- flags=ParseGeometry(image_info->density,&geometry_info);
- image->resolution.x=geometry_info.rho;
- image->resolution.y=geometry_info.sigma;
- if ((flags & SigmaValue) == 0)
- image->resolution.y=image->resolution.x;
- if ((image->resolution.x > 0.0) && (image->resolution.y > 0.0))
- EMFSetDimensions(image, source);
- }
+ flags=ParseGeometry(image_info->density,&geometry_info);
+ image->resolution.x=geometry_info.rho;
+ image->resolution.y=geometry_info.sigma;
+ if ((flags & SigmaValue) == 0)
+ image->resolution.y=image->resolution.x;
+ EMFSetDimensions(image,source);
}
if (SetImageExtent(image,image->columns,image->rows,exception) == MagickFalse)
{
rsvg_handle_get_dimensions(svg_handle,&dimension_info);
if (image_info->size != (char *) NULL)
{
- ssize_t
- v;
-
- (void) GetGeometry(image_info->size,&v,&v,&image->columns,
- &image->rows);
-
- image->resolution.x=90.0*image->columns/dimension_info.width;
- image->resolution.y=90.0*image->rows/dimension_info.height;
- if (image->resolution.x == 0)
- image->resolution.x=image->resolution.y;
- else if (image->resolution.y == 0)
- image->resolution.y=image->resolution.x;
- else
- image->resolution.x=image->resolution.y=MagickMin(
- image->resolution.x,image->resolution.y);
+ (void) GetGeometry(image_info->size,(ssize_t *) NULL,
+ (ssize_t *) NULL,&image->columns,&image->rows);
+ if ((image->columns != 0) || (image->rows != 0))
+ {
+ image->resolution.x=90.0*image->columns/dimension_info.width;
+ image->resolution.y=90.0*image->rows/dimension_info.height;
+ if (image->resolution.x == 0)
+ image->resolution.x=image->resolution.y;
+ else if (image->resolution.y == 0)
+ image->resolution.y=image->resolution.x;
+ else
+ image->resolution.x=image->resolution.y=MagickMin(
+ image->resolution.x,image->resolution.y);
+ }
}
image->columns=image->resolution.x*dimension_info.width/90.0;
image->rows=image->resolution.y*dimension_info.height/90.0;