all groups > dotnet drawing api > february 2004 >
You're in the

dotnet drawing api

group:

PageUnit = Inches - that's not what I'm getting



PageUnit = Inches - that's not what I'm getting FinallyInSeattle
2/28/2004 3:51:34 PM
dotnet drawing api: I've started experimenting with coordinate systems and created a very
simple form with the following paint event.

private void Form1_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
Pen bluePen = new Pen(Color.Blue,1/e.Graphics.DpiX);
e.Graphics.PageUnit = GraphicsUnit.Inch;
e.Graphics.DrawRectangle(bluePen,0,0,1,1);
bluePen.Dispose();
}

I would expect a rectangle that is 1" x 1" but it's a little short of
3/4 of an inch square. Am I missing something?

I'm running on a laptop with my display panel as the active device, so
it's not the monitor isn't configured correctly.

Thanks in advance for your help!


*** Sent via Developersdex http://www.developersdex.com ***
Re: PageUnit = Inches - that's not what I'm getting Frank Hileman
2/29/2004 5:58:05 AM
It is the definition of "Dpi" that is getting you. You logically assume this
means "dots per inch". In fact, dpi in windows is a user defined setting.
Look at your display properties. You will see, under the Settings tab, an
Advanced button. On the dialog that opens, under the General tab, you will
find a drop-down to select dpi (on XP). So there may be only a vague
relationship between the dpi provided in windows, and the true pixels per
inch.

Regards,
Frank Hileman

check out VG.net: www.vgdotnet.com
Animated vector graphics system
Integrated VS.net graphics editor

[quoted text, click to view]

Re: PageUnit = Inches - that's not what I'm getting FinallyInSeattle
2/29/2004 9:51:28 AM
Hi Frank,

Thanks for the info! I need to be able to draw diagrams at approximately
the same size regardless of screen resolution. I was looking at storing
location & size in terms of inches and then rendering with a PageUnit =
Inches setting. From what I've read, this should be a
resolution-independent solution. But after trying different screen
resolutions, my rectangles just get bigger as the resolution decreases
because I always get Graphics.DpiX & DpiY = 96. What am I missing?

Thanks again!

*** Sent via Developersdex http://www.developersdex.com ***
Re: PageUnit = Inches - that's not what I'm getting Frank Hileman
2/29/2004 12:42:03 PM
Did you see this:
http://support.microsoft.com/?id=127152

You might also want to look at SystemInformation properties.

[quoted text, click to view]

Re: PageUnit = Inches - that's not what I'm getting FinallyInSeattle
2/29/2004 3:51:16 PM
Hi Frank,

Thanks for all your help. I guess the bottom line for me is that,
despite all the references that state otherwise, GDI+ really ISN'T
resolution-independent (even if you set the PageUnit to inches or
millimeters). If it were, then the physical size of a drawn rectangle
would remain the same when you increased or decreased the resolution of
your display.

Thanks again!

*** Sent via Developersdex http://www.developersdex.com ***
AddThis Social Bookmark Button