Reputation: 513
I need to store the bitmap image information in an XAML-formatted file. Can anyone please help me out on this regard?
Upvotes: 1
Views: 2311
Reputation:
I think it can be a valid request for some few cases, like embedding small button images in png format. I have not tried it, but I think the following is valid:
By the way, I have seen that case (small icons) embedded in HTML pages, where it is possible without a converter.
Upvotes: 0
Reputation: 31928
It can't be done (Charles Petzold)
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!
Upvotes: 3