Skip to content

Commit 0113fe9

Browse files
author
Cristy
committed
...
1 parent b2f652a commit 0113fe9

File tree

2 files changed

+20
-26
lines changed

2 files changed

+20
-26
lines changed

‎MagickCore/draw-private.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ static inline void GetFillColor(const DrawInfo *draw_info,const ssize_t x,
3232
if (draw_info->fill_pattern == (Image *) NULL)
3333
{
3434
*fill=draw_info->fill;
35+
fill->alpha*=QuantumScale*draw_info->fill_alpha;
3536
return;
3637
}
3738
{
@@ -51,6 +52,7 @@ static inline void GetStrokeColor(const DrawInfo *draw_info,const ssize_t x,
5152
if (draw_info->stroke_pattern == (Image *) NULL)
5253
{
5354
*stroke=draw_info->stroke;
55+
stroke->alpha*=QuantumScale*draw_info->stroke_alpha;
5456
return;
5557
}
5658
{

‎MagickCore/draw.c‎

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2787,12 +2787,8 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
27872787
(void) DrawPatternPath(image,draw_info,token,
27882788
&graphic_context[n]->fill_pattern,exception);
27892789
else
2790-
{
2791-
status&=QueryColorCompliance(token,AllCompliance,
2792-
&graphic_context[n]->fill,exception);
2793-
if (graphic_context[n]->fill_alpha != OpaqueAlpha)
2794-
graphic_context[n]->fill.alpha=graphic_context[n]->fill_alpha;
2795-
}
2790+
status&=QueryColorCompliance(token,AllCompliance,
2791+
&graphic_context[n]->fill,exception);
27962792
break;
27972793
}
27982794
if (LocaleCompare("fill-opacity",keyword) == 0)
@@ -2808,8 +2804,8 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
28082804
StringToDouble(token,&next_token),0.0),1.0);
28092805
if (token == next_token)
28102806
ThrowPointExpectedException(token,exception);
2811-
graphic_context[n]->fill_alpha=(MagickRealType) (QuantumRange-
2812-
QuantumRange*(1.0-opacity));
2807+
if (fabs(opacity) >= DrawEpsilon)
2808+
graphic_context[n]->fill_alpha*=opacity;
28132809
break;
28142810
}
28152811
if (LocaleCompare("fill-rule",keyword) == 0)
@@ -3026,21 +3022,22 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
30263022
}
30273023
if (LocaleCompare("opacity",keyword) == 0)
30283024
{
3025+
double
3026+
opacity;
3027+
30293028
GetNextToken(q,&q,extent,token);
30303029
if (graphic_context[n]->clip_path != MagickFalse)
30313030
break;
30323031
factor=strchr(token,'%') != (char *) NULL ? 0.01 : 1.0;
3033-
graphic_context[n]->alpha=(Quantum) (QuantumRange*(1.0-
3034-
(QuantumScale*graphic_context[n]->alpha*(1.0-factor*
3035-
StringToDouble(token,&next_token)))));
3036-
graphic_context[n]->fill_alpha=QuantumRange*(1.0-(QuantumScale*
3037-
graphic_context[n]->fill_alpha*(1.0-factor*StringToDouble(token,
3038-
&next_token))));
3039-
graphic_context[n]->stroke_alpha=QuantumRange*(1.0-(QuantumScale*
3040-
graphic_context[n]->stroke_alpha*(1.0-factor*StringToDouble(token,
3041-
&next_token))));
3032+
opacity=MagickMin(MagickMax(factor*
3033+
StringToDouble(token,&next_token),0.0),1.0);
30423034
if (token == next_token)
30433035
ThrowPointExpectedException(token,exception);
3036+
if (fabs(opacity) >= DrawEpsilon)
3037+
{
3038+
graphic_context[n]->fill_alpha*=opacity;
3039+
graphic_context[n]->stroke_alpha*=opacity;
3040+
}
30443041
break;
30453042
}
30463043
status=MagickFalse;
@@ -3437,13 +3434,8 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
34373434
(void) DrawPatternPath(image,draw_info,token,
34383435
&graphic_context[n]->stroke_pattern,exception);
34393436
else
3440-
{
3441-
status&=QueryColorCompliance(token,AllCompliance,
3442-
&graphic_context[n]->stroke,exception);
3443-
if (graphic_context[n]->stroke_alpha != OpaqueAlpha)
3444-
graphic_context[n]->stroke.alpha=
3445-
graphic_context[n]->stroke_alpha;
3446-
}
3437+
status&=QueryColorCompliance(token,AllCompliance,
3438+
&graphic_context[n]->stroke,exception);
34473439
break;
34483440
}
34493441
if (LocaleCompare("stroke-antialias",keyword) == 0)
@@ -3566,8 +3558,8 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
35663558
StringToDouble(token,&next_token),0.0),1.0);
35673559
if (token == next_token)
35683560
ThrowPointExpectedException(token,exception);
3569-
graphic_context[n]->stroke_alpha=(MagickRealType) (QuantumRange-
3570-
QuantumRange*(1.0-opacity));
3561+
if (fabs(opacity) >= DrawEpsilon)
3562+
graphic_context[n]->stroke_alpha*=opacity;
35713563
break;
35723564
}
35733565
if (LocaleCompare("stroke-width",keyword) == 0)

0 commit comments

Comments
 (0)