- Welcome, Guest. Please Login or Register
MindFusion  
  Version 2 of our Xamarin Calendar component adds Resource view and support for Universal Windows Platform. Now beta testing spreadsheet component for Java Swing. We have released our Java Swing Pack.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Reset ZoomFactor in CreateImage
Read 98 times

vremennyi   Offline
YaBB Newbies
*
Posts: 5
Gender: male


   
     
 
Reset ZoomFactor in CreateImage
Sep 12th, 2017 at 7:49am
 
I need to export diagram image at 100% size.
Diagram.CreateImage uses ZoomFactor from DiagramView and resizes all layers in diagram in the exported image.
Reset ZoomFactor to 100 before exporting works only on small diagrams that fit in the View. Large diagrams are blurred during export.
Is there a way to get a clear diagram image in 100% size?
In addition it would be great if there is the way to export any Rect to image, i.e. Diagram.GetContentBounds() in default.

Added export button to Demo project

Code (HTML):
  
<Menu Height="22" Margin="0,0,0,0" Name="mainMenu" VerticalAlignment="Top" HorizontalAlignment="Stretch">
 <MenuItem Name="mFile" Header="_File">
 ...
  <MenuItem Name="mPrintPreview" Header="Print Pre_view..." Click="mPreview_Click" />
  <MenuItem Name="mExportToImage" Header="Export to image..." Click="mExportToImage_Click" />
 ...
 </MenuItem>
 



Code (C++):
private void mExportToImage_Click(object sender, RoutedEventArgs e)
{
 diagram.ZoomFactor = 100.0;
 var image = diagram.CreateImage();
 var tempFileName = "D:\\Temp\\123.png";
 Utilities.SaveImage(image, tempFileName);
 Process.Start(tempFileName);
}
 


 
 

123.png (145 KB | 4 )
123.png
 
IP Logged    
 
     

vremennyi   Offline
YaBB Newbies
*
Posts: 5
Gender: male


   
     
 
Re: Reset ZoomFactor in CreateImage
Reply #1 - Sep 12th, 2017 at 8:04am
 
Without reseting ZoomFactor to 100% just getting transparent borders.
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1141
Gender: male
tech.support


   
     
 
Re: Reset ZoomFactor in CreateImage
Reply #2 - Sep 12th, 2017 at 8:09am
 
Have you tried using the CreateImage(100) overload? I'll test it from the demo project.
 
 
 
IP Logged    
 
     

vremennyi   Offline
YaBB Newbies
*
Posts: 5
Gender: male


   
     
 
Re: Reset ZoomFactor in CreateImage
Reply #3 - Sep 12th, 2017 at 8:12am
 
Slavcho wrote on Sep 12th, 2017 at 8:09am:
Have you tried using the CreateImage(100) overload? I'll test it from the demo project.

CreateImage calls CreateImage(100) - same result.
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1141
Gender: male
tech.support


   
     
 
Re: Reset ZoomFactor in CreateImage
Reply #4 - Sep 12th, 2017 at 8:27am
 
Right, the exported boundaries are incorrect if the diagram is zoomed. Try calling UpdateLayout after resetting until we fix that -

Code:
diagram.ZoomFactor = 100;
diagram.UpdateLayout();
var image = diagram.CreateImage(); 

 
 
 
IP Logged    
 
     

vremennyi   Offline
YaBB Newbies
*
Posts: 5
Gender: male


   
     
 
Re: Reset ZoomFactor in CreateImage
Reply #5 - Sep 12th, 2017 at 9:14am
 
Main question about blurried images. See Attachment1.
Slavcho wrote on Sep 12th, 2017 at 8:27am:
Right, the exported boundaries are incorrect if the diagram is zoomed. Try calling UpdateLayout after resetting until we fix that

It doesn't help)
First diagram in Demo, same code + UpdateLayout
Code (C++):
diagram.ZoomFactor = 100.0;
diagram.UpdateLayout();
var image = diagram.CreateImage();
var tempFileName = "D:\\Temp\\123.png";
Utilities.SaveImage(image, tempFileName);
Process.Start(tempFileName); 

 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1141
Gender: male
tech.support


   
     
 
Re: Reset ZoomFactor in CreateImage
Reply #6 - Sep 12th, 2017 at 9:28am
 
I'm not seeing a blurred image after export, is your attachment the actual exported file or a screenshot of it in some application? What's the original zoom value when you click the export menu item? My export is attached, seems crisp enough.
 
 

123_001.png (88 KB | 3 )
123_001.png
 
IP Logged    
 
     

vremennyi   Offline
YaBB Newbies
*
Posts: 5
Gender: male


   
     
 
Re: Reset ZoomFactor in CreateImage
Reply #7 - Sep 12th, 2017 at 9:45am
 
Slavcho wrote on Sep 12th, 2017 at 9:28am:
I'm not seeing a blurred image after export, is your attachment the actual exported file or a screenshot of it in some application? What's the original zoom value when you click the export menu item? My export is attached, seems crisp enough.

Just downloaded Demo.CS again and added export menu item with same code again.

Can't attach screencast, uploaded here: https://www.dropbox.com/s/mcmmwl7myr2febn/2017-09-12_13-40-48.mp4?dl=0

Online preview is blurried))) Watch downloaded.
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1141
Gender: male
tech.support


   
     
 
Re: Reset ZoomFactor in CreateImage
Reply #8 - Sep 12th, 2017 at 9:59am
 
Yes, I've reproduced when exporting a very large image. Our developer will investigate.
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1141
Gender: male
tech.support


   
     
 
Re: Reset ZoomFactor in CreateImage
Reply #9 - Sep 12th, 2017 at 4:10pm
 
That seems a known problem with RenderTargetBitmap, e.g.
https://stackoverflow.com/questions/34745384/image-looks-blur-created-using-rend
ertargetbitamp-in-wpf

Our guess is it could be related to max texture size of video card, WPF being backed by DirectX... We'll try to find some work-around.
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1141
Gender: male
tech.support


   
     
 
Re: Reset ZoomFactor in CreateImage
Reply #10 - Sep 13th, 2017 at 11:56am
 
This build glues the exported bitmap from smaller RenderTargetBitmaps, that seems to fix the blurry output -
https://mindfusion.eu/_beta/wpfdiag351.zip

Also you should no longer have to set ZoomFactor.

Regards,
Slavcho
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print