Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Need to set image in diagram node (Read 1670 times)
Shafi
Full Member
***
Offline


I Love MindFusion!

Posts: 109
Joined: Nov 8th, 2016
Need to set image in diagram node
Nov 21st, 2017 at 9:12am
Print Post  
Hi

I have a requirement that i need to set the images in diagram node. Right now we are doing it like below code. But is there any other way so that we do not need to give URL instead we can give binary image file.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Need to set image in diagram node
Reply #1 - Nov 21st, 2017 at 12:01pm
Print Post  
You could set as source a data URL containing base64 encoded image, like "data:image/png;base64,BASE64_ENCODED_STRING_OF_THE_IMAGE".

E.g. you could pass such string directly to setImageLocation, or set as img.src when calling node.setImage or custom drawing -

var img = new Image(); // a DOM image object
img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI1
2P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
node.setImage(img);

// or custom drawing from updateVisuals
var image = new MindFusion.Drawing.Image(bounds);
image.image.src = "data:image..."

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint