AD
Administrator
Syncfusion Team
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;
RI
Rich
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();
RI
Rich
June 21, 2004 01:02 AM UTC
I am using this as part of an MDI, in case this makes any difference
AD
Administrator
Syncfusion Team
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
AD
Administrator
Syncfusion Team
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
AD
Administrator
Syncfusion Team
October 11, 2004 07:14 PM UTC
It would help if I attached the images, wouldn''t it? :-)
- A
Diagram_Export_Images_8113.zip
AD
Administrator
Syncfusion Team
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