Giter VIP home page Giter VIP logo

svgimage's People

Contributors

avantbentlynevada avatar jogibear9988 avatar paulushub avatar tserious avatar williamgarner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

svgimage's Issues

[BUG]6.svg display failed in example

Describe the bug
6.svg display failed in example

To Reproduce
Steps to reproduce the behavior:

  1. Start example
  2. See error

Expected behavior
2

Screenshots
1

Additional context
Add any other context about the problem here.

Parametrize foreground color

Hello,

We use multiple svg files that constitute our application buttons. The brush is solid black for all svg files. Is it possible to render them with another colour depending of an application setting?

An example would be:

<svg1:SVGImage Source="/Example;component/Images/ButtonCenter.svg" Foreground="{DynamicResource PrimaryTextColorBrush}" />

Thank you,
Sebastien

Opacity is not Work.

I used SvgIconConberter, But Svg opacity(also fill-opacity) is not work.

Use Code
<Image Source="{Binding Contents.CurrentContents.Path, Converter={svg:SvgIconConverter}}" Stretch="Uniform"/>

Svg File Code

<svg version="1.1" id="레이어_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 40 40" style="enable-background:new 0 0 40 40;" xml:space="preserve"> <path style="fill:#2ac8e8;" d="M0.1996008,21 v 9.474734 c 0,4.737368 3.9600799,8.527262 8.9101796,8.527262 H 30.89022 c 4.9501,0 8.910179,-3.789894 8.910179,-8.527262 V 21" /> <path style="fill:rgb(42,200,232);fill-opacity:0.8;" d="M1,12 h 38 v 9 H 1 Z" /> <path style="fill:rgb(42,200,232);fill-opacity:0.5;" d="M1,7 h 38 v 5 H 1 Z" /> <path style="fill:rgb(42,200,232);fill-opacity:0.2;" d="M7,1h26c3.3,0,6,2.7,6,6l0,0l0,0H1l0,0l0,0C1,3.7,3.7,1,7,1z" /> <path style="fill:none;stroke:#464D62;" d="M9,0.5h22c4.7,0,8.5,3.8,8.5,8.5v22c0,4.7-3.8,8.5-8.5,8.5H9c-4.7,0-8.5-3.8-8.5-8.5V9C0.5,4.3,4.3,0.5,9,0.5z" /> </svg>

worng

[Wish] Expose the SVG object model

