Click here to Skip to main content
15,894,740 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>
    <DrawingGroup x:Name="g1213" Transform="1,0,0,1,-3.53311,-1.51419">
      <GeometryDrawing x:Name="path2325">
        <GeometryDrawing.Brush>
          <SolidColorBrush Color="#FFFF0000" Opacity="0.99" Transform="2.61979,0,0,2.61979,-126.179,-162.19" />
        </GeometryDrawing.Brush>
        <GeometryDrawing.Pen>
          <Pen Thickness="2.15943" StartLineCap="Flat" EndLineCap="Flat" LineJoin="Miter">
            <Pen.Brush>
              <SolidColorBrush Color="#FFCD0000" Opacity="0.99" />
            </Pen.Brush>
          </Pen>
        </GeometryDrawing.Pen>
        <GeometryDrawing.Geometry>
          <PathGeometry FillRule="Nonzero" Transform="2.61979,0,0,2.61979,-126.179,-162.19" Figures="M62.5183,70.676C66.6661,73.8177 75.8903,85.4223 82.1278,92.4282 88.034,99.5862 91.2126,103.934 98.4211,113.485L96.2144,114.927C90.3693,107.13 85.8722,100.727 80.212,94.1064 75.9701,89.3468 72.4538,86.181 68.0148,80.8586L60.6447,72.4199 62.5183,70.676z" />
        </GeometryDrawing.Geometry>
      </GeometryDrawing>
      <GeometryDrawing x:Name="path2326">
        <GeometryDrawing.Brush>
          <SolidColorBrush Color="#FFFE0000" Opacity="0.99" Transform="1.752,0,0,1.94064,-47.3001,-110.777" />
        </GeometryDrawing.Brush>
        <GeometryDrawing.Pen>
          <Pen Thickness="3.06807" StartLineCap="Flat" EndLineCap="Flat" LineJoin="Miter">
            <Pen.Brush>
              <SolidColorBrush Color="#FFCD0000" Opacity="0.99" />
            </Pen.Brush>
          </Pen>
        </GeometryDrawing.Pen>
        <GeometryDrawing.Geometry>
          <PathGeometry FillRule="Nonzero" Transform="1.752,0,0,1.94064,-47.3001,-110.777" Figures="M111.059,75.6485C102.406,79.0365 96.7979,82.7968 92.4992,85.7984 75.6104,98.9073 59.5649,113.745 45.2746,129.727L41.6946,127.243C55.9372,108.272 72.6717,95.1336 89.225,82.4041 94.773,78.5579 101.769,74.0373 110.771,71.2531L111.059,75.6485z" />
        </GeometryDrawing.Geometry>
      </GeometryDrawing>
    </DrawingGroup>
  </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