.Renamed CastDoubleToUnsigned to CastDoubleToSizeT

This commit is contained in:
Dirk Lemstra
2025-04-01 22:34:12 +02:00
parent 14a434f278
commit fd418ddc44
17 changed files with 68 additions and 79 deletions
+3 -3
View File
@@ -342,10 +342,10 @@ MagickExport MagickBooleanType AnnotateImage(Image *image,
(void) CloneString(&annotate->text,textlist[i]);
if ((metrics.width == 0) || (annotate->gravity != NorthWestGravity))
(void) GetTypeMetrics(image,annotate,&metrics,exception);
height=CastDoubleToUnsigned(metrics.ascent-metrics.descent+0.5);
height=CastDoubleToSizeT(metrics.ascent-metrics.descent+0.5);
if (height == 0)
height=draw_info->pointsize;
height=CastDoubleToUnsigned(floor((double) height+
height=CastDoubleToSizeT(floor((double) height+
draw_info->interline_spacing+0.5));
switch (annotate->gravity)
{
@@ -680,7 +680,7 @@ MagickExport ssize_t FormatMagickCaption(Image *image,DrawInfo *draw_info,
status=GetTypeMetrics(image,draw_info,metrics,exception);
if (status == MagickFalse)
break;
width=CastDoubleToUnsigned(metrics->width+draw_info->stroke_width+0.5);
width=CastDoubleToSizeT(metrics->width+draw_info->stroke_width+0.5);
if (width <= image->columns)
continue;
if (s != (char *) NULL)
+7 -7
View File
@@ -3543,14 +3543,14 @@ static MagickBooleanType RenderMVGContent(Image *image,
(void) GetNextToken(q,&q,extent,token);
if (*token == ',')
(void) GetNextToken(q,&q,extent,token);
region.width=CastDoubleToUnsigned(floor(GetDrawValue(
token,&next_token)+0.5));
region.width=CastDoubleToSizeT(floor(GetDrawValue(token,
&next_token)+0.5));
if (token == next_token)
ThrowPointExpectedException(token,exception);
(void) GetNextToken(q,&q,extent,token);
if (*token == ',')
(void) GetNextToken(q,&q,extent,token);
region.height=CastDoubleToUnsigned(GetDrawValue(token,
region.height=CastDoubleToSizeT(GetDrawValue(token,
&next_token)+0.5);
if (token == next_token)
ThrowPointExpectedException(token,exception);
@@ -3980,15 +3980,15 @@ static MagickBooleanType RenderMVGContent(Image *image,
(void) GetNextToken(q,&q,extent,token);
if (*token == ',')
(void) GetNextToken(q,&q,extent,token);
graphic_context[n]->viewbox.width=CastDoubleToUnsigned(
floor(GetDrawValue(token,&next_token)+0.5));
graphic_context[n]->viewbox.width=CastDoubleToSizeT(floor(
GetDrawValue(token,&next_token)+0.5));
if (token == next_token)
ThrowPointExpectedException(token,exception);
(void) GetNextToken(q,&q,extent,token);
if (*token == ',')
(void) GetNextToken(q,&q,extent,token);
graphic_context[n]->viewbox.height=(size_t) CastDoubleToUnsigned(
floor(GetDrawValue(token,&next_token)+0.5));
graphic_context[n]->viewbox.height=CastDoubleToSizeT(floor(
GetDrawValue(token,&next_token)+0.5));
if (token == next_token)
ThrowPointExpectedException(token,exception);
break;
+16 -18
View File
@@ -352,7 +352,7 @@ MagickExport MagickStatusType GetGeometry(const char *geometry,ssize_t *x,
if (LocaleNCompare(p,"0x",2) == 0)
*width=(size_t) strtol(p,&p,10);
else
*width=CastDoubleToUnsigned(StringToDouble(p,&p)+0.5);
*width=CastDoubleToSizeT(StringToDouble(p,&p)+0.5);
}
if (p != q)
flags|=WidthValue;
@@ -371,7 +371,7 @@ MagickExport MagickStatusType GetGeometry(const char *geometry,ssize_t *x,
*/
q=p;
if (height != (size_t *) NULL)
*height=CastDoubleToUnsigned(StringToDouble(p,&p)+0.5);
*height=CastDoubleToSizeT(StringToDouble(p,&p)+0.5);
if (p != q)
flags|=HeightValue;
}
@@ -1359,8 +1359,8 @@ MagickExport MagickStatusType ParseGravityGeometry(const Image *image,
scale.y=geometry_info.sigma;
if ((status & SigmaValue) == 0)
scale.y=scale.x;
region_info->width=CastDoubleToUnsigned(scale.x*image->columns/100.0+0.5);
region_info->height=CastDoubleToUnsigned(scale.y*image->rows/100.0+0.5);
region_info->width=CastDoubleToSizeT(scale.x*image->columns/100.0+0.5);
region_info->height=CastDoubleToSizeT(scale.y*image->rows/100.0+0.5);
}
if ((flags & AspectRatioValue) != 0)
{
@@ -1384,18 +1384,18 @@ MagickExport MagickStatusType ParseGravityGeometry(const Image *image,
if ((flags & MaximumValue) != 0)
{
if (geometry_ratio < image_ratio)
region_info->height=CastDoubleToUnsigned((double) image->rows*
region_info->height=CastDoubleToSizeT((double) image->rows*
image_ratio/geometry_ratio+0.5);
else
region_info->width=CastDoubleToUnsigned((double) image->columns*
region_info->width=CastDoubleToSizeT((double) image->columns*
geometry_ratio/image_ratio+0.5);
}
else
if (geometry_ratio >= image_ratio)
region_info->height=CastDoubleToUnsigned((double) image->rows*
region_info->height=CastDoubleToSizeT((double) image->rows*
image_ratio/geometry_ratio+0.5);
else
region_info->width=CastDoubleToUnsigned((double) image->columns*
region_info->width=CastDoubleToSizeT((double) image->columns*
geometry_ratio/image_ratio+0.5);
}
/*
@@ -1519,8 +1519,8 @@ MagickExport MagickStatusType ParseMetaGeometry(const char *geometry,ssize_t *x,
scale.y=geometry_info.sigma;
if ((percent_flags & SigmaValue) == 0)
scale.y=scale.x;
*width=CastDoubleToUnsigned(scale.x*stasis_width/100.0+0.5);
*height=CastDoubleToUnsigned(scale.y*stasis_height/100.0+0.5);
*width=CastDoubleToSizeT(scale.x*stasis_width/100.0+0.5);
*height=CastDoubleToSizeT(scale.y*stasis_height/100.0+0.5);
stasis_width=(*width);
stasis_height=(*height);
}
@@ -1540,12 +1540,12 @@ MagickExport MagickStatusType ParseMetaGeometry(const char *geometry,ssize_t *x,
if (geometry_ratio >= image_ratio)
{
*width=stasis_width;
*height=CastDoubleToUnsigned((double) (PerceptibleReciprocal(
*height=CastDoubleToSizeT((double) (PerceptibleReciprocal(
geometry_ratio)*stasis_height*image_ratio)+0.5);
}
else
{
*width=CastDoubleToUnsigned(PerceptibleReciprocal(image_ratio)*
*width=CastDoubleToSizeT(PerceptibleReciprocal(image_ratio)*
stasis_width*geometry_ratio+0.5);
*height=stasis_height;
}
@@ -1598,10 +1598,8 @@ MagickExport MagickStatusType ParseMetaGeometry(const char *geometry,ssize_t *x,
(scale_factor < ((double) *height/(double) stasis_width)))
scale_factor=(double) *height/(double) stasis_width;
}
*width=CastDoubleToUnsigned(MagickMax(floor(scale_factor*stasis_width+
0.5),1.0));
*height=CastDoubleToUnsigned(MagickMax(floor(scale_factor*stasis_height+
0.5),1.0));
*width=CastDoubleToSizeT(MagickMax(floor(scale_factor*stasis_width+0.5),1.0));
*height=CastDoubleToSizeT(MagickMax(floor(scale_factor*stasis_height+0.5),1.0));
}
if ((flags & GreaterValue) != 0)
{
@@ -1638,9 +1636,9 @@ MagickExport MagickStatusType ParseMetaGeometry(const char *geometry,ssize_t *x,
PerceptibleReciprocal(sqrt(area)));
if ((scale.x < (double) *width) || (scale.y < (double) *height))
{
*width=CastDoubleToUnsigned((double) stasis_width*PerceptibleReciprocal(
*width=CastDoubleToSizeT((double) stasis_width*PerceptibleReciprocal(
distance*PerceptibleReciprocal(sqrt(area)))+0.5);
*height=CastDoubleToUnsigned((double) stasis_height*PerceptibleReciprocal(
*height=CastDoubleToSizeT((double) stasis_height*PerceptibleReciprocal(
distance*PerceptibleReciprocal(sqrt(area)))+0.5);
}
}
+1 -1
View File
@@ -115,7 +115,7 @@ static inline QuantumAny CastDoubleToQuantumAny(const double x)
return((QuantumAny) (x+0.5));
}
static inline size_t CastDoubleToUnsigned(const double x)
static inline size_t CastDoubleToSizeT(const double x)
{
double
value;
+3 -4
View File
@@ -1762,10 +1762,9 @@ MagickExport Image *ShearRotateImage(const Image *image,const double degrees,
*/
width=integral_image->columns;
height=integral_image->rows;
bounds.width=CastDoubleToUnsigned(fabs((double) height*shear.x)+width+0.5);
bounds.height=CastDoubleToUnsigned(fabs((double) bounds.width*shear.y)+
height+0.5);
shear_width=CastDoubleToUnsigned(fabs((double) bounds.height*shear.x)+
bounds.width=CastDoubleToSizeT(fabs((double) height*shear.x)+width+0.5);
bounds.height=CastDoubleToSizeT(fabs((double) bounds.width*shear.y)+height+0.5);
shear_width=CastDoubleToSizeT(fabs((double) bounds.height*shear.x)+
bounds.width+0.5);
bounds.x=CastDoubleToLong(floor((double) ((shear_width > bounds.width) ?
width : bounds.width-shear_width+2)/2.0+0.5));
+4 -8
View File
@@ -615,28 +615,24 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry,
}
if ((page.x < 0) && (bounding_box.x >= 0))
{
page.width=CastDoubleToUnsigned((double) page.width+page.x-
bounding_box.x);
page.width=CastDoubleToSizeT((double) page.width+page.x-bounding_box.x);
page.x=0;
}
else
{
page.width=CastDoubleToUnsigned((double) page.width-(bounding_box.x-
page.x));
page.width=CastDoubleToSizeT((double) page.width-(bounding_box.x-page.x));
page.x-=bounding_box.x;
if (page.x < 0)
page.x=0;
}
if ((page.y < 0) && (bounding_box.y >= 0))
{
page.height=CastDoubleToUnsigned((double) page.height+page.y-
bounding_box.y);
page.height=CastDoubleToSizeT((double) page.height+page.y-bounding_box.y);
page.y=0;
}
else
{
page.height=CastDoubleToUnsigned((double) page.height-(bounding_box.y-
page.y));
page.height=CastDoubleToSizeT((double) page.height-(bounding_box.y-page.y));
page.y-=bounding_box.y;
if (page.y < 0)
page.y=0;
+2 -2
View File
@@ -2067,8 +2067,8 @@ MagickExport Image *ShadowImage(const Image *image,const double alpha,
(void) SetImageColorspace(clone_image,sRGBColorspace,exception);
(void) SetImageVirtualPixelMethod(clone_image,EdgeVirtualPixelMethod,
exception);
border_info.width=CastDoubleToUnsigned(2.0*sigma+0.5);
border_info.height=CastDoubleToUnsigned(2.0*sigma+0.5);
border_info.width=CastDoubleToSizeT(2.0*sigma+0.5);
border_info.height=CastDoubleToSizeT(2.0*sigma+0.5);
border_info.x=0;
border_info.y=0;
(void) QueryColorCompliance("none",AllCompliance,&clone_image->border_color,
+5 -7
View File
@@ -169,7 +169,7 @@ static Image *ReadCAPTIONImage(const ImageInfo *image_info,
return(DestroyImageList(image));
(void) SetImageProperty(image,"caption",caption,exception);
draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
width=CastDoubleToUnsigned(0.5*draw_info->pointsize*strlen(caption)+0.5);
width=CastDoubleToSizeT(0.5*draw_info->pointsize*strlen(caption)+0.5);
if (AcquireMagickResource(WidthResource,width) == MagickFalse)
{
caption=DestroyString(caption);
@@ -277,10 +277,8 @@ static Image *ReadCAPTIONImage(const ImageInfo *image_info,
if (status == MagickFalse)
break;
AdjustTypeMetricBounds(&metrics);
width=CastDoubleToUnsigned(metrics.width+draw_info->stroke_width+
0.5);
height=CastDoubleToUnsigned(
metrics.height-metrics.underline_position+
width=CastDoubleToSizeT(metrics.width+draw_info->stroke_width+0.5);
height=CastDoubleToSizeT(metrics.height-metrics.underline_position+
draw_info->interline_spacing+draw_info->stroke_width+0.5);
if ((image->columns != 0) && (image->rows != 0))
{
@@ -312,8 +310,8 @@ static Image *ReadCAPTIONImage(const ImageInfo *image_info,
if (status == MagickFalse)
break;
AdjustTypeMetricBounds(&metrics);
width=CastDoubleToUnsigned(metrics.width+draw_info->stroke_width+0.5);
height=CastDoubleToUnsigned(metrics.height-metrics.underline_position+
width=CastDoubleToSizeT(metrics.width+draw_info->stroke_width+0.5);
height=CastDoubleToSizeT(metrics.height-metrics.underline_position+
draw_info->interline_spacing+draw_info->stroke_width+0.5);
if ((image->columns != 0) && (image->rows != 0))
{
+5 -7
View File
@@ -151,7 +151,7 @@ static Image *ReadLABELImage(const ImageInfo *image_info,
return(DestroyImageList(image));
(void) SetImageProperty(image,"label",label,exception);
draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
width=CastDoubleToUnsigned(0.5*draw_info->pointsize*strlen(label)+0.5);
width=CastDoubleToSizeT(0.5*draw_info->pointsize*strlen(label)+0.5);
if (AcquireMagickResource(WidthResource,width) == MagickFalse)
{
label=DestroyString(label);
@@ -214,10 +214,8 @@ static Image *ReadLABELImage(const ImageInfo *image_info,
if (status == MagickFalse)
break;
AdjustTypeMetricBounds(&metrics);
width=CastDoubleToUnsigned(metrics.width+draw_info->stroke_width+
0.5);
height=CastDoubleToUnsigned(
metrics.height-metrics.underline_position+
width=CastDoubleToSizeT(metrics.width+draw_info->stroke_width+0.5);
height=CastDoubleToSizeT(metrics.height-metrics.underline_position+
draw_info->stroke_width+0.5);
if ((image->columns != 0) && (image->rows != 0))
{
@@ -251,8 +249,8 @@ static Image *ReadLABELImage(const ImageInfo *image_info,
if (status == MagickFalse)
break;
AdjustTypeMetricBounds(&metrics);
width=CastDoubleToUnsigned(metrics.width+draw_info->stroke_width+0.5);
height=CastDoubleToUnsigned(metrics.height-metrics.underline_position+
width=CastDoubleToSizeT(metrics.width+draw_info->stroke_width+0.5);
height=CastDoubleToSizeT(metrics.height-metrics.underline_position+
draw_info->stroke_width+0.5);
if ((image->columns != 0) && (image->rows != 0))
{
+4 -4
View File
@@ -177,8 +177,8 @@ static Image *ReadMVGImage(const ImageInfo *image_info,ExceptionInfo *exception)
&bounds.x2,&bounds.y2);
if (count != 4)
continue;
image->columns=CastDoubleToUnsigned(floor((bounds.x2-bounds.x1)+0.5));
image->rows=CastDoubleToUnsigned(floor((bounds.y2-bounds.y1)+0.5));
image->columns=CastDoubleToSizeT(floor((bounds.x2-bounds.x1)+0.5));
image->rows=CastDoubleToSizeT(floor((bounds.y2-bounds.y1)+0.5));
break;
}
}
@@ -191,8 +191,8 @@ static Image *ReadMVGImage(const ImageInfo *image_info,ExceptionInfo *exception)
96.0;
draw_info->affine.sy=image->resolution.y == 0.0 ? 1.0 : image->resolution.y/
96.0;
image->columns=CastDoubleToUnsigned(draw_info->affine.sx*image->columns);
image->rows=CastDoubleToUnsigned(draw_info->affine.sy*image->rows);
image->columns=CastDoubleToSizeT(draw_info->affine.sx*image->columns);
image->rows=CastDoubleToSizeT(draw_info->affine.sy*image->rows);
status=SetImageExtent(image,image->columns,image->rows,exception);
if (status == MagickFalse)
{
+2 -2
View File
@@ -337,8 +337,8 @@ static Image *ReadPCLImage(const ImageInfo *image_info,ExceptionInfo *exception)
image->resolution.x,image->resolution.y);
if (image_info->ping != MagickFalse)
(void) FormatLocaleString(density,MagickPathExtent,"2.0x2.0");
page.width=CastDoubleToUnsigned(page.width*image->resolution.x/delta.x+0.5);
page.height=CastDoubleToUnsigned(page.height*image->resolution.y/delta.y+0.5);
page.width=CastDoubleToSizeT(page.width*image->resolution.x/delta.x+0.5);
page.height=CastDoubleToSizeT(page.height*image->resolution.y/delta.y+0.5);
(void) FormatLocaleString(options,MagickPathExtent,"-g%.20gx%.20g ",(double)
page.width,(double) page.height);
image=DestroyImage(image);
+2 -2
View File
@@ -1867,9 +1867,9 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image,
(void) ParseMetaGeometry(temp,&geometry.x,&geometry.y,
&geometry.width,&geometry.height);
scale.x=(double) (geometry.width*delta.x)/resolution.x;
geometry.width=CastDoubleToUnsigned(scale.x+0.5);
geometry.width=CastDoubleToSizeT(scale.x+0.5);
scale.y=(double) (geometry.height*delta.y)/resolution.y;
geometry.height=CastDoubleToUnsigned(scale.y+0.5);
geometry.height=CastDoubleToSizeT(scale.y+0.5);
(void) ParseAbsoluteGeometry(temp,&media_info);
(void) ParseGravityGeometry(image,temp,&page_info,exception);
if (image->gravity != UndefinedGravity)
+6 -6
View File
@@ -9530,27 +9530,27 @@ static MagickBooleanType WriteOnePNGImage(MngWriteInfo *mng_info,
if (image->units == PixelsPerInchResolution)
{
ping_pHYs_unit_type=PNG_RESOLUTION_METER;
ping_pHYs_x_resolution=(png_uint_32) CastDoubleToUnsigned((100.0*
ping_pHYs_x_resolution=(png_uint_32) CastDoubleToSizeT((100.0*
image->resolution.x)/2.54);
ping_pHYs_y_resolution=(png_uint_32) CastDoubleToUnsigned((100.0*
ping_pHYs_y_resolution=(png_uint_32) CastDoubleToSizeT((100.0*
image->resolution.y+0.5)/2.54);
}
else if (image->units == PixelsPerCentimeterResolution)
{
ping_pHYs_unit_type=PNG_RESOLUTION_METER;
ping_pHYs_x_resolution=(png_uint_32) CastDoubleToUnsigned(100.0*
ping_pHYs_x_resolution=(png_uint_32) CastDoubleToSizeT(100.0*
image->resolution.x);
ping_pHYs_y_resolution=(png_uint_32) CastDoubleToUnsigned(100.0*
ping_pHYs_y_resolution=(png_uint_32) CastDoubleToSizeT(100.0*
image->resolution.y);
}
else
{
ping_pHYs_unit_type=PNG_RESOLUTION_UNKNOWN;
ping_pHYs_x_resolution=(png_uint_32) CastDoubleToUnsigned(
ping_pHYs_x_resolution=(png_uint_32) CastDoubleToSizeT(
image->resolution.x);
ping_pHYs_y_resolution=(png_uint_32) CastDoubleToUnsigned(
ping_pHYs_y_resolution=(png_uint_32) CastDoubleToSizeT(
image->resolution.y);
}
+2 -2
View File
@@ -1534,9 +1534,9 @@ static MagickBooleanType WritePSImage(const ImageInfo *image_info,Image *image,
(void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
&geometry.width,&geometry.height);
scale.x=PerceptibleReciprocal(resolution.x)*geometry.width*delta.x;
geometry.width=CastDoubleToUnsigned(scale.x+0.5);
geometry.width=CastDoubleToSizeT(scale.x+0.5);
scale.y=PerceptibleReciprocal(resolution.y)*geometry.height*delta.y;
geometry.height=CastDoubleToUnsigned(scale.y+0.5);
geometry.height=CastDoubleToSizeT(scale.y+0.5);
(void) ParseAbsoluteGeometry(page_geometry,&media_info);
(void) ParseGravityGeometry(image,page_geometry,&page_info,exception);
if (image->gravity != UndefinedGravity)
+2 -2
View File
@@ -527,9 +527,9 @@ static MagickBooleanType WritePS2Image(const ImageInfo *image_info,Image *image,
(void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
&geometry.width,&geometry.height);
scale.x=PerceptibleReciprocal(resolution.x)*geometry.width*delta.x;
geometry.width=CastDoubleToUnsigned(scale.x+0.5);
geometry.width=CastDoubleToSizeT(scale.x+0.5);
scale.y=PerceptibleReciprocal(resolution.y)*geometry.height*delta.y;
geometry.height=CastDoubleToUnsigned(scale.y+0.5);
geometry.height=CastDoubleToSizeT(scale.y+0.5);
(void) ParseAbsoluteGeometry(page_geometry,&media_info);
(void) ParseGravityGeometry(image,page_geometry,&page_info,exception);
if (image->gravity != UndefinedGravity)
+2 -2
View File
@@ -985,9 +985,9 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image,
(void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
&geometry.width,&geometry.height);
scale.x=PerceptibleReciprocal(resolution.x)*geometry.width*delta.x;
geometry.width=CastDoubleToUnsigned(scale.x+0.5);
geometry.width=CastDoubleToSizeT(scale.x+0.5);
scale.y=PerceptibleReciprocal(resolution.y)*geometry.height*delta.y;
geometry.height=CastDoubleToUnsigned(scale.y+0.5);
geometry.height=CastDoubleToSizeT(scale.y+0.5);
(void) ParseAbsoluteGeometry(page_geometry,&media_info);
(void) ParseGravityGeometry(image,page_geometry,&page_info,exception);
if (image->gravity != UndefinedGravity)
+2 -2
View File
@@ -2499,10 +2499,10 @@ static void SVGStartElement(void *context,const xmlChar *name,
svg_info->view_box=svg_info->bounds;
svg_info->width=0;
if (svg_info->bounds.width >= MagickEpsilon)
svg_info->width=CastDoubleToUnsigned(svg_info->bounds.width+0.5);
svg_info->width=CastDoubleToSizeT(svg_info->bounds.width+0.5);
svg_info->height=0;
if (svg_info->bounds.height >= MagickEpsilon)
svg_info->height=CastDoubleToUnsigned(svg_info->bounds.height+0.5);
svg_info->height=CastDoubleToSizeT(svg_info->bounds.height+0.5);
(void) FormatLocaleFile(svg_info->file,"viewbox 0 0 %.20g %.20g\n",
(double) svg_info->width,(double) svg_info->height);
sx=PerceptibleReciprocal(svg_info->view_box.width)*svg_info->width;