There are cases (see the example I posted here #9 ) where the application need to know more info from the object drawn inside the SVG.
For example you may need how many paths are described in the file, and also where they are so that you can draw an adorner over a specific path.
In other cases you may need to make small changes like changing the foreground, background or stroke of a specific object (line, rectangle, path, etc.)

I have no clue what is the effort, but I was wondering if you could expose the SVG object model, right after having parsed it, so that the application can avoid to re-parse it to get this info.
Thank you

Cannot display SVG-file when nesting in containers

I have a WPF-application where I want to display SVG-files.

In my application I have several DockPanels and StackPanels nested to get my layout as I want.
Deep down in the nested I have a SVGImage control.
But when the SVGImage control is nested in a container and the container contains some other controls, the SVGImage control disapears.

I have manage to reproduce the problem with three examples:

Working

<Border BorderBrush="Black" BorderThickness="0" CornerRadius="{Binding CornerRadius}">
    <DockPanel LastChildFill="True">
        <svg:SVGImage Source="/TestWpf;Component/Images/alert_triangle.svg" DockPanel.Dock="Left" />
    </DockPanel>
</Border>

Not wokring

<Border BorderBrush="Black" BorderThickness="0" CornerRadius="{Binding CornerRadius}">
    <DockPanel LastChildFill="True">
        <svg:SVGImage Source="/TestWpf;Component/Images/alert_triangle.svg" DockPanel.Dock="Left" />
        <StackPanel Orientation="Vertical" DockPanel.Dock="Right">
            <TextBlock Text="Foo" FontSize="20" />
            <TextBlock Text="Bar" FontSize="16" />
        </StackPanel>
    </DockPanel>
</Border>

Not wokring

<Border BorderBrush="Black" BorderThickness="0" CornerRadius="{Binding CornerRadius}">
    <DockPanel LastChildFill="True">
        <svg:SVGImage Source="/TestWpf;Component/Images/alert_triangle.svg" DockPanel.Dock="Left" />
        <TextBlock Text="ASDF" DockPanel.Dock="Right" />
    </DockPanel>
</Border>

What could be the problem?

SVGRender and RectangleShape

Comparing the handling of the RectangleShape in SVGRender, there was a change in the original code, in particular, the construction of the RectangleGeometry. The results of the change is that some of the original sample files, like computer-aj_aj_ashton_01.svg, are now throwing exceptions.
Simply reverting to the original construction code fixes this bug, but what issue was fixed with the current changes?

The original is

if (shape is ClipArtViewer.RectangleShape)
{
	ClipArtViewer.RectangleShape r = shape as ClipArtViewer.RectangleShape;
	RectangleGeometry rect = new RectangleGeometry(new Rect(r.X, r.Y, r.Width, r.Height));
	rect.RadiusX = r.RX;
	rect.RadiusY = r.RY;
	if (rect.RadiusX == 0 && rect.RadiusY > 0)
		rect.RadiusX = rect.RadiusY;
	grp.Children.Add(NewDrawingItem(shape, rect));
}

and the current version is

if (shape is RectangleShape)
{
    RectangleShape r = shape as RectangleShape;
    RectangleGeometry rect = new RectangleGeometry(new Rect(r.X < 0 ? 0 : r.X, r.Y < 0 ? 0 : r.Y, r.X < 0 ? r.Width + r.X : r.Width, r.Y < 0 ? r.Height + r.Y : r.Height));
    rect.RadiusX = r.RX;
    rect.RadiusY = r.RY;
    if (rect.RadiusX == 0 && rect.RadiusY > 0) rect.RadiusX = rect.RadiusY;
    var di = this.NewDrawingItem(shape, rect);
    AddDrawingToGroup(grp, shape, di);
    continue;
}

arcs with stroke-dasharray are drawn as filled circle segments

Hi,

I have some lines with dash-arrays in my drawing. In case of arcs they are not shown as dashed lines, but as a filled shape instead. In Inkscape they are shown as expected.
The SVG content is this:

<?xml version="1.0" standalone="no"?>
<svg viewBox="-690 3970 398 667" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" stroke-linecap="round" stroke-linejoin="round" fill-rule="evenodd" xml:space="preserve" >
<defs >
<clipPath id="clipId0" >
<path d="M-690,4637 -292,4637 -292,3970 -690,3970 z" />
</clipPath>
</defs>
<g clip-path="url(#clipId0)" fill="none" stroke="rgb(0,0,0)" stroke-width="0.0155343877" />
<g clip-path="url(#clipId0)" fill="none" stroke="rgb(0,0,0)" stroke-width="0.0155343877" >
<polyline points="-689,4239.5 -602.5,4239.5 " stroke-dasharray="6.350000,3.175000" />
<path d="M-602.5,4239.5  A86.5,86.5 0 0,0 -689,4153 " stroke-dasharray="6.350000,3.175000" />
<polyline points="-689,4265.5 -602.5,4265.5 " stroke-dasharray="6.350000,3.175000" />
<path d="M-689,4353  A88.2340395,88.2340395 0 0,0 -602.5,4265.5 " stroke-dasharray="6.350000,3.175000" />
</g>
</svg>

Greetings,
Jörg

Create strong-named assemblies

**Is your feature request related to a problem? Please describe.

When i use svgimage in my project,it return building error.

1

Svg will not display if SvgImage created dynamically

When control was created as a child elememnt of other control like this:

var img = new SVGImage.SVG.SVGImage()
                                    {
                                       ImageSource =  svgDrawing,
                                       VerticalContentAlignment = VerticalAlignment.Center,
                                       HorizontalContentAlignment = HorizontalAlignment.Center
                                    };
                                    Content = img;

The image will not show.
Maybe because when it was first measred, MeasureOverride returned Size.Zero.

can be fixed:

 protected override Size MeasureOverride(Size constraint)
        {
            //Size result = base.MeasureOverride(constraint);

            Size result = constraint;

            if (this.SizeType == eSizeType.SizeToContent)
            {
                if (this.m_drawing != null && !this.m_drawing.Bounds.Size.IsEmpty)
                    result = this.m_drawing.Bounds.Size;
            }

            if (constraint.Width > 0 && constraint.Width < result.Width)
                result.Width = constraint.Width;
            if (constraint.Height > 0 && constraint.Height < result.Height)
                result.Height = constraint.Height;

            return result;
        }

But I am not sure if this is the right way.

Does not work inside buttons?

I tried the following:

<Button Style="{StaticResource NumPadButton}" Command="{Binding TestCommand}" CommandParameter="Larry" >
	<svg1:SVGImage Grid.Row="0" Grid.Column="1" Source="/Resources/Images/testfile.svg" VerticalContentAlignment="Center"  HorizontalContentAlignment="Center"/>
</Button>

Also i tried to set a width, verticalalignments and so on..
After i switched from SVGImage to Image, and that works, im pretty sure, that the SVGImage does not work inside buttons.

Support patterns

See:

	<defs>
		<pattern id="stripePatternLeft"
			x="0" y="0" width="2" height="12"
			patternUnits="userSpaceOnUse"
			patternTransform="rotate(45)">
			<circle cx="1" cy="1" r="5" style="fill: #000" />
		</pattern>
		<pattern id="stripePatternRight"
			x="0" y="0" width="2" height="12"
			patternUnits="userSpaceOnUse"
			patternTransform="rotate(-45)">
			<circle cx="1" cy="1" r="5" style="fill: #000" />
		</pattern>
	</defs>

Keep transparent colors intact when overriding colors or offer an OverrideColor for Fill and Stroke separately

Is your feature request related to a problem? Please describe.
In my project, I am changing SVGImage stroke colors using the OverrideColor dependency property. However, when my SVGs consist of strokes without any fill color, both the fill color and the stroke is overridden by the OverrideColor. A temporary workaround is to change the stroke to a fill using the "Stroke to Path" feature of Inkscape. This solution is not optimal, because it discards information about the original stroke.

Describe the solution you'd like
This might be fixed by either keeping transparent colors intact when overriding colors, or by offering a separate "OverrideFillColor" property that can be used to override the fill color.

CustomBrushes Binding Problem

I have tried to bind the CustomBrush property SVGImage to a ToggleButton's foreground. The issue is described also here: https://stackoverflow.com/questions/66281489/ivalueconverter-not-called-on-relativesource-ancestor.

I also created this demo project: https://github.com/Doeharrrck/NavButton.

The desired behavior is that the icon should change it's color the same way as the text below on events like hover, press, check changed however it remains black.

The problem seems to be in the OnInitialized method of the SVGImage class. It works if I comment the last line in it so I have already a working solution.

However, it is not clear to me which feature I might have broken by commenting that line. I observed no negative consequences so far.

Padding from SVG is ignored by SVGImage control

Hi, I want to use the Google Material Icons. They have a padding to each side. This Padding is ignored by SVGImage control.
Is it possible to respect the padding?
Or can someone point me in the right direction to fix it by myself?

MicrosoftTeams-image

EDIT:
Here is the svg of the Home image:

<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48">
    <path d="M225.385-185.385h155.77v-245h197.69v245h155.77v-381.922L480-759.23 225.385-567.436v382.051Zm-45.384 45.384v-449.998L480-815.767l299.999 225.768v449.998H533.462v-245H426.538v245H180.001ZM480-472.615Z"/>
</svg>

Visibility bug starting from version 2.0.20

Hello, I tried to use 2.0.20 and 2.0.21 (nuget versions) in an application that overlaps several drawings inside an ItemsControl.
The app works well until (including) 2.0.16 but after this release, the drawings are not visible anymore.
Using the diagnostics tool in Visual Studio I can see the visibility of the SVGImage control is set to Visible, anyway there is nothing on screen.
As soon as I rollback the nuget package to 2.0.16, everything works again.

P.S. it would be useful if you could label the source code in GitHub with the version published on NuGet.

Thanks for your help.

Environment.CurrentDirectory prevents msix packaging

Projects using this library can't be packaged to msix installers because Environment.CurrentDirectory resolves to a system folder e.g. C:\Windows\SysWOW64 (for x64 builds).

Changing the file path resolution to use Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) should solve this issue

