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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to convert diagram node to any image ?

Thread ID:





72541 Mar 26,2008 06:53 AM UTC Mar 27,2008 08:47 AM UTC WinForms 1
Tags: Diagram
Asked On March 26, 2008 06:53 AM UTC

How to convert diagram node to image (wmf, bitmap, any).


vijay [Syncfusion]
Replied On March 27, 2008 08:47 AM UTC

Hi Bob,

Please try below code to export a single node as an image and let me know if this helps.

Node selectedNode = this.diagram1.Controller.SelectionList[0];
if (selectedNode != null)
//Node size is depends on the border line. So we have to calculate the Line width also.
Bitmap bmp = new Bitmap(Convert.ToInt32(selectedNode.Size.Width + selectedNode.LineStyle.LineWidth),
Convert.ToInt32(selectedNode.Size.Height + selectedNode.LineStyle.LineWidth));

using (Graphics gr = Graphics.FromImage(bmp))

System.Drawing.Drawing2D.Matrix m = new System.Drawing.Drawing2D.Matrix();
m.Translate(Convert.ToInt32(-selectedNode.BoundingRectangle.Left), Convert.ToInt32(-selectedNode.BoundingRectangle.Top));
gr.Transform = m;
//This will render the node image in a graphics surface and we can export it easily to any type of image.
bmp.Save("image.png", System.Drawing.Imaging.ImageFormat.Png);


Sample : ExportImage.zip



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon