Commit 90b1d42b authored by owaits's avatar owaits
Browse files

Applies default values of 50% for radial gradient cx,cy and r. This prevents...

Applies default values of 50% for radial gradient cx,cy and r. This prevents an OutOfMemory exception when loading svg files without these parameters specified.
parent 302ca29e
...@@ -49,6 +49,10 @@ namespace Svg ...@@ -49,6 +49,10 @@ namespace Svg
/// </summary> /// </summary>
public SvgRadialGradientServer() public SvgRadialGradientServer()
{ {
//Apply default values of 50% to cX,cY and r
CenterX = new SvgUnit(SvgUnitType.Percentage, 50);
CenterY = new SvgUnit(SvgUnitType.Percentage, 50);
Radius = new SvgUnit(SvgUnitType.Percentage, 50);
} }
public override Brush GetBrush(SvgVisualElement renderingElement, float opacity) public override Brush GetBrush(SvgVisualElement renderingElement, float opacity)
...@@ -59,7 +63,9 @@ namespace Svg ...@@ -59,7 +63,9 @@ namespace Svg
float radius = this.Radius.ToDeviceValue(renderingElement); float radius = this.Radius.ToDeviceValue(renderingElement);
RectangleF boundingBox = (this.GradientUnits == SvgCoordinateUnits.ObjectBoundingBox) ? renderingElement.Bounds : renderingElement.OwnerDocument.GetDimensions(); RectangleF boundingBox = (this.GradientUnits == SvgCoordinateUnits.ObjectBoundingBox) ? renderingElement.Bounds : renderingElement.OwnerDocument.GetDimensions();
path.AddEllipse(left-radius, top-radius, radius*2, radius*2); if (radius > 0)
{
path.AddEllipse(left - radius, top - radius, radius * 2, radius * 2);
PathGradientBrush brush = new PathGradientBrush(path); PathGradientBrush brush = new PathGradientBrush(path);
ColorBlend blend = base.GetColourBlend(renderingElement, opacity); ColorBlend blend = base.GetColourBlend(renderingElement, opacity);
...@@ -69,5 +75,8 @@ namespace Svg ...@@ -69,5 +75,8 @@ namespace Svg
return brush; return brush;
} }
return null;
}
} }
} }
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment