Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Retaining the Image (Read 2041 times)
solisgsandc
YaBB Newbies
*
Offline



Posts: 40
Joined: Dec 18th, 2009
Retaining the Image
Feb 11th, 2010 at 5:30pm
Print Post  
Is there a way I can retain the image of the UIElement when I serialize to XML. When I send the XML to someone else and they use the tool, the image disappears since it has a reference to a local drive. Can the diagram save the image?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Retaining the Image
Reply #1 - Feb 11th, 2010 at 7:25pm
Print Post  
The diagram automatically saves the Image property of nodes in XML by serializing the images in base64 format. If you are using controls hosted in DiagramNodeAdapters and these controls display images, either use relative file paths as images sources and copy the image files too with the xml, or load all images inside hidden ShapeNodes and assign them back to the hosted controls when a diagram is loaded.
  
Back to top
 
IP Logged
 
solisgsandc
YaBB Newbies
*
Offline



Posts: 40
Joined: Dec 18th, 2009
Re: Retaining the Image
Reply #2 - Feb 11th, 2010 at 7:47pm
Print Post  
I am using the latter part. Copying image files too with the XML means saving this a part of the diagram.Tag? Can you give me some code that does this as an example?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Retaining the Image
Reply #3 - Feb 11th, 2010 at 9:41pm
Print Post  
I meant you could copy the external image files together with the diagram xml if using relative URLs.

Another option is to change your tool's file format to a zip archive containing the xml and image files, as shown here -
https://msdn.microsoft.com/en-us/library/system.io.packaging.zippackage.aspx

If you prefer storing the image data as a Tag value of nodes, you can use the FromImage method of MindFusion.Diagramming.Converter to get base64 encoded image bytes, and after loading the diagram call ToImage to load images from the node Tag values.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint