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
/// </summary>
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)
......@@ -59,15 +63,20 @@ namespace Svg
float radius = this.Radius.ToDeviceValue(renderingElement);
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);
ColorBlend blend = base.GetColourBlend(renderingElement, opacity);
PathGradientBrush brush = new PathGradientBrush(path);
ColorBlend blend = base.GetColourBlend(renderingElement, opacity);
brush.InterpolationColors = blend;
brush.CenterPoint = new PointF(this.FocalX.ToDeviceValue(renderingElement), this.FocalY.ToDeviceValue(renderingElement, true));
return brush;
brush.InterpolationColors = blend;
brush.CenterPoint = new PointF(this.FocalX.ToDeviceValue(renderingElement), this.FocalY.ToDeviceValue(renderingElement, true));
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