Click here to Skip to main content
15,896,201 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.Background>  <DrawingBrush><DrawingBrush.Drawing><DrawingGroup>
  <DrawingGroup x:Name="DrawingLayer">
    <DrawingGroup.ClipGeometry>
      <RectangleGeometry Rect="0,0,160,160" />
    </DrawingGroup.ClipGeometry>
    <GeometryDrawing x:Name="path51">
      <GeometryDrawing.Brush>
        <SolidColorBrush Color="#FF84D66D" Opacity="0.797203" Transform="0.642031,0,0,0.647873,-83.7952,-90.6997" />
      </GeometryDrawing.Brush>
      <GeometryDrawing.Geometry>
        <PathGeometry FillRule="Nonzero" Transform="0.642031,0,0,0.647873,-83.7952,-90.6997" Figures="M134.757,263.776C134.757,330.515 189.055,384.816 255.796,384.816 322.535,384.816 376.835,330.515 376.835,263.776 376.835,197.035 322.535,142.737 255.796,142.737 189.055,142.737 134.757,197.035 134.757,263.776z" />
      </GeometryDrawing.Geometry>
    </GeometryDrawing>
    <GeometryDrawing x:Name="path216">
      <GeometryDrawing.Brush>
        <LinearGradientBrush StartPoint="0.497054,-0.0168862" EndPoint="0.558393,0.880475" MappingMode="RelativeToBoundingBox" SpreadMethod="Pad" Opacity="1">
          <LinearGradientBrush.Transform>
            <TransformGroup>
              <MatrixTransform>1,1.79104E-09,-5.10191E-10,1,-3.67651E-07,-3.78757E-07</MatrixTransform>
              <MatrixTransform>-0.682353,0.919919,0.948153,0.703296,61.58,-23.4433</MatrixTransform>
            </TransformGroup>
          </LinearGradientBrush.Transform>
          <GradientStop Color="#FD6ACE34" Offset="0" />
          <GradientStop Color="#F33D7A35" Offset="1" />
        </LinearGradientBrush>
      </GeometryDrawing.Brush>
      <GeometryDrawing.Pen>
        <Pen Thickness="4" StartLineCap="Flat" EndLineCap="Flat" LineJoin="Miter">
          <Pen.Brush>
            <SolidColorBrush Color="#FF0C482B" Opacity="0.992157" />
          </Pen.Brush>
        </Pen>
      </GeometryDrawing.Pen>
      <GeometryDrawing.Geometry>
        <PathGeometry FillRule="Nonzero" Transform="-0.682353,0.919919,0.948153,0.703296,61.58,-23.4433" Figures="M50.2667,51.1884L66.3773,63.9065 22.0561,72.3148 20.8793,27.8085 36.5861,40.3644C45.749,31.616 48.8984,27.0643 56.2748,23.5641 64.3979,18.971 67.1959,18.2482 78.2542,17.3595 91.2542,17.3595 106.734,25.0002 117.847,36.9653 129.246,49.2327 129.751,67.7074 128.751,75.7074 125.623,92.3796 116.785,109.383 102.013,116.956 87.594,124.784 73.4267,129.963 58.1713,129.219 43.1784,128.131 30.5279,121.699 18.4679,111.293 6.40806,100.888 0.292525,89.5931 -1.8839,66.8372 13.6472,90.3856 25.6854,103.728 38.023,110.647 48.4382,116.082 50.4606,117.418 67.4354,117.123 82.8998,117.116 97.4177,110.436 109.172,95.1733 121.023,77.0173 110.798,53.5318 102.059,45.158 93.0568,37.1276 81.9757,30.8078 63.1423,40.5489 56.8243,45.938 56.1035,44.6324 50.2667,51.1884z" />
      </GeometryDrawing.Geometry>
    </GeometryDrawing>
  </DrawingGroup>
      </DrawingGroup></DrawingBrush.Drawing></DrawingBrush></Canvas.Background></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