Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Print Preview not same as display (Read 4252 times)
Kyle Chen
Full Member
***
Offline


I Love MindFusion!

Posts: 104
Joined: Nov 29th, 2012
Print Preview not same as display
Jan 25th, 2013 at 3:38pm
Print Post  
Hi,

I have a diagram with some nodes. Each node will display an image (use node.Image and call FitSizeToImage to resize). The image might have different resolution (by setting the resolution of bitmap). Diagram can display them using custom resolution perfectly! However the print preview will failed on that. Can you look into that?

I currently have to workaround this: export the diagram to an image then use another diagram to show it then preview - it worked but really ugly...

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Print Preview not same as display
Reply #1 - Jan 25th, 2013 at 5:38pm
Print Post  
Hi,

Image size in preview looks ok in our test app as shown below. ImageAlign is set to TopLeft there and the node is resized using ResizeToFitImage. Could you attach one of the images you are showing in nodes that has the problem? As a workaround, try setting ImageAlign to Fit or Stretch, that should fill the node regardless of the image resolution.

Stoyan

  
Back to top
 
IP Logged
 
Kyle Chen
Full Member
***
Offline


I Love MindFusion!

Posts: 104
Joined: Nov 29th, 2012
Re: Print Preview not same as display
Reply #2 - Jan 28th, 2013 at 8:57pm
Print Post  
sorry for late response. I will try to generate a sample for you to test. Before that, if you have time, you may do some test following my steps below:

All images I'm using are created dynamically as 1bppindexed bmp then assingn to node.Image:
Bitmap bmp = GenerateBitmapRouting(...); // 1bppindexed
bmp.SetResolution(dpiX, dpiY);
ShapeNode node = CreateNodeRouting(...);
node.Image = bmp;
node.ResizeToFitImage();

And I'm using LaneGrid to show my nodes/image. Nodes in each lane will have different dpiX and/or dpiY. In display it shows just the sizes I wanted - each image applying to its resolution. In preview, seems not the same. You may take a look at the screenshot Tongue

Thanks
« Last Edit: Jan 29th, 2013 at 4:10pm by Kyle Chen »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Print Preview not same as display
Reply #3 - Jan 29th, 2013 at 7:14am
Print Post  
Nodes and lanes seem to have the wrong size too, so I suppose you have set MeasureUnit to Pixel? This mode draws and prints using the device physical pixel size, unlike the logical units which apply some scale to get device-independent output. Since printers have much smaller pixels and .NET applies the printer's resolution to the preview control, you won't get the same results as in the DiagramView. You can either change your units permanently to logical ones, or create a copy of the diagram for print / preview and switch to Point there.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Kyle Chen
Full Member
***
Offline


I Love MindFusion!

Posts: 104
Joined: Nov 29th, 2012
Re: Print Preview not same as display
Reply #4 - Jan 29th, 2013 at 4:09pm
Print Post  
Yep. I'm using Pixel for calculation reasons. I have to stick to it. So I have to stick to create a new diagram then use an exported bitmap... Fortunately it's a work out.
Thank you for looking into it! (I will remove the image above for security reason.)
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Print Preview not same as display
Reply #5 - Jan 29th, 2013 at 7:08pm
Print Post  
You might also try the copy approach, with MeasureUnit changed to Point and additional PrintOptions.Scale applied to make dimensions closer to screen:

Code
Select All
var screenResolution = CreateGraphics().DpiX;
var printerResolution = 72f; // for Point unit

var diagramView = new DiagramView();
diagramView.Diagram.LoadFromString(diagram.SaveToString()); // copy main diagram
diagramView.Diagram.MeasureUnit = GraphicsUnit.Point;
diagramView.PrintOptions.Scale = 100f * printerResolution / screenResolution;
diagramView.PrintPreview(); 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Kyle Chen
Full Member
***
Offline


I Love MindFusion!

Posts: 104
Joined: Nov 29th, 2012
Re: Print Preview not same as display
Reply #6 - Jan 30th, 2013 at 2:55pm
Print Post  
Hi Stoyan,

It's better than the image I post yesterday but still not the same as the screen. The LaneGrid is too high? If we can fix this, this would be a better workaround. Cheesy

Thank you!
« Last Edit: Jan 31st, 2013 at 8:38pm by Kyle Chen »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Print Preview not same as display
Reply #7 - Jan 30th, 2013 at 4:51pm
Print Post  
Are you using the actual diagram.LaneGrid, or that's something you draw from DrawBackground / DrawForeground event handlers?
  
Back to top
 
IP Logged
 
Kyle Chen
Full Member
***
Offline


I Love MindFusion!

Posts: 104
Joined: Nov 29th, 2012
Re: Print Preview not same as display
Reply #8 - Jan 30th, 2013 at 9:43pm
Print Post  
The background (Color.Wheat) is what I'm using to fill the laneGrid (using LaneGrid.RowHeader[i].Style = ...). And The red line actually regular link I added at the edge of laneGrid.

Stoyo wrote on Jan 30th, 2013 at 4:51pm:
Are you using the actual diagram.LaneGrid, or that's something you draw from DrawBackground / DrawForeground event handlers?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Print Preview not same as display
Reply #9 - Jan 31st, 2013 at 12:02pm
Print Post  
Perhaps the custom image DPI does not work that well within the metafile used to render print preview. Does it look better if you print on the actual printer? In any case, you could change ImageAlign to Stretch and make the nodes as big as the lanes in the printed diagram copy - then the images should fill lane heights completely.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Kyle Chen
Full Member
***
Offline


I Love MindFusion!

Posts: 104
Joined: Nov 29th, 2012
Re: Print Preview not same as display
Reply #10 - Jan 31st, 2013 at 8:38pm
Print Post  
Thank you for your patience, Stoyan. I just save the nodes to an Image(which is WSYWYG absolutely) then show it in a preview diagramView. So far, it works fine now.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint