Click here to Skip to main content
15,891,033 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.4K   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.56585816303016" Canvas.Top="-6.62511664628983">
    <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.29946522">
        <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,2.51101201971819E-15,16.8730602264404" />
            </RadialGradientBrush.Transform>
          </RadialGradientBrush>
        </Path.Fill>
        <Path.RenderTransform>
          <MatrixTransform Matrix="1.27118599414825,0,0,1.27118599414825,-8.11937618255615,-15.1017904281616" />
        </Path.RenderTransform>
      </Path>
      <Path Data="M8.5541875,15.517348L8.5541875,32.511768 21.538,32.511768 21.538,41.056806 41.497835,24.150365 21.41919,7.1251168 21.41919,15.522652 8.5541875,15.517348z" Stroke="#FF3A7304" StrokeThickness="1.00000035762787" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeDashCap="Round" StrokeLineJoin="Round">
        <Path.Fill>
          <RadialGradientBrush Center="22.291636,32.797512" RadiusX="16.9562" RadiusY="16.9562" GradientOrigin="22.291636,32.797512" MappingMode="Absolute">
            <RadialGradientBrush.GradientStops>
              <GradientStop Color="#FF73D216" Offset="0" />
              <GradientStop Color="#FF4E9A06" Offset="1" />
            </RadialGradientBrush.GradientStops>
            <RadialGradientBrush.Transform>
              <MatrixTransform Matrix="0.843021988868713,1.87188497696357E-16,-2.26522815177606E-16,1.02016794681549,4.49929809570313,1.38199198246002" />
            </RadialGradientBrush.Transform>
          </RadialGradientBrush>
        </Path.Fill>
      </Path>
      <Path Data="M21.962385,8.2485033L21.962385,16.054978 9.1452151,16.054978 9.1452151,25.095691C26.895215,27.095691,25.778752,17.640403,40.528752,24.140403L21.962385,8.2485033z" Stroke="{x:Null}" StrokeThickness="1" Opacity="0.5080214">
        <Path.Fill>
          <RadialGradientBrush Center="19.701141,2.8969381" RadiusX="17.171415" RadiusY="17.171415" GradientOrigin="19.701141,2.8969381" MappingMode="Absolute">
            <RadialGradientBrush.GradientStops>
              <GradientStop Color="#FFFFFFFF" Offset="0" />
              <GradientStop Color="#00FFFFFF" Offset="1" />
            </RadialGradientBrush.GradientStops>
            <RadialGradientBrush.Transform>
              <MatrixTransform Matrix="2.04672908782959,-3.74942707522362E-16,2.8534041245803E-16,1.55761003494263,-19.5179901123047,3.45208597183228" />
            </RadialGradientBrush.Transform>
          </RadialGradientBrush>
        </Path.Fill>
      </Path>
      <Path Data="M9.537702,16.561892L9.537702,31.546332 22.523069,31.546332 22.523069,38.941498 40.001083,24.145807 22.507108,9.3654066 22.507108,16.566789 9.537702,16.561892z" Fill="{x:Null}" Stroke="#7BFFFFFF" StrokeThickness="1.00000035762787" Opacity="0.48128339" />
    </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