Charles Petzold



The Tim Sneath Challenge V

August 17, 2006
Roscoe, NY

It's trivial to construct a one-element XAML file that consists of Image element with a URI referencing a bitmap, but even HTML can do that.

Instead, I wanted to display an image without referencing anything outside the XAML file. It'd be nice if you could actually embed a bitmap in a XAML file; maybe we'll see that feature sometime in the future. Meanwhile, I took the photo from the home page of my Web site:

And I wrote a little program to convert it into a XAML file with a Path element that uses a dithering technique to mimic gray shades. Here's what the XAML file displays:

You can download or run the 640K PetzoldPhoto.xaml file to verify that it is just one element and thus meets the Tim Sneath challenge

The Path element in the XAML file consists of a bunch of short lines. If you examine the XAML file, you'll see that I defined the Stroke property to be black, but the anti-aliasing perfomed by WPF actually makes different gray shades. I tried a couple different approaches before settling on the one that produced the image shown above. The XAML file looks best when your screen resolution is 96 DPI.