Click here to Skip to main content
15,891,749 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.Background>  <DrawingBrush><DrawingBrush.Drawing><DrawingGroup>
  <DrawingGroup x:Name="DrawingLayer">
    <DrawingGroup.ClipGeometry>
      <RectangleGeometry Rect="0,0,507.946,507.946" />
    </DrawingGroup.ClipGeometry>
    <GeometryDrawing x:Name="path5">
      <GeometryDrawing.Brush>
        <RadialGradientBrush Center="0.5,0.5" RadiusX="0.5" RadiusY="0.5" GradientOrigin="0.5,0.5" MappingMode="RelativeToBoundingBox" Opacity="1" Transform="3.72638,0,0,3.72638,-100.373,-104.224">
          <GradientStop Color="#FDFBDDB2" Offset="0" />
          <GradientStop Color="#F3EFA81A" Offset="1" />
        </RadialGradientBrush>
      </GeometryDrawing.Brush>
      <GeometryDrawing.Pen>
        <Pen Thickness="3.41213" StartLineCap="Flat" EndLineCap="Flat" LineJoin="Miter" MiterLimit="10">
          <Pen.Brush>
            <SolidColorBrush Color="#FF580400" Opacity="0.992157" />
          </Pen.Brush>
        </Pen>
      </GeometryDrawing.Pen>
      <GeometryDrawing.Geometry>
        <PathGeometry FillRule="Nonzero" Transform="3.72638,0,0,3.72638,-100.373,-104.224" Figures="M142.384,60.3379L136.245,53.3211 123.49,58.6423C117.029,61.3374,108.572,57.417,106.575,50.8016L102.581,37.5707 93.2789,36.9499 88.0223,49.7317C85.3598,56.2056,76.6075,59.4137,70.5176,56.1479L58.3379,49.6164 51.3211,55.7551 56.6423,68.5103C59.3374,74.9706,55.417,83.4279,48.8016,85.4249L35.5707,89.4187 34.9499,98.7211 47.7317,103.978C54.2056,106.64,57.4137,115.392,54.1479,121.482L47.6164,133.662 53.7551,140.679 66.5103,135.358C72.9706,132.663,81.4279,136.583,83.4249,143.198L87.4187,156.429 96.7211,157.05 101.978,144.268C104.64,137.794,113.392,134.586,119.482,137.852L131.662,144.384 138.679,138.245 133.358,125.49C130.663,119.029,134.583,110.572,141.198,108.575L154.429,104.581 155.05,95.2789 142.268,90.0223C135.794,87.3598,132.586,78.6075,135.852,72.5176L142.384,60.3379" />
      </GeometryDrawing.Geometry>
    </GeometryDrawing>
    <GeometryDrawing x:Name="path204">
      <GeometryDrawing.Brush>
        <SolidColorBrush Color="#FFFFFFFF" Opacity="0.99" Transform="3.26308,0,0,3.26308,3.84998,43.5535" />
      </GeometryDrawing.Brush>
      <GeometryDrawing.Pen>
        <Pen Thickness="3.89659" StartLineCap="Flat" EndLineCap="Flat" LineJoin="Miter" MiterLimit="10">
          <Pen.Brush>
            <SolidColorBrush Color="#FF580400" Opacity="0.992157" />
          </Pen.Brush>
        </Pen>
      </GeometryDrawing.Pen>
      <GeometryDrawing.Geometry>
        <PathGeometry FillRule="Nonzero" Transform="3.26308,0,0,3.26308,3.84998,43.5535" Figures="M42,66C42,48.3269 57.2223,34 76,34 94.7777,34 110,48.3269 110,66 110,83.6731 94.7777,98 76,98 57.2223,98 42,83.6731 42,66z" />
      </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