Images do not reload on OverrideColor change

When I change the OverrideColor property, the image does not get re-loaded with the new value.
I have to use a workaround that uses SetImage.

But I don't think that this is intentional?

Not supported text label ?

example aa.svg :

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:pmml2svg="https://sourceforge.net/projects/pmml2svg/"
     version="1.0"
     width="193.16113333333334px"
     height="65.108px"
     viewBox="0 0 193.16113333333334 65.108">
   <metadata>
      <pmml2svg:baseline-shift>10.549999999999997</pmml2svg:baseline-shift>
   </metadata>
   <g stroke="none"
      fill="#000000"
      text-rendering="optimizeLegibility"
      font-family="STIXGeneral,STIXSizeOneSym">
      <g xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
         style="font-family: STIXGeneral,STIXSizeOneSym; fill: ; background-color: transparent; ">
         <g style="font-family: STIXGeneral,STIXSizeOneSym; fill: ; background-color: transparent; ">
            <text style="font-family: STIXGeneral, STIXSizeOneSym; font-style: italic; fill: black; background-color: transparent; "
                  x="10.05"
                  y="54.55800000000001"
                  font-size="50">E</text>
            <text x="55.6389"
                  y="54.55800000000001"
                  font-size="50"
                  style="font-family: STIXGeneral, STIXSizeOneSym; fill: black; background-color: transparent; ">=</text>
            <g style="font-family: STIXGeneral,STIXSizeOneSym; fill: ; background-color: transparent; ">
               <text style="font-family: STIXGeneral, STIXSizeOneSym; font-style: italic; fill: black; background-color: transparent; "
                     x="103.7778"
                     y="54.55800000000001"
                     font-size="50">m</text>
               <text style="font-family: STIXGeneral, STIXSizeOneSym; font-style: italic; fill: black; background-color: transparent; "
                     x="139.8778"
                     y="54.55800000000001"
                     font-size="50">c</text>
               <text style="font-family: STIXGeneral, STIXSizeOneSym; fill: black; background-color: transparent; "
                     x="165.41113333333334"
                     y="33.998000000000005"
                     font-size="35.5">2</text>
            </g>
         </g>
      </g>
   </g>
