Click here to Skip to main content
15,881,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.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="path59">
      <GeometryDrawing.Brush>
        <SolidColorBrush Color="#FFFFFFFF" Opacity="0.7" Transform="-1.03094,1.05323,-1.05323,-1.03094,838.655,269.436" />
      </GeometryDrawing.Brush>
      <GeometryDrawing.Pen>
        <Pen Thickness="6.73139" StartLineCap="Flat" EndLineCap="Flat" LineJoin="Miter">
          <Pen.Brush>
            <SolidColorBrush Color="#FF1C6772" Opacity="0.988235" />
          </Pen.Brush>
        </Pen>
      </GeometryDrawing.Pen>
      <GeometryDrawing.Geometry>
        <PathGeometry FillRule="Nonzero" Transform="-1.03094,1.05323,-1.05323,-1.03094,838.655,269.436" Figures="M299.051,232.372C300.964,230.459 301.731,222.711 301.218,221.474 299.67,217.738 296.025,215.301 291.98,215.301L215.117,215.301C209.594,215.301,205.117,219.778,205.117,225.301L205.117,302.168C205.117,306.213 207.554,309.859 211.29,311.407 215.027,312.955 219.329,312.098 222.188,309.238 222.188,309.238 299.051,232.372 299.051,232.372z" />
      </GeometryDrawing.Geometry>
    </GeometryDrawing>
    <GeometryDrawing x:Name="path44">
      <GeometryDrawing.Brush>
        <SolidColorBrush Color="#FFFFFFFF" Opacity="0.7" Transform="1.36655,-1.1048,1.40279,1.07627,-497.19,258.677" />
      </GeometryDrawing.Brush>
      <GeometryDrawing.Pen>
        <Pen Thickness="5.70824" StartLineCap="Flat" EndLineCap="Flat" LineJoin="Miter">
          <Pen.Brush>
            <SolidColorBrush Color="#FF1C6772" Opacity="0.988235" />
          </Pen.Brush>
        </Pen>
      </GeometryDrawing.Pen>
      <GeometryDrawing.Geometry>
        <PathGeometry FillRule="Nonzero" Transform="1.36655,-1.1048,1.40279,1.07627,-497.19,258.677" Figures="M296.974,234.395C299.406,231.976 298.797,223.275 294.343,218.052 290.395,213.348 279.4,212.777 276.846,216.384L202.982,289.07C197.83,295.098 202.899,303.263 206.738,306.734 211.083,310.725 218.291,313.11 222.188,309.238 222.188,309.238 293.34,237.935 296.974,234.395z" />
      </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