We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Get resource path form BitmapNode

Hi ,
I am looking to get the path of the source image for the BitmapNode, but I wasn't able to find any property with such value

3 Replies

RT Ramya Thirugnanam Syncfusion Team July 24, 2019 07:14 AM UTC

Hi George,  
 
Please use the below code example to get an Image location. By default, the path gets accessed from bin folder and if you need to access the folder location, you should Rightclick on image -> click properties -> Copy to Output Directory as Copy always. Please refer to a screenshot below.  
 
Code example:  
// Get the location of image  
   string filePath = Path.Combine(Environment.CurrentDirectory, "Images\\personico.bmp");  
 
 
 
Here is the link to get an image path.  
 
screenshot:  
 
  
 
please refer to the code example below render  an image node.  
 
Code example:  
// Get an location of image  
   string filePath = Path.Combine(Environment.CurrentDirectory, "Images\\personico.bmp");  
  // Set an filepath to bitmap class  
 Bitmap bitmap = new Bitmap(filePath);  
 //Render an image Node  
BitmapNode image = new BitmapNode(bitmap, new RectangleF(0, 0, 100, 50));  
diagram1.Model.AppendChild(image);    
 
 
 
Regards,  
Ramya T  



GE George July 24, 2019 03:27 PM UTC

I create the BitmapNode at runtime and the user is free to select any image he wants
I wouls also get the Image path at runtime if possible


RT Ramya Thirugnanam Syncfusion Team July 25, 2019 10:38 AM UTC

Hi George,  
 
Please use Diagram “BitmapTool” to activate the tool and create the BitmapNode at runtime. While creating the BitmapNode using Diagram tool at runtime, the dialog box will appear and select the image anywhere from the machine. Please refer to the below attached sample.  
 
Sample:  
Sample  
 
Regards, 
Ramya T 


Loader.
Live Chat Icon For mobile
Up arrow icon