From 4ebd3147dac35df834557ab49c621b6d18492812 Mon Sep 17 00:00:00 2001 From: Cristy Date: Thu, 25 Apr 2024 20:47:05 -0400 Subject: [PATCH] respect gradient bounding box --- magick/draw.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/magick/draw.c b/magick/draw.c index 14873ee37..16be80dcb 100644 --- a/magick/draw.c +++ b/magick/draw.c @@ -2005,6 +2005,7 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image, bounding_box; ssize_t + height, y; /* @@ -2025,11 +2026,12 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image, exception=(&image->exception); GetMagickPixelPacket(image,&zero); image_view=AcquireAuthenticCacheView(image,exception); + height=(size_t) (bounding_box.y+bounding_box.height); #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp parallel for schedule(static) shared(status) \ - magick_number_threads(image,image,(size_t) (bounding_box.height-bounding_box.y),1) + magick_number_threads(image,image,height,1) #endif - for (y=bounding_box.y; y < (ssize_t) bounding_box.height; y++) + for (y=bounding_box.y; y < (ssize_t) height; y++) { double alpha, @@ -2048,12 +2050,13 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image, ssize_t i, j, + width, x; if (status == MagickFalse) continue; q=GetCacheViewAuthenticPixels(image_view,bounding_box.x,y,(size_t) - (bounding_box.width-bounding_box.x),1,exception); + bounding_box.width,1,exception); if (q == (PixelPacket *) NULL) { status=MagickFalse; @@ -2065,7 +2068,8 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image, offset=GetStopColorOffset(gradient,0,y); if (gradient->type != RadialGradient) offset*=PerceptibleReciprocal(length); - for (x=bounding_box.x; x < (ssize_t) bounding_box.width; x++) + width=(size_t) (bounding_box.x+bounding_box.width); + for (x=bounding_box.x; x < (ssize_t) width; x++) { SetMagickPixelPacket(image,q,indexes+x,&pixel); switch (gradient->spread)