C# 您可以将 XAML DrawingImage 转换回 SVG 进行编辑吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/946966/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can you convert a XAML DrawingImage back into an SVG for editting?
提问by Will Eddins
A design company made an application design in WPF 2 years ago, and now we're looking at changing the text on one of the images. No SVG files were provided, only the XAML code used, and the developer who worked on the project at the design company no longer works there. I know he used Expression Blend for the design.
2 年前,一家设计公司在 WPF 中进行了应用程序设计,现在我们正在考虑更改其中一个图像上的文本。没有提供 SVG 文件,只使用了 XAML 代码,并且在设计公司从事该项目的开发人员不再在那里工作。我知道他在设计中使用了 Expression Blend。
Any help with possible ways to convert XAML like this to SVGwould help, or even suggestions on what tools were used to generate this XAML.I saw this topic on converting XAML to SVG,but it looked like the tools only did conversions with SVGs originally converted in their tool.
任何有关将这样的 XAML 转换为 SVG 的可能方法的帮助都会有所帮助,甚至可以提供有关使用哪些工具生成此 XAML 的建议。我看到了有关将 XAML 转换为 SVG 的主题,但看起来这些工具只对最初在其工具中转换的SVG进行了转换。
A resource dictionary contains all the DrawingImage objects used to display images through the application. Here is one of the images we're looking at editting:
资源字典包含用于通过应用程序显示图像的所有 DrawingImage 对象。这是我们正在查看编辑的图像之一:
<DrawingImage x:Key="MotorControlBackground">
<DrawingImage.Drawing>
<DrawingGroup>
<DrawingGroup.Children>
<GeometryDrawing Brush="#FF466280" Geometry="F1 M -1138.47,3547.06C -1128.45,3557.08 -1112.14,3557.17 -1102.23,3547.25L -1024.29,3469.32L -1118.83,3374.78L -1214.79,3470.74L -1138.47,3547.06 Z ">
<GeometryDrawing.Pen>
<Pen Thickness="2.5" MiterLimit="2.75" Brush="#FF212121"/>
</GeometryDrawing.Pen>
</GeometryDrawing>
<GeometryDrawing Brush="#FFFFFFFF" Geometry="F1 M -1131.22,3533.84L -1138.68,3533.84L -1138.68,3532.34L -1135.91,3532.34L -1135.91,3521.89L -1138.68,3521.89L -1138.68,3520.4C -1137.64,3520.4 -1136.87,3520.25 -1136.38,3519.95C -1135.88,3519.65 -1135.6,3519.09 -1135.54,3518.26L -1133.99,3518.26L -1133.99,3532.34L -1131.22,3532.34L -1131.22,3533.84 Z "/>
<!-- ... Heavily shortened. Expect around 100 more lines here ... -->
<GeometryDrawing Geometry="F1 M -1175.94,3268.96L -1057.64,3475.82">
<GeometryDrawing.Pen>
<Pen Thickness="1.33333" MiterLimit="2.75" Brush="#88C7C7C7"/>
</GeometryDrawing.Pen>
</GeometryDrawing>
<GeometryDrawing Geometry="F1 M -1086.99,3255.92L -1147.5,3485.59">
<GeometryDrawing.Pen>
<Pen Thickness="1.33333" MiterLimit="2.75" Brush="#88C7C7C7"/>
</GeometryDrawing.Pen>
</GeometryDrawing>
<GeometryDrawing Brush="#FF0C407C" Geometry="F1 M -1025.41,3324.46C -1035.45,3304.48 -1051.7,3288.14 -1071.58,3278.06C -1085.54,3270.98 -1101.28,3266.99 -1117.91,3266.99C -1131.79,3266.99 -1145.06,3269.78 -1157.2,3274.82C -1182.66,3285.41 -1203.09,3305.94 -1213.63,3331.52C -1218.64,3343.71 -1221.42,3357.05 -1221.42,3371C -1221.42,3385.48 -1218.44,3399.29 -1213.06,3411.83C -1202.56,3436.34 -1182.94,3456.06 -1158.55,3466.61C -1146.05,3472.01 -1132.31,3475.02 -1117.91,3475.02C -1103.67,3475.02 -1090.09,3472.09 -1077.72,3466.81C -1052.97,3456.24 -1033.07,3436.25 -1022.56,3411.38C -1017.3,3398.95 -1014.39,3385.3 -1014.39,3371C -1014.39,3354.3 -1018.37,3338.48 -1025.41,3324.46 Z "/>
<!-- ... shortened some more ... -->
<GeometryDrawing Geometry="F1 M -1021.98,3324.73C -1021.98,3355.74 -1069.88,3368.43 -1117.29,3372.09C -1117.75,3372.13 -1120.57,3372.05 -1120.57,3372.05C -1167.81,3368.32 -1215.32,3355.62 -1215.32,3324.73C -1215.32,3286.57 -1170.4,3255.35 -1115.48,3255.35L -1121.82,3255.35C -1066.92,3255.35 -1021.98,3286.57 -1021.98,3324.73 Z ">
<GeometryDrawing.Brush>
<LinearGradientBrush StartPoint="0.548505,0.143509" EndPoint="0.548505,0.805904">
<LinearGradientBrush.GradientStops>
<GradientStop Color="#7FFFFFFF" Offset="0"/>
<GradientStop Color="#00FFFFFF" Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup.Children>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
采纳答案by Joseph
Inkscape (an SVG editor) has limited support for XAML.
Inkscape(一个 SVG 编辑器)对 XAML 的支持有限。
Last time I tried it, the XAML support wasn't perfect, but that was maybe 6 months ago. It may have improved since then.
我上次尝试时,XAML 支持并不完美,但那可能是在 6 个月前。从那以后它可能有所改善。
回答by Demir
It may be a solution to convert XAML to PNG by means of http://www.codeproject.com/Articles/422523/Convert-XAML-Vector-Graphic-to-PNGand then converting PNG to SVG. There are more options between PNG and SVG in terms of conversion. I have converted my XAML drawings into EMF with this approach.
通过http://www.codeproject.com/Articles/422523/Convert-XAML-Vector-Graphic-to-PNG将 XAML 转换为 PNG ,然后将 PNG 转换为 SVG可能是一种解决方案。在转换方面,PNG 和 SVG 之间有更多选择。我已经使用这种方法将我的 XAML 绘图转换为 EMF。