From: cristy Date: Sat, 5 Nov 2011 02:15:45 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~6685 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b34e30c86419d1be763b1c415cc548d7771d58d;p=imagemagick --- diff --git a/MagickCore/colorspace.c b/MagickCore/colorspace.c index 84e5cd64e..f4aa655c1 100644 --- a/MagickCore/colorspace.c +++ b/MagickCore/colorspace.c @@ -619,8 +619,8 @@ MagickExport MagickBooleanType RGBTransformImage(Image *image, gamma=DisplayGamma; value=GetImageProperty(image,"gamma",exception); if (value != (const char *) NULL) - gamma=1.0/fabs(StringToDouble(value,(char **) NULL)) >= - MagickEpsilon ? StringToDouble(value,(char **) NULL) : 1.0; + gamma=1.0/fabs(StringToDouble(value,(char **) NULL)) >= MagickEpsilon ? + StringToDouble(value,(char **) NULL) : 1.0; film_gamma=FilmGamma; value=GetImageProperty(image,"film-gamma",exception); if (value != (const char *) NULL) diff --git a/MagickCore/display.c b/MagickCore/display.c index 408251c57..c924544e9 100644 --- a/MagickCore/display.c +++ b/MagickCore/display.c @@ -3553,7 +3553,8 @@ static MagickBooleanType XColorEditImage(Display *display, if (*fuzz == '\0') break; (void) ConcatenateMagickString(fuzz,"%",MaxTextExtent); - (*image)->fuzz=StringToDoubleInterval(fuzz,(double) QuantumRange+1.0); + (*image)->fuzz=StringToDoubleInterval(fuzz,(double) QuantumRange+ + 1.0); break; } case ColorEditUndoCommand: @@ -8310,7 +8311,7 @@ static Image *XMagickCommand(Display *display,XResourceInfo *resource_info, */ XSetCursorState(display,windows,MagickTrue); XCheckRefreshWindows(display,windows); - threshold=StringToDoubleInterval(factor,QuantumRange); + threshold=StringToDoubleInterval(factor,(double) QuantumRange+1.0); (void) BilevelImage(*image,threshold,exception); XSetCursorState(display,windows,MagickFalse); if (windows->image.orphan != MagickFalse) @@ -8512,7 +8513,7 @@ static Image *XMagickCommand(Display *display,XResourceInfo *resource_info, */ XSetCursorState(display,windows,MagickTrue); XCheckRefreshWindows(display,windows); - threshold=StringToDoubleInterval(factor,QuantumRange); + threshold=StringToDoubleInterval(factor,(double) QuantumRange+1.0); sepia_image=SepiaToneImage(*image,threshold,exception); if (sepia_image != (Image *) NULL) { @@ -8547,7 +8548,7 @@ static Image *XMagickCommand(Display *display,XResourceInfo *resource_info, */ XSetCursorState(display,windows,MagickTrue); XCheckRefreshWindows(display,windows); - threshold=StringToDoubleInterval(factor,QuantumRange); + threshold=StringToDoubleInterval(factor,(double) QuantumRange+1.0); (void) SolarizeImage(*image,threshold,exception); XSetCursorState(display,windows,MagickFalse); if (windows->image.orphan != MagickFalse) @@ -9874,7 +9875,8 @@ static MagickBooleanType XMatteEditImage(Display *display, if (*fuzz == '\0') break; (void) ConcatenateMagickString(fuzz,"%",MaxTextExtent); - (*image)->fuzz=StringToDoubleInterval(fuzz,(double) QuantumRange+1.0); + (*image)->fuzz=StringToDoubleInterval(fuzz,(double) QuantumRange+ + 1.0); break; } case MatteEditValueCommand: diff --git a/MagickCore/draw.c b/MagickCore/draw.c index 7ba5d516b..9ad24219d 100644 --- a/MagickCore/draw.c +++ b/MagickCore/draw.c @@ -2041,8 +2041,7 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, if (LocaleCompare("font-size",keyword) == 0) { GetMagickToken(q,&q,token); - graphic_context[n]->pointsize=StringToDouble(token, - (char **) NULL); + graphic_context[n]->pointsize=StringToDouble(token,(char **) NULL); break; } if (LocaleCompare("font-stretch",keyword) == 0) @@ -2156,8 +2155,7 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, if (LocaleCompare("kerning",keyword) == 0) { GetMagickToken(q,&q,token); - graphic_context[n]->kerning=StringToDouble(token, - (char **) NULL); + graphic_context[n]->kerning=StringToDouble(token,(char **) NULL); break; } status=MagickFalse; @@ -2359,13 +2357,13 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, GetMagickToken(q,&q,token); (void) CopyMagickString(name,token,MaxTextExtent); GetMagickToken(q,&q,token); - bounds.x=(ssize_t) ceil(StringToDouble(token, - (char **) NULL)-0.5); + bounds.x=(ssize_t) ceil(StringToDouble(token,(char **) NULL)- + 0.5); GetMagickToken(q,&q,token); if (*token == ',') GetMagickToken(q,&q,token); - bounds.y=(ssize_t) ceil(StringToDouble(token, - (char **) NULL)-0.5); + bounds.y=(ssize_t) ceil(StringToDouble(token,(char **) NULL)- + 0.5); GetMagickToken(q,&q,token); if (*token == ',') GetMagickToken(q,&q,token); @@ -2557,8 +2555,8 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, GetMagickToken(q,&q,token); if (*token == ',') GetMagickToken(q,&q,token); - graphic_context[n]->dash_pattern[j]=StringToDouble( - token,(char **) NULL); + graphic_context[n]->dash_pattern[j]=StringToDouble(token, + (char **) NULL); } if ((x & 0x01) != 0) for ( ; j < (2*x); j++) @@ -2695,23 +2693,23 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, if (LocaleCompare("viewbox",keyword) == 0) { GetMagickToken(q,&q,token); - graphic_context[n]->viewbox.x=(ssize_t) ceil(StringToDouble( - token,(char **) NULL)-0.5); + graphic_context[n]->viewbox.x=(ssize_t) ceil(StringToDouble(token, + (char **) NULL)-0.5); GetMagickToken(q,&q,token); if (*token == ',') GetMagickToken(q,&q,token); - graphic_context[n]->viewbox.y=(ssize_t) ceil(StringToDouble( - token,(char **) NULL)-0.5); + graphic_context[n]->viewbox.y=(ssize_t) ceil(StringToDouble(token, + (char **) NULL)-0.5); GetMagickToken(q,&q,token); if (*token == ',') GetMagickToken(q,&q,token); - graphic_context[n]->viewbox.width=(size_t) floor( - StringToDouble(token,(char **) NULL)+0.5); + graphic_context[n]->viewbox.width=(size_t) floor(StringToDouble( + token,(char **) NULL)+0.5); GetMagickToken(q,&q,token); if (*token == ',') GetMagickToken(q,&q,token); - graphic_context[n]->viewbox.height=(size_t) floor( - StringToDouble(token,(char **) NULL)+0.5); + graphic_context[n]->viewbox.height=(size_t) floor(StringToDouble( + token,(char **) NULL)+0.5); break; } status=MagickFalse; @@ -4786,12 +4784,10 @@ MagickExport void GetDrawInfo(const ImageInfo *image_info,DrawInfo *draw_info) draw_info->kerning=StringToDouble(option,(char **) NULL); option=GetImageOption(image_info,"interline-spacing"); if (option != (const char *) NULL) - draw_info->interline_spacing=StringToDouble(option, - (char **) NULL); + draw_info->interline_spacing=StringToDouble(option,(char **) NULL); option=GetImageOption(image_info,"interword-spacing"); if (option != (const char *) NULL) - draw_info->interword_spacing=StringToDouble(option, - (char **) NULL); + draw_info->interword_spacing=StringToDouble(option,(char **) NULL); option=GetImageOption(image_info,"direction"); if (option != (const char *) NULL) draw_info->direction=(DirectionType) ParseCommandOption( diff --git a/MagickCore/enhance.c b/MagickCore/enhance.c index 5514776bb..fe9ef9ada 100644 --- a/MagickCore/enhance.c +++ b/MagickCore/enhance.c @@ -573,8 +573,7 @@ MagickExport MagickBooleanType ColorDecisionListImage(Image *image, { case 0: { - color_correction.red.slope=StringToDouble(token, - (char **) NULL); + color_correction.red.slope=StringToDouble(token,(char **) NULL); break; } case 1: @@ -639,8 +638,7 @@ MagickExport MagickBooleanType ColorDecisionListImage(Image *image, { case 0: { - color_correction.red.power=StringToDouble(token, - (char **) NULL); + color_correction.red.power=StringToDouble(token,(char **) NULL); break; } case 1: diff --git a/MagickCore/image.c b/MagickCore/image.c index e6c30558a..f7f9d1cbd 100644 --- a/MagickCore/image.c +++ b/MagickCore/image.c @@ -4130,7 +4130,7 @@ MagickExport MagickBooleanType SyncImageSettings(const ImageInfo *image_info, exception); option=GetImageOption(image_info,"bias"); if (option != (const char *) NULL) - image->bias=StringToDoubleInterval(option,QuantumRange); + image->bias=StringToDoubleInterval(option,(double) QuantumRange+1.0); option=GetImageOption(image_info,"black-point-compensation"); if (option != (const char *) NULL) image->black_point_compensation=(MagickBooleanType) ParseCommandOption( diff --git a/MagickCore/morphology.c b/MagickCore/morphology.c index 743ce7040..462b1f335 100644 --- a/MagickCore/morphology.c +++ b/MagickCore/morphology.c @@ -331,7 +331,7 @@ static KernelInfo *ParseKernelArray(const char *kernel_string) kernel->values[i] = nan; /* do not include this value in kernel */ } else { - kernel->values[i] = StringToDouble(token,(char **) NULL); + kernel->values[i]=StringToDouble(token,(char **) NULL); ( kernel->values[i] < 0) ? ( kernel->negative_range += kernel->values[i] ) : ( kernel->positive_range += kernel->values[i] ); diff --git a/MagickCore/property.c b/MagickCore/property.c index ce4a5f11b..1944be2b1 100644 --- a/MagickCore/property.c +++ b/MagickCore/property.c @@ -3200,7 +3200,7 @@ MagickExport MagickBooleanType SetImageProperty(Image *image, } if (LocaleCompare(property,"bias") == 0) { - image->bias=StringToDoubleInterval(value,QuantumRange); + image->bias=StringToDoubleInterval(value,(double) QuantumRange+1.0); break; } status=AddValueToSplayTree((SplayTreeInfo *) image->properties, diff --git a/MagickCore/resize.c b/MagickCore/resize.c index f9c59be9f..485209d47 100644 --- a/MagickCore/resize.c +++ b/MagickCore/resize.c @@ -973,8 +973,7 @@ MagickPrivate ResizeFilter *AcquireResizeFilter(const Image *image, } artifact=GetImageArtifact(image,"filter:support"); if (artifact != (const char *) NULL) - resize_filter->support=fabs(StringToDouble(artifact, - (char **) NULL)); /* override support */ + resize_filter->support=fabs(StringToDouble(artifact,(char **) NULL)); /* override support */ /* Scale windowing function separately to the support 'clipping' window that calling operator is planning to actually use (expert override). @@ -982,8 +981,7 @@ MagickPrivate ResizeFilter *AcquireResizeFilter(const Image *image, resize_filter->window_support=resize_filter->support; /* default */ artifact=GetImageArtifact(image,"filter:win-support"); if (artifact != (const char *) NULL) - resize_filter->window_support=fabs(StringToDouble(artifact, - (char **) NULL)); + resize_filter->window_support=fabs(StringToDouble(artifact,(char **) NULL)); /* Adjust window function scaling to match windowing support for weighting function. This avoids a division on every filter call. diff --git a/MagickCore/resource.c b/MagickCore/resource.c index b92e205c0..f095032f3 100644 --- a/MagickCore/resource.c +++ b/MagickCore/resource.c @@ -899,7 +899,7 @@ static inline MagickSizeType StringToSizeType(const char *string, double value; - value=StringToDoubleInterval(string,interval); + value=SiPrefixToDoubleInterval(string,interval); if (value >= (double) MagickULLConstant(~0)) return(MagickULLConstant(~0)); return((MagickSizeType) value); diff --git a/MagickCore/static.c b/MagickCore/static.c index b0f311d3d..9ef564c85 100644 --- a/MagickCore/static.c +++ b/MagickCore/static.c @@ -247,9 +247,6 @@ MagickExport void RegisterStaticModules(void) (void) RegisterNULLImage(); (void) RegisterOTBImage(); (void) RegisterPALMImage(); -#if defined(MAGICKCORE_PANGO_DELEGATE) - (void) RegisterPANGOImage(); -#endif (void) RegisterPATTERNImage(); (void) RegisterPCDImage(); (void) RegisterPCLImage(); @@ -425,9 +422,6 @@ MagickExport void UnregisterStaticModules(void) UnregisterNULLImage(); UnregisterOTBImage(); UnregisterPALMImage(); -#if defined(MAGICKCORE_PANGO_DELEGATE) - UnregisterPANGOImage(); -#endif UnregisterPATTERNImage(); UnregisterPCDImage(); UnregisterPCLImage(); diff --git a/MagickCore/static.h b/MagickCore/static.h index 8888d0209..fb412eb0a 100644 --- a/MagickCore/static.h +++ b/MagickCore/static.h @@ -107,7 +107,6 @@ extern ModuleExport size_t RegisterPBMImage(void), RegisterOTBImage(void), RegisterPALMImage(void), - RegisterPANGOImage(void), RegisterPATTERNImage(void), RegisterPCDImage(void), RegisterPCDSImage(void), @@ -262,7 +261,6 @@ extern ModuleExport void UnregisterPBMImage(void), UnregisterOTBImage(void), UnregisterPALMImage(void), - UnregisterPANGOImage(void), UnregisterPATTERNImage(void), UnregisterPCDImage(void), UnregisterPCDSImage(void), diff --git a/MagickCore/string-private.h b/MagickCore/string-private.h index 8c99324e2..b8948c85f 100644 --- a/MagickCore/string-private.h +++ b/MagickCore/string-private.h @@ -24,6 +24,21 @@ extern "C" { #include +static inline double SiPrefixToDoubleInterval(const char *string, + const double interval) +{ + char + *q; + + double + value; + + value=InterpretSiPrefixValue(string,&q); + if (*q == '%') + value*=interval/100.0; + return(value); +} + static inline double StringToDouble(const char *restrict string, char **restrict sentinal) { @@ -39,7 +54,7 @@ static inline double StringToDoubleInterval(const char *string, double value; - value=InterpretSiPrefixValue(string,&q); + value=InterpretLocaleValue(string,&q); if (*q == '%') value*=interval/100.0; return(value); diff --git a/MagickWand/compare.c b/MagickWand/compare.c index 481b38ede..a665d7fba 100644 --- a/MagickWand/compare.c +++ b/MagickWand/compare.c @@ -529,8 +529,7 @@ WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info, if (*option == '+') dissimilarity_threshold=DefaultDissimilarityThreshold; else - dissimilarity_threshold=StringToDouble(argv[i], - (char **) NULL); + dissimilarity_threshold=StringToDouble(argv[i],(char **) NULL); break; } if (LocaleCompare("duration",option+1) == 0) diff --git a/MagickWand/mogrify.c b/MagickWand/mogrify.c index d002e861b..ed786652c 100644 --- a/MagickWand/mogrify.c +++ b/MagickWand/mogrify.c @@ -1309,7 +1309,8 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, if (*option == '+') threshold=40.0*QuantumRange/100.0; else - threshold=StringToDoubleInterval(argv[i+1],QuantumRange); + threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ + 1.0); mogrify_image=DeskewImage(*image,threshold,exception); break; } @@ -1507,7 +1508,8 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, (void) SyncImageSettings(mogrify_info,*image,exception); op=(MagickEvaluateOperator) ParseCommandOption( MagickEvaluateOptions,MagickFalse,argv[i+1]); - constant=StringToDoubleInterval(argv[i+2],QuantumRange); + constant=StringToDoubleInterval(argv[i+2],(double) QuantumRange+ + 1.0); (void) EvaluateImage(*image,op,constant,exception); break; } @@ -1978,8 +1980,7 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, } if (LocaleCompare("linewidth",option+1) == 0) { - draw_info->stroke_width=StringToDouble(argv[i+1], - (char **) NULL); + draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL); break; } if (LocaleCompare("liquid-rescale",option+1) == 0) @@ -2618,7 +2619,8 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, Sepia-tone image. */ (void) SyncImageSettings(mogrify_info,*image,exception); - threshold=StringToDoubleInterval(argv[i+1],QuantumRange); + threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ + 1.0); mogrify_image=SepiaToneImage(*image,threshold,exception); break; } @@ -2782,7 +2784,8 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, threshold; (void) SyncImageSettings(mogrify_info,*image,exception); - threshold=StringToDoubleInterval(argv[i+1],QuantumRange); + threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ + 1.0); (void) SolarizeImage(*image,threshold,exception); break; } @@ -2888,8 +2891,7 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, } if (LocaleCompare("strokewidth",option+1) == 0) { - draw_info->stroke_width=StringToDouble(argv[i+1], - (char **) NULL); + draw_info->stroke_width=StringToDouble(argv[i+1],(char **) NULL); break; } if (LocaleCompare("style",option+1) == 0) @@ -2930,7 +2932,8 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, if (*option == '+') threshold=(double) QuantumRange/2; else - threshold=StringToDoubleInterval(argv[i+1],QuantumRange); + threshold=StringToDoubleInterval(argv[i+1],(double) QuantumRange+ + 1.0); (void) BilevelImage(*image,threshold,exception); break; } @@ -6247,7 +6250,8 @@ WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, limit=MagickResourceInfinity; if (LocaleCompare("unlimited",argv[i+1]) != 0) - limit=(MagickSizeType) StringToDoubleInterval(argv[i+1],100.0); + limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1], + 100.0); (void) SetMagickResourceLimit(MemoryResource,limit); (void) SetMagickResourceLimit(MapResource,2*limit); break; @@ -6653,7 +6657,8 @@ WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, MagickFalse,argv[i+1]); limit=MagickResourceInfinity; if (LocaleCompare("unlimited",argv[i+2]) != 0) - limit=(MagickSizeType) StringToDoubleInterval(argv[i+2],100.0); + limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2], + 100.0); (void) SetMagickResourceLimit(type,limit); break; } diff --git a/MagickWand/montage.c b/MagickWand/montage.c index 1995b1d54..befab247c 100644 --- a/MagickWand/montage.c +++ b/MagickWand/montage.c @@ -1282,8 +1282,7 @@ WandExport MagickBooleanType MontageImageCommand(ImageInfo *image_info, ThrowMontageException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowMontageInvalidArgumentException(option,argv[i]); - montage_info->pointsize=StringToDouble(argv[i], - (char **) NULL); + montage_info->pointsize=StringToDouble(argv[i],(char **) NULL); break; } if (LocaleCompare("polaroid",option+1) == 0) diff --git a/MagickWand/operation.c b/MagickWand/operation.c index 8881e165d..8984b2016 100644 --- a/MagickWand/operation.c +++ b/MagickWand/operation.c @@ -557,15 +557,15 @@ WandExport MagickBooleanType ApplySettingsOption(MagickWand *wand, limit=MagickResourceInfinity; if (LocaleCompare("unlimited",arg) != 0) - limit=(MagickSizeType) StringToDoubleInterval(arg,100.0); + limit=(MagickSizeType) SiPrefixToDoubleInterval(arg,100.0); (void) SetMagickResourceLimit(MemoryResource,limit); (void) SetMagickResourceLimit(MapResource,2*limit); break; } if (LocaleCompare("caption",option) == 0) { - (void) SetImageOption(image_info,option, - IfSetOption ? arg : (const char*)NULL); + (void) SetImageOption(image_info,option,IfSetOption ? arg : + (const char*)NULL); break; } if (LocaleCompare("channel",option) == 0) @@ -832,7 +832,8 @@ WandExport MagickBooleanType ApplySettingsOption(MagickWand *wand, */ if (IfSetOption) { - image_info->fuzz=StringToDoubleInterval(arg,(double) QuantumRange+1.0); + image_info->fuzz=StringToDoubleInterval(arg,(double) QuantumRange+ + 1.0); (void) SetImageOption(image_info,option,arg); break; } @@ -901,8 +902,7 @@ WandExport MagickBooleanType ApplySettingsOption(MagickWand *wand, value = IfSetOption ? arg : "0"; /* undefined? */ (void) SetImageOption(image_info,option, value); - draw_info->interline_spacing=StringToDouble(value, - (char **) NULL); + draw_info->interline_spacing=StringToDouble(value,(char **) NULL); break; } if (LocaleCompare("interpolate",option) == 0) @@ -922,8 +922,7 @@ WandExport MagickBooleanType ApplySettingsOption(MagickWand *wand, value = IfSetOption ? arg : "0"; /* undefined? */ (void) SetImageOption(image_info,option, value); - draw_info->interword_spacing=StringToDouble(value, - (char **) NULL); + draw_info->interword_spacing=StringToDouble(value,(char **) NULL); break; } break; @@ -965,7 +964,8 @@ WandExport MagickBooleanType ApplySettingsOption(MagickWand *wand, MagickFalse,arg); limit=MagickResourceInfinity; if (LocaleCompare("unlimited",argv[2]) != 0) - limit=(MagickSizeType) StringToDoubleInterval(argv[2],100.0); + limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[2], + 100.0); (void) SetMagickResourceLimit(type,limit); break; } @@ -2115,7 +2115,7 @@ WandExport MagickBooleanType ApplySettingsOption(MagickWand *wand, if (*argv[0] == '+') threshold=40.0*QuantumRange/100.0; else - threshold=StringToDoubleInterval(args[0],QuantumRange); + threshold=StringToDoubleInterval(args[0],(double) QuantumRange+1.0); new_image=DeskewImage(*image,threshold,exception); break; } @@ -2276,7 +2276,7 @@ WandExport MagickBooleanType ApplySettingsOption(MagickWand *wand, (void) SyncImageSettings(image_info,*image,exception); op=(MagickEvaluateOperator) ParseCommandOption( MagickEvaluateOptions,MagickFalse,args[0]); - constant=StringToDoubleInterval(argv[2],QuantumRange); + constant=StringToDoubleInterval(argv[2],(double) QuantumRange+1.0); (void) EvaluateImage(*image,op,constant,exception); break; } @@ -3218,7 +3218,7 @@ WandExport MagickBooleanType ApplySettingsOption(MagickWand *wand, threshold; (void) SyncImageSettings(image_info,*image,exception); - threshold=StringToDoubleInterval(args[0],QuantumRange); + threshold=StringToDoubleInterval(args[0],(double) QuantumRange+1.0); new_image=SepiaToneImage(*image,threshold,exception); break; } @@ -3354,7 +3354,7 @@ WandExport MagickBooleanType ApplySettingsOption(MagickWand *wand, threshold; (void) SyncImageSettings(image_info,*image,exception); - threshold=StringToDoubleInterval(args[0],QuantumRange); + threshold=StringToDoubleInterval(args[0],(double) QuantumRange+1.0); (void) SolarizeImage(*image,threshold,exception); break; } @@ -3433,7 +3433,7 @@ WandExport MagickBooleanType ApplySettingsOption(MagickWand *wand, if (*argv[0] == '+') threshold=(double) QuantumRange/2; else - threshold=StringToDoubleInterval(args[0],QuantumRange); + threshold=StringToDoubleInterval(args[0],(double) QuantumRange+1.0); (void) BilevelImage(*image,threshold,exception); break; } diff --git a/PerlMagick/Magick.xs b/PerlMagick/Magick.xs index 068fb1d97..155237c85 100644 --- a/PerlMagick/Magick.xs +++ b/PerlMagick/Magick.xs @@ -1026,32 +1026,37 @@ static struct PackageInfo *GetPackageInfo(pTHX_ void *reference, % */ +static double SiPrefixToDoubleInterval(const char *string,const double interval) +{ + char + *q; + + double + value; + + value=InterpretSiPrefixValue(string,&q); + if (*q == '%') + value*=interval/100.0; + return(value); +} + +static inline double StringToDouble(const char *restrict string, + char **restrict sentinal) +{ + return(InterpretLocaleValue(string,sentinal)); +} + static double StringToDoubleInterval(const char *string,const double interval) { char *q; double - scale, value; - value=StringToDouble(string,&q); - scale=1000.0; - if ((*q != '\0') && (tolower((int) ((unsigned char) *(q+1))) == 'i')) - scale=1024.0; - switch (tolower((int) ((unsigned char) *q))) - { - case '%': value*=pow(scale,0)*interval/100.0; break; - case 'k': value*=pow(scale,1); break; - case 'm': value*=pow(scale,2); break; - case 'g': value*=pow(scale,3); break; - case 't': value*=pow(scale,4); break; - case 'p': value*=pow(scale,5); break; - case 'e': value*=pow(scale,6); break; - case 'z': value*=pow(scale,7); break; - case 'y': value*=pow(scale,8); break; - default: break; - } + value=InterpretLocaleValue(string,&q); + if (*q == '%') + value*=interval/100.0; return(value); } @@ -1137,7 +1142,8 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, limit=MagickResourceInfinity; if (LocaleCompare(SvPV(sval,na),"unlimited") != 0) - limit=(MagickSizeType) StringToDoubleInterval(SvPV(sval,na),100.0); + limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na), + 100.0); (void) SetMagickResourceLimit(AreaResource,limit); break; } @@ -1175,7 +1181,8 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (LocaleCompare(attribute,"bias") == 0) { for ( ; image; image=image->next) - image->bias=StringToDoubleInterval(SvPV(sval,na),QuantumRange); + image->bias=StringToDoubleInterval(SvPV(sval,na),(double) + QuantumRange+1.0); break; } if (LocaleCompare(attribute,"blue-primary") == 0) @@ -1213,9 +1220,9 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (LocaleCompare(attribute,"cache-threshold") == 0) { (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType) - StringToDoubleInterval(SvPV(sval,na),100.0)); + SiPrefixToDoubleInterval(SvPV(sval,na),100.0)); (void) SetMagickResourceLimit(MapResource,(MagickSizeType) - (2*StringToDoubleInterval(SvPV(sval,na),100.0))); + (2.0*SiPrefixToDoubleInterval(SvPV(sval,na),100.0))); break; } if (LocaleCompare(attribute,"clip-mask") == 0) @@ -1340,7 +1347,8 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, limit=MagickResourceInfinity; if (LocaleCompare(SvPV(sval,na),"unlimited") != 0) - limit=(MagickSizeType) StringToDoubleInterval(SvPV(sval,na),100.0); + limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na), + 100.0); (void) SetMagickResourceLimit(DiskResource,limit); break; } @@ -1505,9 +1513,11 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (LocaleCompare(attribute,"fuzz") == 0) { if (info) - info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),QuantumRange); + info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),(double) + QuantumRange+1.0); for ( ; image; image=image->next) - image->fuzz=StringToDoubleInterval(SvPV(sval,na),QuantumRange); + image->fuzz=StringToDoubleInterval(SvPV(sval,na),(double) + QuantumRange+1.0); break; } if (info) @@ -1665,7 +1675,8 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, limit=MagickResourceInfinity; if (LocaleCompare(SvPV(sval,na),"unlimited") != 0) - limit=(MagickSizeType) StringToDoubleInterval(SvPV(sval,na),100.0); + limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na), + 100.0); (void) SetMagickResourceLimit(MapResource,limit); break; } @@ -1712,7 +1723,8 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, limit=MagickResourceInfinity; if (LocaleCompare(SvPV(sval,na),"unlimited") != 0) - limit=(MagickSizeType) StringToDoubleInterval(SvPV(sval,na),100.0); + limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na), + 100.0); (void) SetMagickResourceLimit(MemoryResource,limit); break; } @@ -2035,7 +2047,8 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, limit=MagickResourceInfinity; if (LocaleCompare(SvPV(sval,na),"unlimited") != 0) - limit=(MagickSizeType) StringToDoubleInterval(SvPV(sval,na),100.0); + limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na), + 100.0); (void) SetMagickResourceLimit(ThreadResource,limit); break; } @@ -2060,7 +2073,8 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, limit=MagickResourceInfinity; if (LocaleCompare(SvPV(sval,na),"unlimited") != 0) - limit=(MagickSizeType) StringToDoubleInterval(SvPV(sval,na),100.0); + limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na), + 100.0); (void) SetMagickResourceLimit(TimeResource,limit); break; } @@ -7622,8 +7636,8 @@ Mogrify(ref,...) if (attribute_flag[4] != 0) geometry.y=argument_list[4].integer_reference; if (attribute_flag[5] != 0) - image->fuzz= - StringToDoubleInterval(argument_list[5].string_reference,QuantumRange); + image->fuzz=StringToDoubleInterval( + argument_list[5].string_reference,(double) QuantumRange+1.0); image=CropImage(image,&geometry,exception); break; } @@ -8222,8 +8236,8 @@ Mogrify(ref,...) invert=MagickTrue; } if (attribute_flag[5] != 0) - image->fuzz=StringToDoubleInterval(argument_list[5].string_reference, - QuantumRange); + image->fuzz=StringToDoubleInterval( + argument_list[5].string_reference,(double) QuantumRange+1.0); if (attribute_flag[6] != 0) invert=(MagickBooleanType) argument_list[6].integer_reference; (void) FloodfillPaintImage(image,draw_info,&target,geometry.x, @@ -8259,7 +8273,7 @@ Mogrify(ref,...) if (compose != DissolveCompositeOp) (void) SetImageAlpha(composite_image,(Quantum) StringToDoubleInterval(argument_list[6].string_reference, - QuantumRange),exception); + (double) QuantumRange+1.0),exception); else { CacheView @@ -8287,7 +8301,8 @@ Mogrify(ref,...) (void) CloneString(&image->geometry, argument_list[6].string_reference); opacity=(Quantum) StringToDoubleInterval( - argument_list[6].string_reference,QuantumRange); + argument_list[6].string_reference,(double) QuantumRange+ + 1.0); if (composite_image->matte != MagickTrue) (void) SetImageAlpha(composite_image,OpaqueAlpha,exception); composite_view=AcquireCacheView(composite_image); @@ -8789,11 +8804,12 @@ Mogrify(ref,...) QueryColorCompliance(argument_list[4].string_reference, AllCompliance,&target,exception); if (attribute_flag[3] != 0) - target.alpha=StringToDoubleInterval(argument_list[3].string_reference, - QuantumRange); + target.alpha=StringToDoubleInterval( + argument_list[3].string_reference,(double) (double) QuantumRange+ + 1.0); if (attribute_flag[5] != 0) - image->fuzz=StringToDoubleInterval(argument_list[5].string_reference, - QuantumRange); + image->fuzz=StringToDoubleInterval( + argument_list[5].string_reference,(double) QuantumRange+1.0); invert=MagickFalse; if (attribute_flag[6] != 0) invert=(MagickBooleanType) argument_list[6].integer_reference; @@ -8887,8 +8903,8 @@ Mogrify(ref,...) (void) QueryColorCompliance(argument_list[1].string_reference, AllCompliance,&fill_color,exception); if (attribute_flag[2] != 0) - image->fuzz=StringToDoubleInterval(argument_list[2].string_reference, - QuantumRange); + image->fuzz=StringToDoubleInterval( + argument_list[2].string_reference,(double) QuantumRange+1.0); if (attribute_flag[3] != 0) channel=(ChannelType) argument_list[3].integer_reference; invert=MagickFalse; @@ -9007,7 +9023,7 @@ Mogrify(ref,...) &geometry_info); if (attribute_flag[1] != 0) geometry_info.rho=StringToDoubleInterval( - argument_list[1].string_reference,QuantumRange); + argument_list[1].string_reference,(double) QuantumRange+1.0); (void) SolarizeImage(image,geometry_info.rho,exception); break; } @@ -9060,10 +9076,10 @@ Mogrify(ref,...) opacity=TransparentAlpha; if (attribute_flag[1] != 0) opacity=StringToDoubleInterval(argument_list[1].string_reference, - QuantumRange); + (double) QuantumRange+1.0); if (attribute_flag[2] != 0) - image->fuzz=StringToDoubleInterval(argument_list[2].string_reference, - QuantumRange); + image->fuzz=StringToDoubleInterval( + argument_list[2].string_reference,(double) QuantumRange+1.0); if (attribute_flag[3] == 0) argument_list[3].integer_reference=0; invert=MagickFalse; @@ -9083,7 +9099,7 @@ Mogrify(ref,...) if (attribute_flag[1] != 0) channel=(ChannelType) argument_list[1].integer_reference; threshold=StringToDoubleInterval(argument_list[0].string_reference, - QuantumRange); + (double) QuantumRange+1.0); channel_mask=SetPixelChannelMask(image,channel); (void) BilevelImage(image,threshold,exception); (void) SetPixelChannelMask(image,channel_mask); @@ -9111,8 +9127,8 @@ Mogrify(ref,...) case 59: /* Trim */ { if (attribute_flag[0] != 0) - image->fuzz=StringToDoubleInterval(argument_list[0].string_reference, - QuantumRange); + image->fuzz=StringToDoubleInterval( + argument_list[0].string_reference,(double) QuantumRange+1.0); image=TrimImage(image,exception); break; } @@ -9247,8 +9263,8 @@ Mogrify(ref,...) if (attribute_flag[1] != 0) channel=(ChannelType) argument_list[1].integer_reference; if (attribute_flag[2] != 0) - image->bias=StringToDoubleInterval(argument_list[2].string_reference, - QuantumRange); + image->bias=StringToDoubleInterval( + argument_list[2].string_reference,(double) QuantumRange+1.0); if (attribute_flag[3] != 0) { kernel=AcquireKernelInfo(argument_list[3].string_reference); @@ -9600,8 +9616,8 @@ Mogrify(ref,...) goto PerlException; } if (attribute_flag[1] != 0) - image->fuzz=StringToDoubleInterval(argument_list[1].string_reference, - QuantumRange); + image->fuzz=StringToDoubleInterval( + argument_list[1].string_reference,(double) QuantumRange+1.0); (void) IsImagesEqual(image,argument_list[0].image_reference, exception); break; @@ -9773,8 +9789,8 @@ Mogrify(ref,...) if (attribute_flag[4] != 0) geometry.y=argument_list[4].integer_reference; if (attribute_flag[5] != 0) - image->fuzz=StringToDoubleInterval(argument_list[5].string_reference, - QuantumRange); + image->fuzz=StringToDoubleInterval( + argument_list[5].string_reference,(double) QuantumRange+1.0); if (attribute_flag[6] != 0) (void) QueryColorCompliance(argument_list[6].string_reference, AllCompliance,&image->background_color,exception); @@ -9898,8 +9914,8 @@ Mogrify(ref,...) if (attribute_flag[4] != 0) geometry.y=argument_list[4].integer_reference; if (attribute_flag[5] != 0) - image->fuzz=StringToDoubleInterval(argument_list[5].string_reference, - QuantumRange); + image->fuzz=StringToDoubleInterval( + argument_list[5].string_reference,(double) QuantumRange+1.0); if (attribute_flag[6] != 0) (void) QueryColorCompliance(argument_list[6].string_reference, AllCompliance,&image->background_color,exception); @@ -10273,8 +10289,8 @@ Mogrify(ref,...) QueryColorCompliance(argument_list[4].string_reference, AllCompliance,&target,exception); if (attribute_flag[5] != 0) - image->fuzz=StringToDoubleInterval(argument_list[5].string_reference, - QuantumRange); + image->fuzz=StringToDoubleInterval( + argument_list[5].string_reference,(double) QuantumRange+1.0); if (attribute_flag[6] != 0) channel=(ChannelType) argument_list[6].integer_reference; invert=MagickFalse; @@ -10393,7 +10409,7 @@ Mogrify(ref,...) &geometry_info); if (attribute_flag[1] != 0) geometry_info.rho=StringToDoubleInterval( - argument_list[1].string_reference,QuantumRange); + argument_list[1].string_reference,(double) QuantumRange+1.0); image=DeskewImage(image,geometry_info.rho,exception); break; } diff --git a/coders/mpc.c b/coders/mpc.c index c10861bda..02b3e37aa 100644 --- a/coders/mpc.c +++ b/coders/mpc.c @@ -444,8 +444,8 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception) } if (LocaleCompare(keyword,"error") == 0) { - image->error.mean_error_per_pixel=StringToDouble( - options,(char **) NULL); + image->error.mean_error_per_pixel=StringToDouble(options, + (char **) NULL); break; } (void) SetImageProperty(image,keyword,options,exception); @@ -511,14 +511,14 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception) } if (LocaleCompare(keyword,"maximum-error") == 0) { - image->error.normalized_maximum_error= - StringToDouble(options,(char **) NULL); + image->error.normalized_maximum_error=StringToDouble( + options,(char **) NULL); break; } if (LocaleCompare(keyword,"mean-error") == 0) { - image->error.normalized_mean_error=StringToDouble( - options,(char **) NULL); + image->error.normalized_mean_error=StringToDouble(options, + (char **) NULL); break; } if (LocaleCompare(keyword,"montage") == 0) diff --git a/coders/msl.c b/coders/msl.c index 1002fe973..c9d51d6c1 100644 --- a/coders/msl.c +++ b/coders/msl.c @@ -820,8 +820,8 @@ static void MSLStartElement(void *context,const xmlChar *tag, } if (LocaleCompare(keyword,"antialias") == 0) { - option=ParseCommandOption(MagickBooleanOptions,MagickFalse, - value); + option=ParseCommandOption(MagickBooleanOptions, + MagickFalse,value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedBooleanType", value); @@ -908,8 +908,7 @@ static void MSLStartElement(void *context,const xmlChar *tag, { if (LocaleCompare(keyword,"pointsize") == 0) { - draw_info->pointsize=StringToDouble(value, - (char **) NULL); + draw_info->pointsize=StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", @@ -1211,8 +1210,7 @@ static void MSLStartElement(void *context,const xmlChar *tag, { if (LocaleCompare(keyword,"radius") == 0) { - geometry_info.rho=StringToDouble(value, - (char **) NULL); + geometry_info.rho=StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", @@ -1466,19 +1464,19 @@ static void MSLStartElement(void *context,const xmlChar *tag, case 'b': { if (LocaleCompare(keyword, "bias") == 0) - { - bias = StringToDouble(value,(char **) NULL); - break; - } + { + bias=StringToDouble(value,(char **) NULL); + break; + } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } case 'R': case 'r': { - if (LocaleCompare(keyword, "radius") == 0) + if (LocaleCompare(keyword,"radius") == 0) { - radius = StringToDouble(value,(char **) NULL); + radius=StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); @@ -2762,8 +2760,7 @@ static void MSLStartElement(void *context,const xmlChar *tag, { if (LocaleCompare(keyword,"radius") == 0) { - geometry_info.rho=StringToDouble(value, - (char **) NULL); + geometry_info.rho=StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",