Click here to Skip to main content
15,885,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.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="-4.00158119847775" Canvas.Top="-3.00156483054161">
    <Canvas>
      <Path Data="F1M40.5,40.9375A17.1875,5.4375,0,1,1,6.125,40.9375A17.1875,5.4375,0,1,1,40.5,40.9375z" Stroke="{x:Null}" StrokeThickness="1" Opacity="0.36931817">
        <Path.Fill>
          <RadialGradientBrush Center="23.3125,40.9375" RadiusX="17.1875" RadiusY="17.1875" GradientOrigin="23.3125,40.9375" MappingMode="Absolute">
            <RadialGradientBrush.GradientStops>
              <GradientStop Color="#FF000000" Offset="0" />
              <GradientStop Color="#00000000" Offset="1" />
            </RadialGradientBrush.GradientStops>
            <RadialGradientBrush.Transform>
              <MatrixTransform Matrix="1,0,0,0.316363990306854,0,27.9863605499268" />
            </RadialGradientBrush.Transform>
          </RadialGradientBrush>
        </Path.Fill>
        <Path.RenderTransform>
          <MatrixTransform Matrix="1,0,0,1,-0.125,0.625" />
        </Path.RenderTransform>
      </Path>
      <Canvas>
        <Canvas>
          <Path Data="F1M23,3C15.599034,8.5765861 4,12 4,12 7,37.75 23.375,44 23.375,44 23.375,44 39.5,37.5 42.75,11.625 42.75,11.625 28.75,6.5 23,3z" Stroke="#FF888A85" StrokeThickness="0.996870338916779" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeDashCap="Round" StrokeLineJoin="Round" StrokeMiterLimit="4">
            <Path.Fill>
              <RadialGradientBrush Center="22.75,10.250003" RadiusX="19.875" RadiusY="19.875" GradientOrigin="22.75,10.250003" MappingMode="Absolute">
                <RadialGradientBrush.GradientStops>
                  <GradientStop Color="#FFF0F1EE" Offset="0" />
                  <GradientStop Color="#FFD5D9D1" Offset="1" />
                </RadialGradientBrush.GradientStops>
                <RadialGradientBrush.Transform>
                  <MatrixTransform Matrix="1.61654794216156,-3.84584389992579E-26,-2.93909999674138E-25,1.70805096626282,-14.0264701843262,-8.00752258300781" />
                </RadialGradientBrush.Transform>
              </RadialGradientBrush>
            </Path.Fill>
          </Path>
          <Path Data="F1M23.023587,4.289309C16.08809,9.5151669 5.218554,12.723272 5.218554,12.723272 8.029875,36.853777 23.335694,42.710696 23.335694,42.710696 23.335694,42.710696 38.485853,36.619501 41.53145,12.371857 41.53145,12.371857 28.411952,7.5691835 23.023587,4.289309z" Fill="{x:Null}" Stroke="#FFFFFFFF" StrokeThickness="0.996870458126068" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeDashCap="Round" StrokeLineJoin="Round" StrokeMiterLimit="4" />
          <Path Data="F1M22.88299,7L22.88299,40C22.88299,40 10.564533,34.740576 6.8829905,14 12.13299,13.125 22.88299,7 22.88299,7z" Stroke="{x:Null}" StrokeThickness="1">
            <Path.Fill>
              <RadialGradientBrush Center="17.62042,21.610504" RadiusX="7.9999997" RadiusY="7.9999997" GradientOrigin="17.62042,21.610504" MappingMode="Absolute">
                <RadialGradientBrush.GradientStops>
                  <GradientStop Color="#FFEDEEEC" Offset="0" />
                  <GradientStop Color="#FFBABDB6" Offset="1" />
                </RadialGradientBrush.GradientStops>
                <RadialGradientBrush.Transform>
                  <MatrixTransform Matrix="4.07299423217773,8.88178525579244E-16,-6.26826827341284E-16,2.87449193000793,-48.884880065918,-43.2154197692871" />
                </RadialGradientBrush.Transform>
              </RadialGradientBrush>
            </Path.Fill>
          </Path>
          <Canvas.RenderTransform>
            <MatrixTransform Matrix="1.00628900527954,0,0,1,0.477995008230209,0.5" />
          </Canvas.RenderTransform>
        </Canvas>
      </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