Click here to Skip to main content
15,885,546 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.99999593705013" Canvas.Top="-4.99999982118607">
    <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.20454544">
        <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.5177639274715E-15,16.8730602264404" />
            </RadialGradientBrush.Transform>
          </RadialGradientBrush>
        </Path.Fill>
        <Path.RenderTransform>
          <MatrixTransform Matrix="1.21446597576141,0,0,0.595457971096039,-6.16384601593018,20.1877498626709" />
        </Path.RenderTransform>
      </Path>
      <Path Data="M40.5,42.5L40.5,36.503792 25.375,36.503792 40.46875,18.5 32.5,18.4375 32.5,5.4999998 14.53125,5.4999998 14.53125,18.4375 6.5000002,18.4375 21.875,36.503792 6.5018962,36.503792 6.5018962,42.5 40.5,42.5z" Stroke="#FF3B7502" StrokeThickness="1.00000035762787" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeDashCap="Round" StrokeLineJoin="Round">
        <Path.Fill>
          <RadialGradientBrush Center="34.663586,20.321211" RadiusX="16.9562" RadiusY="16.9562" GradientOrigin="34.663586,20.321211" 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,46.3935699462891,1.41385400295258" />
            </RadialGradientBrush.Transform>
          </RadialGradientBrush>
        </Path.Fill>
      </Path>
      <Path Data="M7.598671,19.005743L15.005062,18.994024 15.002381,6.001187 30.380937,6.01034C29.611015,24.35133,19.658288,17.003413,14.999278,27.657219L7.598671,19.005743z" 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,2.91297006607056,-22.9335403442383" />
            </RadialGradientBrush.Transform>
          </RadialGradientBrush>
        </Path.Fill>
      </Path>
      <Path Data="M31.529849,6.5000002L15.519518,6.5000002 15.519518,19.49295 8.6884242,19.49295 23.146289,36.497838 24.058638,36.510066 38.27903,19.537918 31.480757,19.471627 31.529849,6.5000002z" Fill="{x:Null}" Stroke="#7BFFFFFF" StrokeThickness="1.00000035762787" Opacity="0.4812834" />
      <Rectangle Stroke="#7BFFFFFF" StrokeThickness="1.00000035762787" Width="33.0016443576279" Height="5.00946745762787" Opacity="0.481" Canvas.Left="6.99984632118607" Canvas.Top="36.9999998211861">
        <Rectangle.Fill>
          <RadialGradientBrush Center="6.58201681670036,-10.976917476748" RadiusX="16.505941" RadiusY="16.505941" GradientOrigin="6.58201681670036,-10.976917476748" MappingMode="Absolute">
            <RadialGradientBrush.GradientStops>
              <GradientStop Color="#FF73D216" Offset="0" />
              <GradientStop Color="#FF4E9A06" Offset="1" />
            </RadialGradientBrush.GradientStops>
            <RadialGradientBrush.Transform>
              <MatrixTransform Matrix="0.999669015407562,-0.00478290347382426,0.00378530425950885,0.791667997837067,-0.221863001585007,10.4137697219849" />
            </RadialGradientBrush.Transform>
          </RadialGradientBrush>
        </Rectangle.Fill>
      </Rectangle>
      <Path Data="M40,40.785821C27.93934,36.732669,10.597476,42.084912,7.0220967,39.534362L7.0376697,37.027779 40,37.004571 40,40.785821z" Stroke="{x:Null}" StrokeThickness="1" Opacity="0.17613636">
        <Path.Fill>
          <RadialGradientBrush Center="16.620785,-29.734715" RadiusX="16.5" RadiusY="16.5" GradientOrigin="16.620785,-29.734715" MappingMode="Absolute">
            <RadialGradientBrush.GradientStops>
              <GradientStop Color="#FFFFFFFF" Offset="0" />
              <GradientStop Color="#00FFFFFF" Offset="1" />
            </RadialGradientBrush.GradientStops>
            <RadialGradientBrush.Transform>
              <MatrixTransform Matrix="-2.19318509101868,-0.000537222367711365,-0.00026268360670656,0.916666984558105,44.5004005432129,59.2996292114258" />
            </RadialGradientBrush.Transform>
          </RadialGradientBrush>
        </Path.Fill>
      </Path>
    </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