PETZOLD BOOK BLOG

Charles Petzold on writing books, reading books, and exercising the internal UTM


Recent Entries
< PreviousBrowse the ArchivesNext >
Subscribe to the RSS Feed

Embedding Bitmaps in XAML Files

August 23, 2006
Roscoe, NY

It can't be done.

Sure, you can refer to external bitmaps in XAML files, but you can't embed a bitmap in a XAML file. What you would need is a class that derives from BitmapSource that has a property named Data or something that you could set to an array of bytes, and a converter that would accept a list of quoted bytes in the XAML file. And such a class does not exist.

What you really shouldn't be doing is getting weird and dangerous ideas, like possibly simulating a bitmap using a UniformGrid containing a bunch of one-pixel square Rectangle objects, one for each pixel. That's just nuts.

Once you start thinking crazy thoughts like that, you're likely to take a 6K 220×260 color JPEG and convert it into a 1.9 megabyte EmbeddedBitmap.xaml file that takes way too much time to load and compose.

Surely you have better sense than that!


Recent Entries
< PreviousBrowse the ArchivesNext >
Subscribe to the RSS Feed

(c) Copyright Charles Petzold
www.charlespetzold.com