Click here to Skip to main content
15,886,026 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.3K   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="-5" Canvas.Top="-4.55231146257217">
    <Canvas>
      <Path Data="M44.42857,38.57143A19.714285,6.5714288,0,1,1,5,38.57143A19.714285,6.5714288,0,1,1,44.42857,38.57143z" Stroke="{x:Null}" StrokeThickness="1" Opacity="0.53164557">
        <Path.Fill>
          <RadialGradientBrush Center="24.714285,38.57143" RadiusX="19.714285" RadiusY="19.714285" GradientOrigin="24.714285,38.57143" MappingMode="Absolute">
            <RadialGradientBrush.GradientStops>
              <GradientStop Color="#FF000000" Offset="0" />
              <GradientStop Color="#00000000" Offset="1" />
            </RadialGradientBrush.GradientStops>
            <RadialGradientBrush.Transform>
              <MatrixTransform Matrix="1,0,0,0.333332985639572,0,25.7142906188965" />
            </RadialGradientBrush.Transform>
          </RadialGradientBrush>
        </Path.Fill>
      </Path>
      <Path Data="M39.774755,19.008621A8.6620579,8.6620579,0,1,1,22.45064,19.008621A8.6620579,8.6620579,0,1,1,39.774755,19.008621z" Stroke="#FF9C8C0A" StrokeThickness="0.480044037103653" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeDashCap="Round" StrokeLineJoin="Round" StrokeMiterLimit="4">
        <Path.Fill>
          <RadialGradientBrush Center="29.288071,15.720984" RadiusX="8.9020796" RadiusY="8.9020796" GradientOrigin="29.288071,15.720984" MappingMode="Absolute">
            <RadialGradientBrush.GradientStops>
              <GradientStop Color="#FFFFFCDE" Offset="0" />
              <GradientStop Color="#FFF6E76A" Offset="0.644859790802002" />
              <GradientStop Color="#FFFFB738" Offset="1" />
            </RadialGradientBrush.GradientStops>
          </RadialGradientBrush>
        </Path.Fill>
        <Path.RenderTransform>
          <MatrixTransform Matrix="2.08314204216003,0,0,2.08314204216003,-40.5471496582031,-16.4922409057617" />
        </Path.RenderTransform>
      </Path>
      <Path Data="M39.774755,19.008621A8.6620579,8.6620579,0,1,1,22.45064,19.008621A8.6620579,8.6620579,0,1,1,39.774755,19.008621z" Fill="{x:Null}" Stroke="#ADFFFFFF" StrokeThickness="0.505106270313263" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeDashCap="Round" StrokeLineJoin="Round" StrokeMiterLimit="4" Opacity="0.67721519">
        <Path.RenderTransform>
          <MatrixTransform Matrix="1.9797819852829,0,0,1.9797819852829,-37.3312797546387,-14.5274600982666" />
        </Path.RenderTransform>
      </Path>
      <Canvas>
        <Path Data="F1M37.284637,24.719966C34.26817,29.944639 30.741134,33.710005 24.462492,33.710005 18.362475,33.710005 13.896955,29.370308 11.110016,24.543189 13.659429,27.599109 17.392948,31.109501 24.197327,31.109501 32.327531,31.109501 33.749103,28.202646 37.284637,24.719966z" Fill="#5CFFFFFF" Stroke="{x:Null}" StrokeThickness="1" Opacity="0.35999998" />
        <Path Data="F1M37.284637,24.012862C34.26817,29.237535 30.741134,33.002901 24.462492,33.002901 18.362475,33.002901 13.896955,28.663204 11.110016,23.836085 13.659429,26.892005 17.392948,30.402397 24.197327,30.402397 32.327531,30.402397 33.749103,27.495542 37.284637,24.012862z" Stroke="{x:Null}" StrokeThickness="1">
          <Path.Fill>
            <RadialGradientBrush Center="25.0527,39.5928" RadiusX="15.7572" RadiusY="15.7572" GradientOrigin="25.0527,39.5928" MappingMode="Absolute">
              <RadialGradientBrush.GradientStops>
                <GradientStop Color="#FF777777" Offset="0" />
                <GradientStop Color="#FF000000" Offset="1" />
              </RadialGradientBrush.GradientStops>
              <RadialGradientBrush.Transform>
                <MatrixTransform Matrix="1.25,0,0,1.25,-6.47944593429565,-13.3721103668213" />
              </RadialGradientBrush.Transform>
            </RadialGradientBrush>
          </Path.Fill>
        </Path>
        <Canvas.RenderTransform>
          <MatrixTransform Matrix="0.969371974468231,0.245598003268242,-0.245598003268242,0.969371974468231,6.45693683624268,-5.23000383377075" />
        </Canvas.RenderTransform>
      </Canvas>
      <Path Data="F1M31.042065,17.714134C31.042065,20.214134 29.917065,22.214134 28.542065,22.214134 27.167065,22.214134 26.042065,20.214134 26.042065,17.714134 26.042065,15.214134 27.167065,13.214134 28.542065,13.214134 29.917065,13.214134 31.042065,15.214134 31.042065,17.714134z" Fill="#5CFFFFFF" Stroke="{x:Null}" StrokeThickness="1" Opacity="0.35999998" />
      <Path Data="F1M31.042065,17.089134C31.042065,19.589134 29.917065,21.589134 28.542065,21.589134 27.167065,21.589134 26.042065,19.589134 26.042065,17.089134 26.042065,14.589134 27.167065,12.589134 28.542065,12.589134 29.917065,12.589134 31.042065,14.589134 31.042065,17.089134z" Fill="#FF000000" Stroke="{x:Null}" StrokeThickness="1" />
      <Path Data="F1M15.924926,17.535184C17.28643,14.190727 20.768376,14.102908 21.99369,17.42035 19.832621,15.70722 17.845598,16.200617 15.924926,17.535184z" Fill="#FF000000" Stroke="{x:Null}" StrokeThickness="1" />
    </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