Is there to store an encoded PNG in a Canvas?I have a system that uses Canvases as the base UI element. I am slowly moving of all of my resources to be Path based, but I still have a lot of material in raster images (mostly PNG). The systems needs to be able to have the Canvas be self-contained (i.e., it can't load resources from anywhere) - is there a way to store/encode the PNG within the Canvas markup? If not, is there a way to convert the PNG to a Path?<br/><br/>Thanks,<br/>Erick© 2009 Microsoft Corporation. All rights reserved.Thu, 02 Jul 2009 22:13:18 Zc88654ec-e0a3-4a17-8037-5f7e5eee529fhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c88654ec-e0a3-4a17-8037-5f7e5eee529f#c88654ec-e0a3-4a17-8037-5f7e5eee529fhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c88654ec-e0a3-4a17-8037-5f7e5eee529f#c88654ec-e0a3-4a17-8037-5f7e5eee529ferick.thompsonhttp://social.msdn.microsoft.com/Profile/en-US/?user=erick.thompsonIs there to store an encoded PNG in a Canvas?I have a system that uses Canvases as the base UI element. I am slowly moving of all of my resources to be Path based, but I still have a lot of material in raster images (mostly PNG). The systems needs to be able to have the Canvas be self-contained (i.e., it can't load resources from anywhere) - is there a way to store/encode the PNG within the Canvas markup? If not, is there a way to convert the PNG to a Path?<br/><br/>Thanks,<br/>ErickTue, 30 Jun 2009 17:50:59 Z2009-06-30T17:50:59Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c88654ec-e0a3-4a17-8037-5f7e5eee529f#bee282c7-2633-49a4-a1b6-c57f106871f7http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c88654ec-e0a3-4a17-8037-5f7e5eee529f#bee282c7-2633-49a4-a1b6-c57f106871f7Mark Salsberyhttp://social.msdn.microsoft.com/Profile/en-US/?user=Mark%20SalsberyIs there to store an encoded PNG in a Canvas?<blockquote>...needs to be able to have the Canvas be self-contained (i.e., it can't load resources from anywhere)</blockquote> <br/>From anywhere?  Can you use resources embedded in your application?<br/><br/>If so, add the png files to your project and make sure their build action is set to resource.<br/><br/>Then to use the images in a canvas you can use the Image element.  For example, if you added an image called myimage.png to a project folder called Images, you could use it like this:<br/><br/> <pre lang=x-xml> &lt;Canvas &gt; &lt;Image Canvas.Left=&quot;10&quot; Canvas.Top=&quot;10&quot; Source=&quot;Images/myimage.png&quot; /&gt; &lt;/Canvas&gt; </pre> <br/><br/><br/><br/> <hr class=sig> Mark Salsbery Microsoft MVP - Visual C++Tue, 30 Jun 2009 18:41:33 Z2009-06-30T18:42:33Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c88654ec-e0a3-4a17-8037-5f7e5eee529f#a57c8a6e-bea7-473a-86f7-41f65c8f9898http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c88654ec-e0a3-4a17-8037-5f7e5eee529f#a57c8a6e-bea7-473a-86f7-41f65c8f9898erick.thompsonhttp://social.msdn.microsoft.com/Profile/en-US/?user=erick.thompsonIs there to store an encoded PNG in a Canvas?That would work in some situations, but not mine. I can't reference resources embedded in the application, as these Canvas are application independent. Basically, these are XAML fragments that need to stand alone, be stored/serialized, and will be instantiated in many different applications (with different security contexts, so I can't even load from a Uri). What I am hoping is that there is some way to encode the binary data, and store that in the XAML (along with something that will decode it correctly).<br/><br/>Thanks,<br/>ErickTue, 30 Jun 2009 19:16:36 Z2009-06-30T19:16:36Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c88654ec-e0a3-4a17-8037-5f7e5eee529f#53409d40-eea5-4f58-8f0a-0fc8ab5fe281http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c88654ec-e0a3-4a17-8037-5f7e5eee529f#53409d40-eea5-4f58-8f0a-0fc8ab5fe281Kenneth Hauglandhttp://social.msdn.microsoft.com/Profile/en-US/?user=Kenneth%20HauglandIs there to store an encoded PNG in a Canvas?Hi<br/><br/>are you talking about a adding a folder full of images and load it at runtime?!?<br/><br/>Have you got some code to show pleas paste it... Will be easyer to understand what you actually want that way...<br/><br/><hr class="sig">KennethWed, 01 Jul 2009 15:32:14 Z2009-07-01T15:32:14Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c88654ec-e0a3-4a17-8037-5f7e5eee529f#dd40cebb-8116-4c54-8eeb-38314198a2edhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c88654ec-e0a3-4a17-8037-5f7e5eee529f#dd40cebb-8116-4c54-8eeb-38314198a2edJonathan.Peppershttp://social.msdn.microsoft.com/Profile/en-US/?user=Jonathan.PeppersIs there to store an encoded PNG in a Canvas?If you are serializing Xaml, I don't think you're going to be able to store images inside there. <div><br/></div> <div>A better option would be to save all of your images in a seperate file (in a format of your choice or even as loose files).</div> <div><br/></div> <div>So you would have YourSerializedXaml.xaml and YourSerializedXaml.IMGS or something of that nature, and you would just have to manually load your images and stick them in as StaticResources.</div> <div><br/></div> <div>This is not an easy task I would say.  I'm not sure if the Xaml serializer will keep StaticResource names for images inside Xaml or not.</div>Wed, 01 Jul 2009 20:02:13 Z2009-07-01T20:02:13Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c88654ec-e0a3-4a17-8037-5f7e5eee529f#c63ed2da-3ade-42d2-af9b-8614cbf4ee98http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c88654ec-e0a3-4a17-8037-5f7e5eee529f#c63ed2da-3ade-42d2-af9b-8614cbf4ee98erick.thompsonhttp://social.msdn.microsoft.com/Profile/en-US/?user=erick.thompsonIs there to store an encoded PNG in a Canvas?I was afriad of that. I need something totally self-contained, but unless I want to code it up myself, I think I'm out of luck. <br/><br/>Thanks,<br/>ErickThu, 02 Jul 2009 21:53:19 Z2009-07-02T21:53:19Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c88654ec-e0a3-4a17-8037-5f7e5eee529f#21b524d1-e1ed-44ca-8a60-3a5bf842859chttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c88654ec-e0a3-4a17-8037-5f7e5eee529f#21b524d1-e1ed-44ca-8a60-3a5bf842859cJonathan.Peppershttp://social.msdn.microsoft.com/Profile/en-US/?user=Jonathan.PeppersIs there to store an encoded PNG in a Canvas?Well, it's definitely do-able. <div><br/></div> <div>Make a Serializable/XmlSerializable class, that has:</div> <div><br/></div> <div> <ul> <li>A string property for xaml</li> <li>A List&lt;byte[]&gt; of the raw png encoded images</li> <li>Come up with some standard way to map your images to where they go</li> </ul> <div>Then you could serialize your whole class to a file.</div> <div><br/></div> <div>It is just a thought, and .Net has most of that built in... you will just have to put it all together.</div> </div>Thu, 02 Jul 2009 22:13:18 Z2009-07-02T22:13:18Z