Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception: ColorBlend object that was set is not valid. When handling linear gradients. #964

Closed
nickdekesel opened this issue Mar 29, 2022 · 2 comments

Comments

@nickdekesel
Copy link

nickdekesel commented Mar 29, 2022

Description

Hi, I got the following exception when calling .Draw() on an SvgDocument that has a linear gradient in it:

System.ArgumentException: ColorBlend object that was set is not valid.Position's last element must be equal to 1.0. ColorBlend objects must be constructed with the same number of positions and color values. Positions must be between 0.0 and 1.0, 1.0 indicating the last element in the array.
   at System.Drawing.Drawing2D.LinearGradientBrush.set_InterpolationColors(ColorBlend value)
   at Svg.SvgLinearGradientServer.GetBrush(SvgVisualElement renderingElement, ISvgRenderer renderer, Single opacity, Boolean forStroke)
   at Svg.SvgDeferredPaintServer.GetBrush(SvgVisualElement styleOwner, ISvgRenderer renderer, Single opacity, Boolean forStroke)
   at Svg.SvgVisualElement.RenderFill(ISvgRenderer renderer)
   at Svg.SvgVisualElement.RenderFillAndStroke(ISvgRenderer renderer)
   at Svg.SvgVisualElement.RenderInternal(ISvgRenderer renderer, Action`1 renderMethod)
   at Svg.SvgVisualElement.RenderInternal(ISvgRenderer renderer, Boolean renderFilter)
   at Svg.SvgElement.RenderChildren(ISvgRenderer renderer)
   at Svg.SvgVisualElement.RenderInternal(ISvgRenderer renderer, Action`1 renderMethod)
   at Svg.SvgVisualElement.RenderInternal(ISvgRenderer renderer, Boolean renderFilter)
   at Svg.SvgElement.RenderChildren(ISvgRenderer renderer)
   at Svg.SvgVisualElement.RenderInternal(ISvgRenderer renderer, Action`1 renderMethod)
   at Svg.SvgVisualElement.RenderInternal(ISvgRenderer renderer, Boolean renderFilter)
   at Svg.SvgElement.RenderChildren(ISvgRenderer renderer)
   at Svg.SvgElement.Render(ISvgRenderer renderer)
   at Svg.SvgFragment.Render(ISvgRenderer renderer)
   at Svg.SvgDocument.Draw(ISvgRenderer renderer, ISvgBoundable boundable)
   at Svg.SvgDocument.Draw(Int32 rasterWidth, Int32 rasterHeight)

I see this issue has already been fixed before with the following PR:
#314

But it looks like it has been reintroduced by the following commit:
1067717

Used Versions

SVG version: 3.4.0
.NET 6.0
Windows

@H1Gdev
Copy link
Contributor

H1Gdev commented Mar 29, 2022

Does this issue also occur in latest version (3.4.1) ?
If so, please upload SVG file.

@nickdekesel
Copy link
Author

In 3.4.1 it is fixed.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants