Click here to Skip to main content
15,892,059 members
Articles / Desktop Programming / WPF

Convert XAML Vector Graphic to PNG

Rate me:
Please Sign up or sign in to vote.
4.87/5 (11 votes)
23 Oct 2012CPOL12 min read 74.4K   6.8K   43  
An introduction to the usage of vector graphics as a source of bitmap graphics.
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Canvas Canvas.Left="-8.978003693902" Canvas.Top="-3.33232094964853">
    <Canvas>
      <Canvas>
        <Path Data="F1M96.883576,112.57538C96.910956,108.51534 93.352176,105.19329 88.943586,105.16355 88.844646,105.16288 88.743726,105.16871 88.645636,105.17134L89.005826,51.774817 71.856336,51.659139 71.511676,102.75323C67.406946,104.0525 64.367096,108.33393 64.332636,113.44339 64.291046,119.60863 68.635286,124.64211 74.023566,124.67845 78.158216,124.70633 81.706876,121.78346 83.156876,117.63653 84.597266,119.00644 86.613016,119.86438 88.844326,119.87943 93.252906,119.90917 96.856176,116.63542 96.883576,112.57538z" Fill="#FFEEEEEC" Stroke="#FF888A85" StrokeThickness="4" StrokeMiterLimit="4" />
        <Path Data="F1M75.8125,55.6875L75.5,102.78125C75.487515,104.51028 74.365586,106.0356 72.71875,106.5625 70.485197,107.26949 68.367692,109.91875 68.34375,113.46875 68.314926,117.74185 71.158032,120.66791 74.0625,120.6875 76.283487,120.70248 78.399916,119.10119 79.375,116.3125 79.820021,115.02861 80.886337,114.05841 82.20643,113.73628 83.526524,113.41415 84.919876,113.78415 85.90625,114.71875 86.605546,115.38383 87.661192,115.86681 88.875,115.875 91.283711,115.89125 92.863437,114.2446 92.875,112.53125 92.88653,110.82154 91.323422,109.17256 88.90625,109.15625 88.769855,109.15533 88.733542,109.15669 88.75,109.15625 87.667575,109.18155 86.621121,108.76701 85.849655,108.00733 85.078189,107.24764 84.647605,106.20769 84.65625,105.125L84.96875,55.75 75.8125,55.6875z" Fill="{x:Null}" Stroke="#FFFFFFFF" StrokeThickness="4" StrokeMiterLimit="4" />
        <Path Data="F1M79.7585,83.737536C76.59193,83.787566 73.841888,83.638795 72.991217,82.857558 59.254721,70.242264 51.555791,42.555276 51.426891,23.44655 51.923551,-1.2850351 67.249286,-14.947355 79.7585,-14.928516 92.267715,-14.947355 107.59345,-1.2850351 108.09011,23.44655 107.96121,42.555276 100.26228,70.242264 86.525784,82.857558 85.675113,83.638795 82.925076,83.787566 79.7585,83.737536z" Stroke="#FF8F5902" StrokeThickness="4" StrokeMiterLimit="4">
          <Path.Fill>
            <LinearGradientBrush StartPoint="67.8109668967009,11.0573326105264" EndPoint="102.667509919691,18.3755103391205" MappingMode="Absolute" SpreadMethod="Pad">
              <LinearGradientBrush.GradientStops>
                <GradientStop Color="#FFE9B96E" Offset="0" />
                <GradientStop Color="#FFC17D11" Offset="1" />
              </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
          </Path.Fill>
        </Path>
        <Path Data="F1M79.75,-10.9375C70.158157,-10.951945 55.90163,0.41952793 55.4375,23.53125 55.557845,41.371807 63.391516,68.044196 75.28125,79.4375 75.418647,79.503505 75.611225,79.584232 75.96875,79.625 76.851982,79.725713 78.196067,79.773565 79.6875,79.75 79.729164,79.749349 79.770836,79.749349 79.8125,79.75 81.30373,79.773561 82.66908,79.726207 83.5625,79.625 83.912282,79.585376 84.103935,79.506672 84.25,79.4375 96.139718,68.041645 103.9734,41.246807 104.09375,23.40625 103.62969,0.29789561 89.341835,-10.951945 79.75,-10.9375z" Fill="{x:Null}" Stroke="#80FFFFFF" StrokeThickness="4" StrokeMiterLimit="4" Opacity="0.5" />
        <Canvas.RenderTransform>
          <MatrixTransform Matrix="0.323884397745132,-0.0867845714092255,0.0867845714092255,0.323884397745132,-5.5614595413208,13.1047010421753" />
        </Canvas.RenderTransform>
      </Canvas>
    </Canvas>
  </Canvas>
</Canvas>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Germany Germany
The Windows Presentation Foundation (WPF) and C# are among my favorites and so I developed Edi

and a few other projects on GitHub. I am normally an algorithms and structure type but WPF has such interesting UI sides that I cannot help myself but get into it.

https://de.linkedin.com/in/dirkbahle

Comments and Discussions