Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Where to change Graphics.InterpolationMode and Graphics.PixelOffsetMode (Read 2731 times)
Kyle Chen
Full Member
***
Offline


I Love MindFusion!

Posts: 104
Joined: Nov 29th, 2012
Where to change Graphics.InterpolationMode and Graphics.PixelOffsetMode
Dec 5th, 2013 at 2:57pm
Print Post  
Hi Stoyan,

Back to my old question, when I set a node's image to a bitmap with specified dpi, it will be scaled to non-integer width/height which caused some edge lines to turn gray instead of pure black or even disappear which is annoying. I wonder if it will help if I change graphics's InterpolationMode to NearestNeigbour and PixelOffsetMode to None.
If so, where is the best place to do it? (still to consider the drawing performance)

(What will the DiagramView.SmoothingMode affect? The enum shows it is like "PixelOffsetMode" but when I tried to change it, seems no effect at all)

Thanks,

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Where to change Graphics.InterpolationMode and Graphics.PixelOffsetMode
Reply #1 - Dec 6th, 2013 at 7:32am
Print Post  
Hi Kyle,

You could change Graphics rendering properties from overrides of the DiagramView.OnPaint or Diagram.Draw methods before calling base methods, or from the DrawBackground event handler, which it is raised before drawing diagram items.

DiagramView.SmoothingMode is assigned to Graphics.SmoothingMode and lets you enable or disable anti-aliasing.

If you use Pixel as MasureUnit, ZoomFactor is 100 and bitmap's DPI corresponds to screen's DPI, your bitmap pixels should be rendered coinciding with screen pixels. You could as well try to custom-draw images by calling GDI's DrawImageUnscaled  method.

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: Where to change Graphics.InterpolationMode and Graphics.PixelOffsetMode
Reply #2 - Dec 9th, 2013 at 4:09pm
Print Post  
Hi Stoyan,

Thank you so much! I override the DrawLocal of ShapeNode and set as following which generate better scale result in my application. If these properties can be exposed to DiagramView, it will be easier. (And still, the DiagramView.SmoothingMode seems no effect to this)

        public override void DrawLocal(MindFusion.Drawing.IGraphics graphics, RenderOptions options)
        {
            graphics.SmoothingMode = SmoothingMode.AntiAlias;
            graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None;

            base.DrawLocal(graphics, options);
        }


Kyle

Stoyo wrote on Dec 6th, 2013 at 7:32am:
Hi Kyle,

You could change Graphics rendering properties from overrides of the DiagramView.OnPaint or Diagram.Draw methods before calling base methods, or from the DrawBackground event handler, which it is raised before drawing diagram items.

DiagramView.SmoothingMode is assigned to Graphics.SmoothingMode and lets you enable or disable anti-aliasing.

If you use Pixel as MasureUnit, ZoomFactor is 100 and bitmap's DPI corresponds to screen's DPI, your bitmap pixels should be rendered coinciding with screen pixels. You could as well try to custom-draw images by calling GDI's DrawImageUnscaled method.

I hope that helps,
Stoyan

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