</svg>

error

Default permission with FileSource

Hello jogibear9988,

Is it possible to specify the read file access when opening a file stream? By default, I suspect it opening the file in ReadWrite causing an exception when the application is located inside of program files.

From SVGImage/SVGImage/SVG/SVGImage.cs at line 63

Replacing

((SVGImage)d).SetImage(new FileStream(e.NewValue.ToString(), FileMode.Open));

To

((SVGImage)d).SetImage(new FileStream(e.NewValue.ToString(), FileMode.Open, FileAccess.Read));

Thank you!
Sebastien

global.json

Do you really need this file in your solution?

Suggestions - Evolving

Currently, developing and maintaining SharpVectors, but could contribute to this library too.
Have you made releases? Nuget package? Is there any problem with breaking interfaces to current users?

Please consider the following:

  1. A better namespace and .NET compliant naming.
    • Currently, namepace=SVGImage.SVG and assembly=DotNetProjects.SVGImage
    • And the control is name is SVGImage.
    • Also, you have DotNetProjects.SVGImage.SVG.FileLoaders
    • Something like SvgXaml, SvgWpf or SvgImages (then you have SvgXaml.IO, SvgXaml.Shapes, SvgXaml.Filters or Effects to include Clip and Mask, SvgXaml.Animations, SvgXaml.Css) etc.
    • And the control can be SvgImage (similar to SvgImageSource), a lightweight viewer for UWP applications.
    • Then the SVG class to SvgDocument or SvgModel etc
  2. Add an improved CSS library. Some lightweight parsers on Codeproject (maybe updated versions on Github)

