Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to ignore resolution of background image? (Read 3022 times)
Rennie
Full Member
***
Offline


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
How to ignore resolution of background image?
May 3rd, 2013 at 6:27am
Print Post  
When I specify a background image via Diagram.BackgroundImage, it is displayed according to the resolution (dpi) specified in the Image object. This may be 300dpi or 72dpi or something else - at the moment I'm just accepting the dpi specified in the user's .jpg or .png file.

Is there some way to get DiagramView's rendering to ignore the resolution and just display the image pixel-for-pixel?

Alternatively, what's the recommended way to modify the resolution settings in the Image object so it matches the screen resolution?

Thanks,
Rennie
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to ignore resolution of background image?
Reply #1 - May 3rd, 2013 at 7:56am
Print Post  
You could draw an image using Graphics methods from DrawBackground event handler, instead of setting BackgroundImage. Don't use the Utilities.DrawImage method, because it does the resolution scaling you don't want.

Another way to achieve that could be setting the HorizontalResolution and VerticalResolution properties of the BackgroundImage to values corresponding to your screen resolution.

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


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
Re: How to ignore resolution of background image?
Reply #2 - May 4th, 2013 at 12:38am
Print Post  
Thanks, I've gotten it to work using your first suggestion. Thanks for good support.

(Your second suggestion doesn't work - the HorizontalResolution and VerticalResolution properties do not have setters.)
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to ignore resolution of background image?
Reply #3 - May 6th, 2013 at 5:51am
Print Post  
You can still change the resolution property values using the Bitmap.SetResolution method.

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


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
Re: How to ignore resolution of background image?
Reply #4 - May 6th, 2013 at 11:16am
Print Post  
OK, I'm trying this now, and it seems to work:

Code
Select All
using (Graphics graphicsObject = this.CreateGraphics())
{
   ((Bitmap)_diagramView.Diagram.BackgroundImage).SetResolution(graphicsObject.DpiX,
                                                                graphicsObject.DpiY);
} 



Is this what you meant? Is there a simpler way of doing it?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to ignore resolution of background image?
Reply #5 - May 6th, 2013 at 2:22pm
Print Post  
Yes; this looks simple enough Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint