Skip to content

Commit ae0dc6b

Browse files
author
Lukas Kirschner
committed
Merged paulushub's fixes
1 parent 5c154df commit ae0dc6b

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

Source/SVGImage/SVG/SVGRender.cs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,24 @@ private GeometryDrawing NewDrawingItem(Shape shape, Geometry geometry)
121121
Stroke stroke = shape.Stroke;
122122
if (stroke != null)
123123
{
124-
if(OverrideStrokeWidth.HasValue)
124+
var strokeWidth = stroke.Width;
125+
if (OverrideStrokeWidth.HasValue)
125126
{
126-
stroke.Width = OverrideStrokeWidth.Value;
127+
strokeWidth = OverrideStrokeWidth.Value;
127128
}
128129
var brush = stroke.StrokeBrush(this.SVG, this, shape, shape.Opacity, geometry.Bounds);
129130
if (OverrideColor != null)
130131
brush = new SolidColorBrush(Color.FromArgb((byte)(255 * shape.Opacity),
131132
OverrideColor.Value.R, OverrideColor.Value.G, OverrideColor.Value.B));
132133
if (OverrideStrokeColor != null)
133-
brush = new SolidColorBrush(Color.FromArgb((byte)(255 * shape.Opacity),
134+
brush = new SolidColorBrush(Color.FromArgb((byte)(255 * shape.Opacity),
134135
OverrideStrokeColor.Value.R, OverrideStrokeColor.Value.G, OverrideStrokeColor.Value.B));
135-
item.Pen = new Pen(brush, stroke.Width);
136+
item.Pen = new Pen(brush, strokeWidth);
136137
if (stroke.StrokeArray != null)
137138
{
138139
item.Pen.DashCap = PenLineCap.Flat;
139140
DashStyle ds = new DashStyle();
140-
double scale = 1 / stroke.Width;
141+
double scale = 1 / strokeWidth;
141142
foreach (var dash in stroke.StrokeArray) ds.Dashes.Add(dash * scale);
142143
item.Pen.DashStyle = ds;
143144
}
@@ -177,7 +178,7 @@ private GeometryDrawing NewDrawingItem(Shape shape, Geometry geometry)
177178
item.Brush = new SolidColorBrush(Color.FromArgb((byte)(255 * shape.Opacity),
178179
OverrideColor.Value.R, OverrideColor.Value.G, OverrideColor.Value.B));
179180
if (OverrideFillColor != null)
180-
item.Brush = new SolidColorBrush(Color.FromArgb((byte)(255 * shape.Opacity),
181+
item.Brush = new SolidColorBrush(Color.FromArgb((byte)(255 * shape.Opacity),
181182
OverrideFillColor.Value.R, OverrideFillColor.Value.G, OverrideFillColor.Value.B));
182183
GeometryGroup g = new GeometryGroup();
183184
g.FillRule = FillRule.Nonzero;
@@ -187,12 +188,15 @@ private GeometryDrawing NewDrawingItem(Shape shape, Geometry geometry)
187188
else if (shape.Fill != null)
188189
{
189190
item.Brush = shape.Fill.FillBrush(this.SVG, this, shape, shape.Opacity, geometry.Bounds);
190-
if (OverrideColor != null)
191-
item.Brush = new SolidColorBrush(Color.FromArgb((byte)(255 * shape.Opacity),
192-
OverrideColor.Value.R, OverrideColor.Value.G, OverrideColor.Value.B));
193-
if (OverrideFillColor != null && shape.Fill.Opacity > 0.0)
194-
item.Brush = new SolidColorBrush(Color.FromArgb((byte)(255 * shape.Opacity),
195-
OverrideFillColor.Value.R, OverrideFillColor.Value.G, OverrideFillColor.Value.B));
191+
if (item.Brush != null)
192+
{
193+
if (OverrideColor != null)
194+
item.Brush = new SolidColorBrush(Color.FromArgb((byte)(255 * shape.Opacity),
195+
OverrideColor.Value.R, OverrideColor.Value.G, OverrideColor.Value.B));
196+
if (OverrideFillColor != null)
197+
item.Brush = new SolidColorBrush(Color.FromArgb((byte)(255 * shape.Opacity),
198+
OverrideFillColor.Value.R, OverrideFillColor.Value.G, OverrideFillColor.Value.B));
199+
}
196200
GeometryGroup g = new GeometryGroup();
197201
g.FillRule = FillRule.Nonzero;
198202
if (shape.Fill.FillRule == Fill.eFillRule.evenodd) g.FillRule = FillRule.EvenOdd;

0 commit comments

Comments
 (0)