Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic DrawImage rendering blurry on DrawNode event (Read 3919 times)
Gabriel
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 30
Joined: Oct 9th, 2012
DrawImage rendering blurry on DrawNode event
Sep 17th, 2014 at 8:53am
Print Post  
Hello,

I have a flowchart diagram Node on which I want to draw a bmp.

I'm using the flowChart.DrawNode event and using the DrawNodeEventArgs to retrieve the graphics and draw the image on it:

Code
Select All
public void flowChart_DrawBox(object sender, DrawNodeEventArgs e)
{
   // bmp is an image generated on the fly
   e.Graphics.DrawImage(bmp, Rectangle.Ceiling(e.Bounds));
} 



The bmp used is the same exact size as the node bounds, and when I save the bmp to a file to take a look it is tack sharp (using paint at 100%), however the node shows it blurred without definition.

I have set all graphics parameters like:
Code
Select All
 e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
  e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
  e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
  e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; 



But the problem persist.

The only way to have it renderer with an acceptable quality is generating the bmp twice the size of the node, but that is not an option as the image becomes very huge.

have I missed something? Is there anything I can do / adjust to make the node render it correctly?

thank you in advance
Gabriel
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: DrawImage rendering blurry on DrawNode event
Reply #1 - Sep 17th, 2014 at 9:04am
Print Post  
Graphics.DrawImage renders blurry image when it isn't aligned exactly to device pixels, which is the usual case if you are not using Pixel as MeasureUnit value and node.Bounds does not contain integer coordinates. The built-in rendering of ShapeNode.Image should take care of aligning to device pixels, or if you prefer custom drawing, use the Utilities.DrawImage method from mindfusion.common.dll.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Gabriel
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 30
Joined: Oct 9th, 2012
Re: DrawImage rendering blurry on DrawNode event
Reply #2 - Sep 17th, 2014 at 9:39am
Print Post  
Thank you for the help,
I changed my code to use the utilities:

Utilities.DrawImage(e.Graphics, bmp, Rectangle.Ceiling(e.Bounds), MindFusion.Drawing.ImageAlign.Fit);

instead of e.Graphics.DrawImage.

It is better rendered but it is still not as sharp as the image.

I can't use the shapenode.Image, as we are generating the image on any zoom change.

Gabriel
  
Back to top
 
IP Logged
 
Gabriel
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 30
Joined: Oct 9th, 2012
Re: DrawImage rendering blurry on DrawNode event
Reply #3 - Sep 17th, 2014 at 10:14am
Print Post  
It worked.

In addition to use the DrawImage from the utilities, I also needed to generate the bmp using the DocToDevice method to ensure that the size is the correct.

Thank you very much for your help

Gabriel
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint