Click here to Skip to main content
15,886,518 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.3K   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="path51">
      <GeometryDrawing.Brush>
        <SolidColorBrush Color="#FFA4C9EE" Opacity="0.7" Transform="1.89511,0,0,1.91236,-231.458,-247.971" />
      </GeometryDrawing.Brush>
      <GeometryDrawing.Geometry>
        <PathGeometry FillRule="Nonzero" Transform="1.89511,0,0,1.91236,-231.458,-247.971" 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="path56">
      <GeometryDrawing.Brush>
        <RadialGradientBrush Center="218.9404,219.7715" RadiusX="150.7063" RadiusY="150.7063" GradientOrigin="218.9404,219.7715" MappingMode="Absolute" Opacity="1" Transform="2.04451,0,0,2.04451,-264.353,-281.723">
          <GradientStop Color="#FF73FFFF" Offset="0" />
          <GradientStop Color="#FF2EA6B9" Offset="0.2809" />
          <GradientStop Color="#FF006B8B" Offset="1" />
        </RadialGradientBrush>
      </GeometryDrawing.Brush>
      <GeometryDrawing.Pen>
        <Pen Thickness="7.73106" StartLineCap="Flat" EndLineCap="Flat" LineJoin="Miter">
          <Pen.Brush>
            <SolidColorBrush Color="#FF1C6671" Opacity="0.988235" />
          </Pen.Brush>
        </Pen>
      </GeometryDrawing.Pen>
      <GeometryDrawing.Geometry>
        <PathGeometry FillRule="EvenOdd" Transform="2.04451,0,0,2.04451,-264.353,-281.723" Figures="M356.643,263.366C356.643,320.393 310.413,366.623 253.387,366.623 196.36,366.623 150.131,320.394 150.131,263.366 150.131,206.339 196.36,160.11 253.387,160.11 310.412,160.11 356.643,206.339 356.643,263.366z" />
      </GeometryDrawing.Geometry>
    </GeometryDrawing>
    <GeometryDrawing x:Name="path249">
      <GeometryDrawing.Brush>
        <SolidColorBrush Color="#FFFFFFFF" Opacity="0.99" Transform="22.3548,0,0,22.3548,-5265.87,-2768.46" />
      </GeometryDrawing.Brush>
      <GeometryDrawing.Pen>
        <Pen Thickness="0.532547" StartLineCap="Flat" EndLineCap="Flat" LineJoin="Miter">
          <Pen.Brush>
            <SolidColorBrush Color="#FF0C6772" Opacity="0.988235" />
          </Pen.Brush>
        </Pen>
      </GeometryDrawing.Pen>
      <GeometryDrawing.Geometry>
        <PathGeometry FillRule="Nonzero" Transform="22.3548,0,0,22.3548,-5265.87,-2768.46" Figures="M243.23,133.176C243.14,130.512 244.49,129.072 247.28,129.072 249.656,129.072 251.186,130.314 251.186,132.33 251.186,133.554 250.772,134.346 249.332,135.552 248.108,136.578 247.784,137.136 247.803,137.946L247.803,138.324 246.489,138.324C246.363,137.262 246.634,136.308 247.3,135.606 249.064,133.716 249.621,133.374 249.621,132.402 249.621,131.268 248.758,130.368 247.264,130.368 245.626,130.368 244.726,131.286 244.798,133.176L243.232,133.176z M246.236,141.978L246.236,140.016 248.018,140.016 248.018,141.978 246.236,141.978z" />
      </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