Click here to Skip to main content
15,894,907 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.5K   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="-4.99999593705013" Canvas.Top="-4.99921017885208">
    <Canvas>
      <Path Data="M40.481863,36.421127A15.644737,8.3968935,0,1,1,9.1923885,36.421127A15.644737,8.3968935,0,1,1,40.481863,36.421127z" Stroke="{x:Null}" StrokeThickness="1" Opacity="0.20454545">
        <Path.Fill>
          <RadialGradientBrush Center="24.837126,36.421127" RadiusX="15.644737" RadiusY="15.644737" GradientOrigin="24.837126,36.421127" MappingMode="Absolute">
            <RadialGradientBrush.GradientStops>
              <GradientStop Color="#FF000000" Offset="0" />
              <GradientStop Color="#00000000" Offset="1" />
            </RadialGradientBrush.GradientStops>
            <RadialGradientBrush.Transform>
              <MatrixTransform Matrix="1,0,0,0.536723017692566,1.61471605976805E-15,16.8730602264404" />
            </RadialGradientBrush.Transform>
          </RadialGradientBrush>
        </Path.Fill>
        <Path.RenderTransform>
          <MatrixTransform Matrix="1.21446597576141,0,0,0.595457971096039,-6.16384601593018,16.3127498626709" />
        </Path.RenderTransform>
      </Path>
      <Canvas>
        <Path Data="M14.519136,38.5L32.524165,38.496094 32.524165,25.504468 40.519531,25.496656 23.374809,5.4992135 6.5285585,25.497284 14.52444,25.501074 14.519136,38.5z" Stroke="#FF3A7304" StrokeThickness="1.00000035762787" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeDashCap="Round" StrokeLineJoin="Round">
          <Path.Fill>
            <RadialGradientBrush Center="35.292667,20.494493" RadiusX="16.956199" RadiusY="16.956199" GradientOrigin="35.292667,20.494493" MappingMode="Absolute">
              <RadialGradientBrush.GradientStops>
                <GradientStop Color="#FF73D216" Offset="0" />
                <GradientStop Color="#FF4E9A06" Offset="1" />
              </RadialGradientBrush.GradientStops>
              <RadialGradientBrush.Transform>
                <MatrixTransform Matrix="1.87188497696357E-16,-0.843021988868713,1.02016794681549,2.26522815177606E-16,0.606436014175415,42.5861396789551" />
              </RadialGradientBrush.Transform>
            </RadialGradientBrush>
          </Path.Fill>
        </Path>
        <Path Data="M39.429889,24.993467L32.023498,25.005186 32.026179,37.998023 16.647623,37.98887C17.417545,19.64788,27.370272,26.995797,32.029282,16.341991L39.429889,24.993467z" Stroke="{x:Null}" StrokeThickness="1" Opacity="0.50802141">
          <Path.Fill>
            <RadialGradientBrush Center="15.987216,1.5350308" RadiusX="17.171415" RadiusY="17.171415" GradientOrigin="15.987216,1.5350308" MappingMode="Absolute">
              <RadialGradientBrush.GradientStops>
                <GradientStop Color="#FFFFFFFF" Offset="0" />
                <GradientStop Color="#00FFFFFF" Offset="1" />
              </RadialGradientBrush.GradientStops>
              <RadialGradientBrush.Transform>
                <MatrixTransform Matrix="3.74942707522362E-16,-2.04672908782959,-1.55761003494263,-2.8534041245803E-16,44.1155891418457,66.932746887207" />
              </RadialGradientBrush.Transform>
            </RadialGradientBrush>
          </Path.Fill>
        </Path>
        <Path Data="M15.520704,37.496094L31.522109,37.5 31.522109,24.50705 38.33892,24.491425 23.384644,7.0388396 8.6781173,24.495782 15.518018,24.501029 15.520704,37.496094z" Fill="{x:Null}" Stroke="#7BFFFFFF" StrokeThickness="1.00000035762787" Opacity="0.4812834" />
        <Canvas.RenderTransform>
          <MatrixTransform Matrix="-1,0,0,-1,47.0285606384277,43.999210357666" />
        </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