Click here to Skip to main content
15,894,362 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="F1M34.014268,32.036842C30.290694,27.87283 28.451859,26.405561 24.462492,26.405561 20.561313,26.405561 17.96282,28.093607 15.087492,32.390396 18.520789,30.041583 20.397124,28.7409 24.197327,28.7409 27.909166,28.7409 29.948404,29.791599 34.014268,32.036842z" Fill="#5CFFFFFF" Stroke="{x:Null}" StrokeThickness="1" Opacity="0.35999998" />
      <Path Data="F1M34.014268,31.329738C30.290694,27.165726 28.451859,25.698457 24.462492,25.698457 20.561313,25.698457 17.96282,27.386503 15.087492,31.683292 18.520789,29.334479 20.397124,28.033796 24.197327,28.033796 27.909166,28.033796 29.948404,29.084495 34.014268,31.329738z" 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,73.6644821166992" />
            </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.353552997112274,2.3927059173584" />
        </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