Click here to Skip to main content
15,881,882 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="path107">
      <GeometryDrawing.Brush>
        <SolidColorBrush Color="#FFA4C9EE" Opacity="0.701961" Transform="29.8155,0,0,29.8155,-7593.72,41.973" />
      </GeometryDrawing.Brush>
      <GeometryDrawing.Pen>
        <Pen Thickness="0.478131" StartLineCap="Flat" EndLineCap="Flat" LineJoin="Miter">
          <Pen.Brush>
            <SolidColorBrush Color="#FF0C6772" Opacity="0.992157" />
          </Pen.Brush>
        </Pen>
      </GeometryDrawing.Pen>
      <GeometryDrawing.Geometry>
        <PathGeometry FillRule="Nonzero" Transform="29.8155,0,0,29.8155,-7593.72,41.973" Figures="M255.689,0.39L255.689,0.156 261.323,0.156 261.323,0.39 261.017,0.39C260.128,0.39,259.63,0.702,259.523,1.326L259.505,1.668 259.505,8.31C259.505,10.35 260.267,11.556 261.79,11.928 262.186,12.024 262.637,12.072 263.141,12.072 265,12.072 266.159,11.268 266.615,9.66 266.735,9.216 266.796,8.706 266.796,8.13L266.796,1.668C266.796,0.816,266.291,0.39,265.283,0.39L264.977,0.39 264.977,0.156 269.423,0.156 269.423,0.39 269.116,0.39C268.204,0.39,267.706,0.732,267.622,1.416L267.604,1.668 267.604,8.472C267.604,10.56 266.776,11.922 265.12,12.558 265.108,12.558 265.097,12.564 265.085,12.576 264.616,12.744 264.089,12.852 263.501,12.9 263.32,12.912 263.135,12.918 262.942,12.918 260.11,12.918 258.376,11.934 257.74,9.966 257.584,9.474 257.507,8.91 257.507,8.274L257.507,1.668C257.507,0.816,257.002,0.39,255.994,0.39L255.688,0.39z" />
      </GeometryDrawing.Geometry>
    </GeometryDrawing>
    <GeometryDrawing x:Name="rect2234">
      <GeometryDrawing.Brush>
        <SolidColorBrush Color="#FF0C6772" Opacity="0.992157" />
      </GeometryDrawing.Brush>
      <GeometryDrawing.Pen>
        <Pen Thickness="8.41811" StartLineCap="Flat" EndLineCap="Flat" LineJoin="Miter">
          <Pen.Brush>
            <SolidColorBrush Color="#FF0C6772" Opacity="0.992157" />
          </Pen.Brush>
        </Pen>
      </GeometryDrawing.Pen>
      <GeometryDrawing.Geometry>
        <RectangleGeometry RadiusX="0" RadiusY="0" Rect="53.6788,462.2789,400.5883,16.0236" />
      </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