Hopefully, the current users will contribute to this thread to evolve this library as a lightweight viewer of Svg files in WPF.

License of this repository is not under GNU

Hello Jochen,

Thanks for this repository. However, this repository is licensed under CPOL which is incompatible with the GNU General Public License and some other free software licenses, and inconsistent with the Open Source Definition. Can you please put this repository under GNU license so that it can be used according to Open Source definition?

Thanks,
Amit

[BUG] NullReferenceException when placing an SVGImage inside a DataGridCheckboxColumn

Describe the bug
When I place an SVGImage inside a DataGridCheckboxColumn and change the DataContext, my program crashes with a System.NullReferenceException inside the OnSourceChanged method of the SVGImage.

To Reproduce
Steps to reproduce the behavior:

  1. Create a User Control X with a Datagrid and a DataGridCheckboxColumn, place an SVGImage inside the DataGridCheckboxColumn and set its URI to a relative path that points to an existing SVG resource
  2. Create a ContentPresenter inside a different UserControl
  3. Programmatically change the Content of the ContentControl to different instances of the UserControl X

Expected behavior
The SVGImage is displayed correctly with its Source set to some existing URI, and invisible with the source set to Null or DependencyProperty.UnsetValue.

Additional context
The problem occurred with SVGImage 5.1.1 and .NET8

Control crashes loading a SVG file

I was loading a number of SVG files, testing some svg files. In some instances the application crashed, so I traced the problem to ShapeUil ParseTransformInternal. The problem was that the string had a leading space which resulted in returning a null to ParseTrasnform.
The solution is to call trim on value before any other calls are made within the function

Path only svg file not working

Hi,

I have no idea if this is the right fix, but it works for me. Given the following SVG:

<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M7.52 21.48C4.25 19.94 1.91 16.76 1.55 13H.05C.56 19.16 5.71 24 12 24l.66-.03-3.81-3.81-1.33 1.32zm.89-6.52c-.19 0-.37-.03-.52-.08-.16-.06-.29-.13-.4-.24-.11-.1-.2-.22-.26-.37-.06-.14-.09-.3-.09-.47h-1.3c0 .36.07.68.21.95.14.27.33.5.56.69.24.18.51.32.82.41.3.1.62.15.96.15.37 0 .72-.05 1.03-.15.32-.1.6-.25.83-.44s.42-.43.55-.72c.13-.29.2-.61.2-.97 0-.19-.02-.38-.07-.56-.05-.18-.12-.35-.23-.51-.1-.16-.24-.3-.4-.43-.17-.13-.37-.23-.61-.31.2-.09.37-.2.52-.33.15-.13.27-.27.37-.42.1-.15.17-.3.22-.46.05-.16.07-.32.07-.48 0-.36-.06-.68-.18-.96-.12-.28-.29-.51-.51-.69-.2-.19-.47-.33-.77-.43C9.1 8.05 8.76 8 8.39 8c-.36 0-.69.05-1 .16-.3.11-.57.26-.79.45-.21.19-.38.41-.51.67-.12.26-.18.54-.18.85h1.3c0-.17.03-.32.09-.45s.14-.25.25-.34c.11-.09.23-.17.38-.22.15-.05.3-.08.48-.08.4 0 .7.1.89.31.19.2.29.49.29.86 0 .18-.03.34-.08.49-.05.15-.14.27-.25.37-.11.1-.25.18-.41.24-.16.06-.36.09-.58.09H7.5v1.03h.77c.22 0 .42.02.6.07s.33.13.45.23c.12.11.22.24.29.4.07.16.1.35.1.57 0 .41-.12.72-.35.93-.23.23-.55.33-.95.33zm8.55-5.92c-.32-.33-.7-.59-1.14-.77-.43-.18-.92-.27-1.46-.27H12v8h2.3c.55 0 1.06-.09 1.51-.27.45-.18.84-.43 1.16-.76.32-.33.57-.73.74-1.19.17-.47.26-.99.26-1.57v-.4c0-.58-.09-1.1-.26-1.57-.18-.47-.43-.87-.75-1.2zm-.39 3.16c0 .42-.05.79-.14 1.13-.1.33-.24.62-.43.85-.19.23-.43.41-.71.53-.29.12-.62.18-.99.18h-.91V9.12h.97c.72 0 1.27.23 1.64.69.38.46.57 1.12.57 1.99v.4zM12 0l-.66.03 3.81 3.81 1.33-1.33c3.27 1.55 5.61 4.72 5.96 8.48h1.5C23.44 4.84 18.29 0 12 0z"/></svg>

