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

Export/Save diagram as image format.

Thread ID:

Created:

Updated:

Platform:

Replies:

15212 Jun 14,2004 09:05 PM UTC Oct 12,2004 04:31 PM UTC WinForms 7
loading
Tags: Diagram
Rich
Asked On June 14, 2004 09:05 PM UTC

Hi, Could you please tell me how I can programmatically export/save a diagram as an image...jpeg, gif and/or bmp. Richard

Administrator [Syncfusion]
Replied On June 16, 2004 06:34 PM UTC

Hi Richard, Exporting the diagram as an Image is a feature that we intend to provide in a future version of Essential Diagram. For the time being you can use the appended code snippet to publish the Diagram contents as an image object. Regards, Prakash Syncfusion, Inc // The activeDiagram member in this snippet // references the Diagram control // Cache the view''s current origin and size PointF vieworigin = activeDiagram.View.Origin; Size viewsize = activeDiagram.View.Size; // Set the view''s origin and size to // encompass the whole diagram activeDiagram.View.Origin = new PointF(0, 0); activeDiagram.View.Size = new Size((int)activeDiagram.Model.Width, (int)activeDiagram.Model.Height); // Create a Bitmap equal to the model // dimensions and create a Graphics object // from the image Bitmap diagramimage = new Bitmap((int)activeDiagram.Model.Width, (int)activeDiagram.Model.Height); Graphics bmpgrfx = Graphics.FromImage(diagramimage); // Draw the Diagram.View''s contents onto // the Image Graphics object activeDiagram.View.Draw(bmpgrfx); bmpgrfx.Dispose(); // The diagramimage is now a full rendering // of the Diagram contents and can be used // in any format diagramimage.Save("C:\\diagramsurface.bmp", System.Drawing.Imaging.ImageFormat.Bmp); // Restore the View''s origin and size activeDiagram.View.Origin = vieworigin; activeDiagram.View.Size = viewsize;

Rich
Replied On June 21, 2004 12:58 AM UTC

Thanks Prakash, This saves the file, but the diagram component does not refresh after the save until the drawing surface is clicked. I have tried the following lines with no avail this.Diagram.Refresh(); this.diagramComponent.Focus(); this.diagramComponent.Refresh(); this.Focus(); this.Refresh();

Rich
Replied On June 21, 2004 01:02 AM UTC

I am using this as part of an MDI, in case this makes any difference

Administrator [Syncfusion]
Replied On June 22, 2004 11:07 AM UTC

Richard, The Diagram''s Model.UpdateViews() method will force an update of all views tied to the diagram model. Prakash Syncfusion, Inc

Administrator [Syncfusion]
Replied On October 11, 2004 06:59 PM UTC

Hi, Prakash -- I''m afraid that the Export to Bitmap functionality doesn''t work well. As with all other image rendering in Diagram, the problem is when you change GraphicsUnits. I set the Diagram''s GraphicsUnits to Millimeters. However, that doesn''t work when the Bitmap size is set. If my Diagram is 280 or so mm wide, the image that''s created is only 280 pixels wide. The export also exports the View''s Rulers. The 2 attached images show the original screenshot of the full Diagram that I attempted to export, and the other image shows the exported image. The code needs to convert from the ints for whatever GraphicsUnits are set in the active Diagram to dimensions that are appropriate for a Bitmap. It also needs to save whether the Ruler is showing, then hide it if it''s showing, and turn off the Grid (and restore it later). Of course, I can do the latter 2 steps easily enough, but are there any built in conversion utilities that can convert the ints for the Diagram''s dimensions in MM to dimensions appropriate for a Bitmap? It would be nice if there were a method like: Size bitmapSize = GetSizeForBitmap(activeDiagram) This method could inspect the Diagram and dynamically make the right conversions depending on what the Diagram''s GraphicsUnits are set to. Thanks, Anthony

Administrator [Syncfusion]
Replied On October 11, 2004 07:14 PM UTC

It would help if I attached the images, wouldn''t it? :-) - A Diagram_Export_Images_8113.zip

Administrator [Syncfusion]
Replied On October 12, 2004 04:31 PM UTC

Hi Anthony, Yes, we can see this problem. Thanks also for your feedback on this issue with reference to the Rulers being visible. I am going ahead and logging a high priority QA incident on this issue. Do not hesitate to contact us if you have any further questions. Regards Arun

CONFIRMATION

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.

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

;