Skip to content

Invalid xaml created #311

Description

@Pollyfun

When using some svg files as input, the xaml is invalid.
Example: https://upload.wikimedia.org/wikipedia/commons/4/48/Complex_Color_map.svg

 svgFilePath = @"Complex_Color_map.svg";

 var settings = new WpfDrawingSettings
 {
     IncludeRuntime = false,
     TextAsGeometry = true
 };

using (var reader = new FileSvgReader(settings))
{
     DrawingGroup drawingGroup = reader.Read(svgFilePath);
     string xaml;
     using (var stringWriter = new StringWriter())
     using (var xmlWriter = new XmlTextWriter(stringWriter) { Formatting = Formatting.Indented })
     {
         XamlWriter.Save(drawingGroup, xmlWriter);
         xaml = stringWriter.ToString();
     }

     string path = Path.Combine(@"D:\_Cases\SVG\", Path.GetFileNameWithoutExtension(svgFilePath) + ".xaml");
     File.WriteAllText(path, xaml);
 }

Complex_Color_map.xaml contains:
<BitmapImage BaseUri="{x:Null}" CreateOptions="PreservePixelFormat" />

This is invalid and later cause exceptions when the xaml is used (for example in XamlReader.Load())

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions