From: Cristy Date: Thu, 28 Jul 2016 21:41:37 +0000 (-0400) Subject: https://www.imagemagick.org/discourse-server/posting.php?mode=reply&f=1&t=29692 X-Git-Tag: 7.0.2-6~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3661062ac624bcb08203d18d3cfb6eb72554c238;p=imagemagick https://www.imagemagick.org/discourse-server/posting.php?mode=reply&f=1&t=29692 --- diff --git a/MagickCore/image.c b/MagickCore/image.c index ca66a79f7..69a6f3a6e 100644 --- a/MagickCore/image.c +++ b/MagickCore/image.c @@ -3193,20 +3193,23 @@ MagickExport MagickBooleanType SetImageRegionMask(Image *image, } for (x=0; x < (ssize_t) image->columns; x++) { - MagickRealType - intensity; + Quantum + pixel; - intensity=0; + pixel=0; + if (((x >= region->x) && (x < (region->x+region->width))) && + ((y >= region->y) && (y < (region->y+region->height)))) + pixel=QuantumRange; switch (type) { case WritePixelMask: { - SetPixelWriteMask(image,ClampToQuantum(QuantumRange-intensity),q); + SetPixelWriteMask(image,pixel,q); break; } default: { - SetPixelReadMask(image,ClampToQuantum(QuantumRange-intensity),q); + SetPixelReadMask(image,pixel,q); break; } } diff --git a/MagickCore/option.c b/MagickCore/option.c index b2e04e436..9de7ff68f 100644 --- a/MagickCore/option.c +++ b/MagickCore/option.c @@ -659,8 +659,8 @@ static const OptionInfo { "-recolor", 1L, ReplacedOptionFlag | SimpleOperatorFlag, MagickTrue }, { "+red-primary", 0L, ImageInfoOptionFlag, MagickFalse }, { "-red-primary", 1L, ImageInfoOptionFlag, MagickFalse }, - { "+region", 0L, NoImageOperatorFlag, MagickFalse }, - { "-region", 1L, NoImageOperatorFlag, MagickFalse }, + { "+region", 0L, SimpleOperatorFlag, MagickFalse }, + { "-region", 1L, SimpleOperatorFlag, MagickFalse }, { "+remap", 0L, ListOperatorFlag | NeverInterpretArgsFlag | FireOptionFlag, MagickFalse }, { "-remap", 1L, SimpleOperatorFlag | NeverInterpretArgsFlag, MagickFalse }, { "+remote", 0L, NonMagickOptionFlag, MagickFalse }, diff --git a/MagickWand/mogrify.c b/MagickWand/mogrify.c index e4b4ffc5f..ec9763171 100644 --- a/MagickWand/mogrify.c +++ b/MagickWand/mogrify.c @@ -147,7 +147,7 @@ WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, (void) setlocale(LC_ALL,""); (void) setlocale(LC_NUMERIC,"C"); GetPathComponent(argv[0],TailPath,client_name); - SetClientName(client_name); + (void) SetClientName(client_name); concurrent=MagickFalse; duration=(-1.0); iterations=1; @@ -690,9 +690,6 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, GeometryInfo geometry_info; - Image - *region_image; - ImageInfo *mogrify_info; @@ -740,7 +737,6 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, interpolate_method=UndefinedInterpolatePixel; format=GetImageOption(mogrify_info,"format"); SetGeometry(*image,®ion_geometry); - region_image=NewImageList(); /* Transmogrify the image. */ @@ -2597,33 +2593,18 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, } if (LocaleCompare("region",option+1) == 0) { + /* + Apply read mask as defined by a region geometry. + */ (void) SyncImageSettings(mogrify_info,*image,exception); - if (region_image != (Image *) NULL) + if (*option == '+') { - /* - Composite region. - */ - (void) CompositeImage(region_image,*image, - region_image->alpha_trait != UndefinedPixelTrait ? - CopyCompositeOp : OverCompositeOp,MagickTrue, - region_geometry.x,region_geometry.y,exception); - *image=DestroyImage(*image); - *image=region_image; - region_image = (Image *) NULL; + (void) SetImageRegionMask(*image,ReadPixelMask, + (const RectangleInfo *) NULL,exception); + break; } - if (*option == '+') - break; - /* - Apply transformations to a selected region of the image. - */ - (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, - exception); - mogrify_image=CropImage(*image,®ion_geometry,exception); - if (mogrify_image == (Image *) NULL) - break; - region_image=(*image); - *image=mogrify_image; - mogrify_image=(Image *) NULL; + (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); + (void) SetImageRegionMask(*image,ReadPixelMask,&geometry,exception); break; } if (LocaleCompare("render",option+1) == 0) @@ -3388,20 +3369,6 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, ReplaceImageInListReturnLast(image,mogrify_image); i+=count; } - if (region_image != (Image *) NULL) - { - /* - Composite transformed region onto image. - */ - (void) SyncImageSettings(mogrify_info,*image,exception); - (void) CompositeImage(region_image,*image, - region_image->alpha_trait != UndefinedPixelTrait ? CopyCompositeOp : - OverCompositeOp,MagickTrue,region_geometry.x,region_geometry.y, - exception); - *image=DestroyImage(*image); - *image=region_image; - region_image = (Image *) NULL; - } /* Free resources. */ diff --git a/MagickWand/operation.c b/MagickWand/operation.c index ec1bc4511..14d3795f6 100644 --- a/MagickWand/operation.c +++ b/MagickWand/operation.c @@ -3026,14 +3026,6 @@ static MagickBooleanType CLISimpleOperatorImage(MagickCLI *cli_wand, } case 'r': { - if (LocaleCompare("rotational-blur",option+1) == 0) - { - flags=ParseGeometry(arg1,&geometry_info); - if ((flags & RhoValue) == 0) - CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); - new_image=RotationalBlurImage(_image,geometry_info.rho,_exception); - break; - } if (LocaleCompare("raise",option+1) == 0) { if (IsGeometry(arg1) == MagickFalse) @@ -3089,7 +3081,22 @@ static MagickBooleanType CLISimpleOperatorImage(MagickCLI *cli_wand, if (LocaleCompare("recolor",option+1) == 0) { CLIWandWarnReplaced("-color-matrix"); - (void) CLISimpleOperatorImage(cli_wand,"-color-matrix",arg1,NULL,exception); + (void) CLISimpleOperatorImage(cli_wand,"-color-matrix",arg1,NULL, + exception); + } + if (LocaleCompare("region",option+1) == 0) + { + if (IsGeometry(arg1) == MagickFalse) + CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); + if (*option == '+') + { + (void) SetImageRegionMask(_image,ReadPixelMask, + (const RectangleInfo *) NULL,_exception); + break; + } + (void) ParseGravityGeometry(_image,arg1,&geometry,_exception); + (void) SetImageRegionMask(_image,ReadPixelMask,&geometry,_exception); + break; } if (LocaleCompare("remap",option+1) == 0) { @@ -3158,6 +3165,14 @@ static MagickBooleanType CLISimpleOperatorImage(MagickCLI *cli_wand, new_image=RotateImage(_image,geometry_info.rho,_exception); break; } + if (LocaleCompare("rotational-blur",option+1) == 0) + { + flags=ParseGeometry(arg1,&geometry_info); + if ((flags & RhoValue) == 0) + CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); + new_image=RotationalBlurImage(_image,geometry_info.rho,_exception); + break; + } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 's':