No drawing is rendered because there is no Brush defined.

SVGRender.NewDrawingItem() does not update the GeometryDrawing.Brush. I needed to add the following:

if (item.Brush == null) { item.Brush = Brushes.Black; }
Just before
item.Geometry = geometry; return item;

Proposition to load an SVG from a path

Hello,

I get permission denied when I am trying to create a branch for a pull request.

I modified the OnSourceChanged event to support resource and file to be able to load a SVG from a file.

<svg1:SVGImage Source="/Example;ButtonUndo.svg" OverrideColor="blue"/>
<svg1:SVGImage Source="C:\\Example\\ButtonUndo.svg" OverrideColor="blue"/>

It works by changing this method

        static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            StreamResourceInfo resource = Application.GetResourceStream(new Uri(e.NewValue.ToString(), UriKind.Relative));
            ((SVGImage)d).SetImage(resource.Stream);
        }

To

        static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var source = e.NewValue.ToString();
            var stream = File.Exists(source)
                ? StreamFromFile(source)
                : StreamFromResource(source);

            ((SVGImage)d).SetImage(stream);
        }

        private static Stream StreamFromFile(string path)
        {
            return new FileStream(path, FileMode.Open);
        }

        private static Stream StreamFromResource(string uri)
        {
            var resource = Application.GetResourceStream(new Uri(uri, UriKind.Relative));
            return resource?.Stream;
        }

Do you think it is possible to add this change on the official version hosted on nuget?

Thank you!
Sebastien

SVGimage ignore transparent regions which are neccesary.

I have a SVG icon which contains a triangle at the right down corner and left other regions transparent.
when I show the SVG icon via SVGImage

<svg:SVGImage
     x:Name="ExpandPath"
     UriSource="/SegmentOperation;component/Svgs/Arrow_Right.svg" />

or SVGIcon

<Image x:Name="ExpandPath" Stretch="Uniform" 
     Source="{Binding Converter={svg:SvgIconConverter}, 
     ConverterParameter=/SegmentOperation;component/Svgs/Arrow_Down.svg, Mode=OneWay}"/>

The result is two triangles stretch to the full contents. the deliberated transparent regions are missing. but I need the two triangles stay at right down corner correctly. What do I missing?
thanks for your attention.

Wont work woth http uris

Using the nugget package like this:

<UserControl xmlns:svgc="clr-namespace:SVGImage.SVG;assembly=SVGImage">
      <svgc:SVGImage  Source="{Binding Path=IconSvgUri}"/>
</UserControl>

I get this error:

System.UriFormatException : 'A relative URI cannot be created because the 'uriString' parameter represents an absolute URI.'

Not rendering inside of a button

Hello,

Do you know why the image does not reder inside of a button?

        <Button>
            <svg1:SVGImage Source="/Example;component/Images/PhotoEditor/ButtonDeleteImage.svg" OverrideColor="blue"/>
        </Button>

Thank you!
Sebastien

Parts of the SVG are rendered in black when rendered first time

