Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Unable to take snap shot of diagram. (Read 7515 times)
Yogendra
Junior Member
**
Offline


I Love MindFusion!

Posts: 68
Joined: Dec 27th, 2012
Unable to take snap shot of diagram.
Jul 15th, 2013 at 11:22am
Print Post  
Hi Stoyo,

I am working with diagram and can change diagram bounds from UI. At this time, there is no issue but when we set bounds say(0,0,5000,5000) and go to save the content of diagram in database and try to take snap shot of diagram, Diagram.SaveToPng  method raised the out of memory exception.
Exception is An exception of type 'System.OutOfMemoryException' occurred in System.Windows.dll but was not handled in user code

I have attached sample project, you can easily find issue with my code. Please suggest me something.

Thanks in advanced. Smiley
  

DiagramBounds.rar (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Unable to take snap shot of diagram.
Reply #1 - Jul 15th, 2013 at 5:08pm
Print Post  
Hi,

You will have to use third-party image encoders, you can find an example here:
http://mindfusion.eu/Forum/YaBB.pl?num=1328022990/1#1

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Yogendra
Junior Member
**
Offline


I Love MindFusion!

Posts: 68
Joined: Dec 27th, 2012
Re: Unable to take snap shot of diagram.
Reply #2 - Jul 31st, 2013 at 8:12am
Print Post  
Hi stoyo,

I did same thing to create image of diagram as mentioned in the link.

Step:-

Set diagram bounds as
Code
Select All
       Dim BGBounds = New Rect(0, 0, 2050, 2050) [code] 


diagram.Bounds = BGBounds
BGNode.Bounds = BGBounds
[/code]

and set zoom factor of Diagram to 500, code:
Code
Select All
diagram.ZoomFactor = 500
 



and try to create image using this code:-
Code
Select All
 Dim bitmap As WriteableBitmap = diagram.CreateImage()
 

.

But it show exception. Exception was:

Exception of type 'System.OutOfMemoryException' was thrown.

at System.Windows.Media.Imaging.WriteableBitmap.AllocPixelBuffer()
at System.Windows.Media.Imaging.WriteableBitmap..ctor(UIElement element, Transform transform)
at MindFusion.Diagramming.Silverlight.Diagram.CreateImage(Double scale)
at MindFusion.Diagramming.Silverlight.Diagram.CreateImage().

Please suggest something...
Thanks in advance. Smiley

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Unable to take snap shot of diagram.
Reply #3 - Jul 31st, 2013 at 8:51am
Print Post  
This test shows the exception happening at 8000 x 8000 pixels, so I suppose that's the max image size supported by Silverlight:

Code
Select All
for (int size = 5000; size < 20000; size += 500)
{
	try
	{
		var bmp = new WriteableBitmap(size, size);
		GC.Collect();
	}
	catch (OutOfMemoryException)
	{
		MessageBox.Show("size: " + size);
		break;
	}
} 



In your case the image is 10250 x 10250 pixels due to the 500 zoom level, so you will have to either export without zoom, or split the images into several smaller parts and export them separately. You could do the latter by setting smaller diagram.Bounds, e.g. starting from Rect(0,0,1000,1000) and adding 1000 pixels offset by X and Y from nested loops, then exporting the smaller diagrams.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint