Click here to Skip to main content
15,895,799 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="-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>
      <Path Data="F1M33.660715,32.696428C33.660715,36.196428 29.410715,38.946428 24.285715,38.946428 19.160715,38.946428 14.910715,36.196428 14.910715,32.696428 14.910715,29.196428 19.160715,26.446428 24.285715,26.446428 29.410715,26.446428 33.660715,29.196428 33.660715,32.696428z" Fill="#5CFFFFFF" Stroke="{x:Null}" StrokeThickness="1" Opacity="0.35999998" />
      <Path Data="F1M33.660715,31.696428C33.660715,35.196428 29.410715,37.946428 24.285715,37.946428 19.160715,37.946428 14.910715,35.196428 14.910715,31.696428 14.910715,28.196428 19.160715,25.446428 24.285715,25.446428 29.410715,25.446428 33.660715,28.196428 33.660715,31.696428z" 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.21428108215332,-8.4285717010498" />
            </RadialGradientBrush.Transform>
          </RadialGradientBrush>
        </Path.Fill>
      </Path>
      <Canvas>
        <Path Data="F1M21.398158,15.321428C21.398158,17.821428 20.273158,19.821428 18.898158,19.821428 17.523158,19.821428 16.273158,17.821428 16.273158,15.321428 16.273158,12.821428 17.398158,10.821428 18.773158,10.821428 20.148158,10.821428 21.273158,12.821428 21.273158,15.321428L21.398158,15.321428z" Fill="#5CFFFFFF" Stroke="{x:Null}" StrokeThickness="1" Opacity="0.35999998" />
        <Path Data="F1M30.688512,15.321428C30.688512,17.821428 29.563512,19.821428 28.188512,19.821428 26.813512,19.821428 25.688512,17.821428 25.688512,15.321428 25.688512,12.821428 26.813512,10.821428 28.188512,10.821428 29.563512,10.821428 30.688512,12.821428 30.688512,15.321428z" Fill="#5CFFFFFF" Stroke="{x:Null}" StrokeThickness="1" Opacity="0.35999998" />
        <Path Data="F1M21.398158,14.696428C21.398158,17.196428 20.273158,19.196428 18.898158,19.196428 17.523158,19.196428 16.398158,17.196428 16.398158,14.696428 16.398158,12.196428 17.523158,10.196428 18.898158,10.196428 20.273158,10.196428 21.398158,12.196428 21.398158,14.696428z" Fill="#FF000000" Stroke="{x:Null}" StrokeThickness="1" />
        <Path Data="F1M30.688512,14.696428C30.688512,17.196428 29.563512,19.196428 28.188512,19.196428 26.813512,19.196428 25.688512,17.196428 25.688512,14.696428 25.688512,12.196428 26.813512,10.196428 28.188512,10.196428 29.563512,10.196428 30.688512,12.196428 30.688512,14.696428z" Fill="#FF000000" Stroke="{x:Null}" StrokeThickness="1" />
        <Canvas.RenderTransform>
          <MatrixTransform Matrix="1,0,0,1,0.265165001153946,0" />
        </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