I have a simple svg drawing which contains a white curve on orange background. In my code, I draw the image five times in consecutive rows of the same WPF Grid. The first time the image is rendered, the area below the curve is filled in black. The code of the image looks like this (so there is no explicit fill-rule applied):

<svg width="88" height="88" viewBox="0 0 88 88" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect width="88" height="88" rx="8" fill="#FF8021"/> <path d="M8 60.5744H10.0297L10.847 38.9127C11.3892 32.6765 11.3892 27.8335 13.9651 27.8335L33.4391 27.8335C33.6646 32.2401 38.5892 46.8056 40.9434 50.7029C46.3662 59.6804 56.1392 60.8215 62.499 60.5744H79.8518" stroke="#FFBF90" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/> </svg>

The version used is 4.1.86

Suggestion to make appVeyor build

Hello,

I tried to create a pull request but I do not have the permission. I suspect the automatic appVeyor build does not support C#7 feature.

Do you think those replacement lines will fix the automatic build then it will generate a new NuGet version?

Thank you!

1. replace line 170 from SVGRender.cs

if (shape is AnimateTransform animateTransform)

by

if (shape is AnimateTransform)
{
    var animateTransform = shape as AnimateTransform;

2. replace line 187 from SVGRender.cs

else if (shape is Animate animate)

by

else if (shape is Animate)
{
    var animate = shape as Animate;

identical polylines not equally drawn, if coordinates are large

Hi,
I have two SVG files which look the same in Inkscape but are not drawn equally in SVGImage. The wrong one contains large coordinates.

This is the failing view:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
  viewBox="2506744 5624642 18.459999 7.8600001"
   version="1.1"
   stroke-linecap="round"
   stroke-linejoin="round"
   fill-rule="evenodd"
   xml:space="preserve"
   id="svg29"
   sodipodi:docname="Vermaßung20001_200.svg"
   width="18.459999"
   height="7.8600001"
   inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
   id="namedview31"
   pagecolor="#ffffff"
   bordercolor="#666666"
   borderopacity="1.0"
   inkscape:pageshadow="2"
   inkscape:pageopacity="0.0"
   inkscape:pagecheckerboard="0"
   showgrid="false"
   inkscape:zoom="21.825"
   inkscape:cx="-5.2004582"
   inkscape:cy="19.839633"
   inkscape:window-width="1918"
   inkscape:window-height="1520"
   inkscape:window-x="1913"
   inkscape:window-y="329"
   inkscape:window-maximized="0"
   inkscape:current-layer="svg29" />
<defs
   id="defs5">
<clipPath
   id="clipId0">
<path
   d="m 2506744,5624682 h 49 v -40 h -49 z"
   id="path2" />
</clipPath>
</defs>
<g
   clip-path="url(#clipId0)"
   fill="none"
   stroke="#000000"
   stroke-width="0.01"
   id="g7"
   transform="translate(-25.565,-0.145)" />
<g
   clip-path="url(#clipId0)"
   fill="#00ff00"
   stroke="#00ff00"
   stroke-width="0.01"
   id="g11"
   transform="translate(-25.565,-0.145)">
<text
   transform="matrix(0.13096062,-0.05489367,0.07731503,0.18445158,2506778.5,5624646.1)"
   font-family="Txt, sans-serif"
   font-size="1.38842px"
   id="text9">19.81</text>
</g>
<g
   clip-path="url(#clipId0)"
   fill="none"
   stroke="#00ff00"
   stroke-width="0.01"
   id="g27"
   transform="translate(-25.565,-0.145)">
<polyline
   points="2506787.93,5624642.25 2506769.66,5624649.9 "
   id="polyline13" />
<polyline
   points="2506787.75,5624642.32 2506788.02,5624642.21 "
   id="polyline15" />
<polyline
   points="2506787.97,5624642.34 2506787.89,5624642.15 "
   id="polyline17" />
<polyline
   points="2506787.9,5624642.32 2506787.96,5624642.17 "
   id="polyline19" />
<polyline
   points="2506769.84,5624649.83 2506769.57,5624649.94 "
   id="polyline21" />
<polyline
   points="2506769.62,5624649.81 2506769.7,5624650 "
   id="polyline23" />
<polyline
   points="2506769.69,5624649.82 2506769.63,5624649.98 "
   id="polyline25" />
</g>
</svg>

while this on works fine;

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   viewBox="44 42 18.459999 7.8600001"
   version="1.1"
   stroke-linecap="round"
   stroke-linejoin="round"
   fill-rule="evenodd"
   xml:space="preserve"
   id="svg29"
   sodipodi:docname="Vermaßung20001_200.svg"
   width="18.459999"
   height="7.8600001"
   inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
   id="namedview31"
   pagecolor="#ffffff"
   bordercolor="#666666"
   borderopacity="1.0"
   inkscape:pageshadow="2"
   inkscape:pageopacity="0.0"
   inkscape:pagecheckerboard="0"
   showgrid="false"
   inkscape:zoom="21.825"
   inkscape:cx="-5.2004582"
   inkscape:cy="19.839633"
   inkscape:window-width="1918"
   inkscape:window-height="1520"
   inkscape:window-x="1913"
   inkscape:window-y="329"
   inkscape:window-maximized="0"
   inkscape:current-layer="svg29" />
<defs
   id="defs5">
<clipPath
   id="clipId0">
<path
   d="m 44,82 h 49 v -40 h -49 z"
   id="path2" />
</clipPath>
</defs>
<g
   clip-path="url(#clipId0)"
   fill="none"
   stroke="#000000"
   stroke-width="0.01"
   id="g7"
   transform="translate(-25.565,-0.145)" />
<g
   clip-path="url(#clipId0)"
   fill="#00ff00"
   stroke="#00ff00"
   stroke-width="0.01"
   id="g11"
   transform="translate(-25.565,-0.145)">
<text
   transform="matrix(0.13096062,-0.05489367,0.07731503,0.18445158,78.5,46.1)"
   font-family="Txt, sans-serif"
   font-size="1.38842px"
   id="text9">19.81</text>
</g>
<g
   clip-path="url(#clipId0)"
   fill="none"
   stroke="#00ff00"
   stroke-width="0.01"
   id="g27"
   transform="translate(-25.565,-0.145)">
<polyline
   points="87.93,42.25 69.66,49.9 "
   id="polyline13" />
<polyline
   points="87.75,42.32 88.02,42.21 "
   id="polyline15" />
<polyline
   points="87.97,42.34 87.89,42.15 "
   id="polyline17" />
<polyline
   points="87.9,42.32 87.96,42.17 "
   id="polyline19" />
<polyline
   points="69.84,49.83 69.57,49.94 "
   id="polyline21" />
<polyline
   points="69.62,49.81 69.7,50 "
   id="polyline23" />
<polyline
   points="69.69,49.82 69.63,49.98 "
   id="polyline25" />
</g>
</svg>

Greetings,
Jörg

Updates: Refactoring and bug fixes

@jogibear9988 I have made a number of changes to the codes. The changes are available in my fork below;

Refactoring and bug fixes

  • Removed the Design project
  • Removed the VS2017 project files
  • Removed .NETCore 3.0
  • Removed DotnetProjects namespaces, simplified the namespaces
  • Removed the Attribute class, since it is the same as StyleItem class
  • Added DocFX projects for building documentations
  • Updates to the Nuget package: included Xml-docs, readme etc.
  • Fixed null exception in the ViewBoxToSizeNoStretch support when using Drawing sources.

NOTE: The changes will results in breakings changes in the API, as

  • I have removed the DotnetProjects namespaces (for simplicity and documentation),
  • Made the utility classes internal. and
  • Eliminated most of the nested classes for simplicity.

But there is no breaking change in binary output, and any current project using only the controls will work as usual.

You can check the changes, if you like them, I will add support for .NET6/7 and create a PR.

The output of the document is shown below (others can contribute to improve it):
NOTE: You preview the current documentation deployed here with GitHub action.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.