Click here to Skip to main content
15,896,063 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="-3.04415152768519" Canvas.Top="-0.132465374784749">
    <Canvas>
      <Path Data="F1M27,25.53125A9.6875,3.40625,0,1,1,7.625,25.53125A9.6875,3.40625,0,1,1,27,25.53125z" Stroke="{x:Null}" StrokeThickness="1" Opacity="0.40909091">
        <Path.Fill>
          <RadialGradientBrush Center="17.3125,25.53125" RadiusX="9.6875" RadiusY="9.6875" GradientOrigin="17.3125,25.53125" MappingMode="Absolute">
            <RadialGradientBrush.GradientStops>
              <GradientStop Color="#FF000000" Offset="0" />
              <GradientStop Color="#00000000" Offset="1" />
            </RadialGradientBrush.GradientStops>
            <RadialGradientBrush.Transform>
              <MatrixTransform Matrix="1,0,0,0.351612985134125,1.29280309398819E-15,16.5541305541992" />
            </RadialGradientBrush.Transform>
          </RadialGradientBrush>
        </Path.Fill>
        <Path.RenderTransform>
          <MatrixTransform Matrix="2.18291211128235,0,0,2.18291211128235,-13.5037202835083,-14.3501195907593" />
        </Path.RenderTransform>
      </Path>
      <Path Data="F1M46.138718,23.42804A22.008699,21.213203,0,1,1,2.1213188,23.42804A22.008699,21.213203,0,1,1,46.138718,23.42804z" Fill="#FFF57900" Stroke="#FF914900" StrokeThickness="0.982149422168732" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeDashCap="Round" StrokeLineJoin="Round" StrokeMiterLimit="4">
        <Path.RenderTransform>
          <MatrixTransform Matrix="0.944630026817322,0,0,0.980053007602692,1.50417399406433,-1.55691194534302" />
        </Path.RenderTransform>
      </Path>
      <Path Data="F1M46.138718,23.42804A22.008699,21.213203,0,1,1,2.1213188,23.42804A22.008699,21.213203,0,1,1,46.138718,23.42804z" Fill="{x:Null}" Stroke="#FFFCAF3E" StrokeThickness="0.982149422168732" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeDashCap="Round" StrokeLineJoin="Round" StrokeMiterLimit="4">
        <Path.RenderTransform>
          <MatrixTransform Matrix="0.914085984230042,0,0,0.948364019393921,2.38057589530945,-0.905815005302429" />
        </Path.RenderTransform>
      </Path>
      <Path Data="F1M21.464926,10.373268C21.336952,10.373268,21.230316,10.547762,21.230316,10.757175L22.295085,25.197999C22.295085,25.407412 22.401721,25.581906 22.529695,25.581907 22.529695,25.581907 23.370516,25.59381 24.063684,25.581907 24.292022,25.577986 24.361898,25.602219 24.568998,25.581907 25.262166,25.59381 26.102987,25.581907 26.102987,25.581907 26.230961,25.581907 26.337597,25.407412 26.337597,25.197999L27.402366,10.757175C27.402366,10.547762,27.29573,10.402799,27.167755,10.402799L24.587044,10.402799C24.577532,10.400862,24.578842,10.373268,24.568998,10.373268L21.464926,10.373268z" Fill="#FFFFFFFF" Stroke="{x:Null}" StrokeThickness="1" />
      <Path Data="F1M-11.875,34.0625A4.5625,3.8125,0,1,1,-21,34.0625A4.5625,3.8125,0,1,1,-11.875,34.0625z" Fill="#FFFFFFFF" Stroke="{x:Null}" StrokeThickness="1">
        <Path.RenderTransform>
          <MatrixTransform Matrix="0.504863977432251,0,0,0.604182004928589,32.659351348877,9.60884475708008" />
        </Path.RenderTransform>
      </Path>
      <Path Data="F1M43.676426,20.47678C43.676426,31.307396 37.624257,16.170581 25.001688,20.863168 12.279172,25.592912 4.4350535,31.307396 4.4350535,20.47678 4.4350535,9.6461627 13.22512,0.85609769 24.05574,0.85609769 34.886359,0.85609769 43.676426,9.6461627 43.676426,20.47678z" Fill="#37FFFEFF" 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