I am just starting with C# Graphics programming and need some help with this.
As I understand it, setting "..PageUnit=GraphicsUnits.Millimeter" means that the drawing units are taken to be mm.
However, in the following code the rectangle is displayed with dimensions 120mm square (as measured with a rular on the screen!)
protected override void OnPaint(PaintEventArgs e)
{
Graphics g=e.Graphics;
g.PageUnit = GraphicsUnit.Millimeter;
Rectangle bb= new Rectangle(0,0,100,100);
g.DrawRectangle(new Pen(Color.Red,1/g.DpiX ),bb);
}
If I change the code to draw a box 3.937" (equivalent to 100mm) and set the GraphicUnits to Inch - I also get a box about 120mm square.
protected override void OnPaint(PaintEventArgs e)
{
Graphics g=e.Graphics;
g.PageUnit = GraphicsUnit.Inch;
RectangleF bb= new RectangleF(0,0,3.937008f,3.937008f);
g.DrawRectangle(new Pen(Color.Red,1/g.DpiX ),Rectangle.Round(bb));
}
It seems as if the real measurements on screen are different to what I expect - am I missing something here.
This is important as I need to show real word objects at their correct size on screen and printed reports.
Any help anyone can offer will be much appreciated
Phil Cunningham 3 5053
Sounds like the resolution that Windows believes your monitor is and the
resolution is actually is are different. However, I'm not sure how you
would go about properly configuring Windows, and my guess would be that
most people's computers are not properly configured for this.
Ryan
phil cunningham wrote: I am just starting with C# Graphics programming and need some help with this.
As I understand it, setting "..PageUnit=GraphicsUnits.Millimeter" means that the drawing units are taken to be mm. However, in the following code the rectangle is displayed with dimensions 120mm square (as measured with a rular on the screen!)
protected override void OnPaint(PaintEventArgs e) { Graphics g=e.Graphics; g.PageUnit = *GraphicsUnit.Millimeter; Rectangle bb= new Rectangle(0,0,100,100);* g.DrawRectangle(new Pen(Color.Red,1/g.DpiX ),bb); }
If I change the code to draw a box 3.937" (equivalent to 100mm) and set the GraphicUnits to Inch - I also get a box about 120mm square.
protected override void OnPaint(PaintEventArgs e) { Graphics g=e.Graphics; g.PageUnit = *GraphicsUnit.Inch; RectangleF bb= new RectangleF(0,0,3.937008f,3.937008f);* g.DrawRectangle(new Pen(Color.Red,1/g.DpiX ),Rectangle.Round(bb)); }
It seems as if the real measurements on screen are different to what I expect - am I missing something here.
This is important as I need to show real word objects at their correct size on screen and printed reports.
Any help anyone can offer will be much appreciated
Phil Cunningham
You can adjust your monitor's DPI-setting under Control Panel - Display
Properties - Settings Tab - Advanced. AFAIK this value is used for pixel-mm
conversion. However you should assume that many people got that setting
wrong, and that few of them will want to change it for your application (it
also changes dialog font sizes, control sizes, etc). You should probably use
your own calibration factor for screen display.
However the GDI value should be correct for printers and metafiles.
Niki
"phil cunningham" <ph**@oakleafsoftwareNOSPAM.co.uk> wrote in
news:eN*************@TK2MSFTNGP10.phx.gbl...
I am just starting with C# Graphics programming and need some help with
this.
As I understand it, setting "..PageUnit=GraphicsUnits.Millimeter" means that
the drawing units are taken to be mm.
However, in the following code the rectangle is displayed with dimensions
120mm square (as measured with a rular on the screen!)
protected override void OnPaint(PaintEventArgs e)
{
Graphics g=e.Graphics;
g.PageUnit = GraphicsUnit.Millimeter;
Rectangle bb= new Rectangle(0,0,100,100);
g.DrawRectangle(new Pen(Color.Red,1/g.DpiX ),bb);
}
If I change the code to draw a box 3.937" (equivalent to 100mm) and set the
GraphicUnits to Inch - I also get a box about 120mm square.
protected override void OnPaint(PaintEventArgs e)
{
Graphics g=e.Graphics;
g.PageUnit = GraphicsUnit.Inch;
RectangleF bb= new RectangleF(0,0,3.937008f,3.937008f);
g.DrawRectangle(new Pen(Color.Red,1/g.DpiX ),Rectangle.Round(bb));
}
It seems as if the real measurements on screen are different to what I
expect - am I missing something here.
This is important as I need to show real word objects at their correct size
on screen and printed reports.
Any help anyone can offer will be much appreciated
Phil Cunningham
As long as the printed reports are accurate I am happy with that.
Thanks for the very fast reply
Phil
"Niki Estner" <ni*********@cube.net> wrote in message
news:OX**************@TK2MSFTNGP11.phx.gbl... You can adjust your monitor's DPI-setting under Control Panel - Display Properties - Settings Tab - Advanced. AFAIK this value is used for
pixel-mm conversion. However you should assume that many people got that setting wrong, and that few of them will want to change it for your application
(it also changes dialog font sizes, control sizes, etc). You should probably
use your own calibration factor for screen display. However the GDI value should be correct for printers and metafiles.
Niki
"phil cunningham" <ph**@oakleafsoftwareNOSPAM.co.uk> wrote in news:eN*************@TK2MSFTNGP10.phx.gbl... I am just starting with C# Graphics programming and need some help with this.
As I understand it, setting "..PageUnit=GraphicsUnits.Millimeter" means
that the drawing units are taken to be mm. However, in the following code the rectangle is displayed with dimensions 120mm square (as measured with a rular on the screen!)
protected override void OnPaint(PaintEventArgs e) { Graphics g=e.Graphics; g.PageUnit = GraphicsUnit.Millimeter; Rectangle bb= new Rectangle(0,0,100,100); g.DrawRectangle(new Pen(Color.Red,1/g.DpiX ),bb); }
If I change the code to draw a box 3.937" (equivalent to 100mm) and set
the GraphicUnits to Inch - I also get a box about 120mm square.
protected override void OnPaint(PaintEventArgs e) { Graphics g=e.Graphics; g.PageUnit = GraphicsUnit.Inch; RectangleF bb= new RectangleF(0,0,3.937008f,3.937008f); g.DrawRectangle(new Pen(Color.Red,1/g.DpiX ),Rectangle.Round(bb)); }
It seems as if the real measurements on screen are different to what I expect - am I missing something here.
This is important as I need to show real word objects at their correct
size on screen and printed reports.
Any help anyone can offer will be much appreciated
Phil Cunningham
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Developwebsites |
last post by:
Hi all,
I've made a sliding puzzle game in shockwave which works just
fine, except I dont know how to have it solve itself.
the URL is:
http://members.aol.com/rglukov/games/selfsolve.htm
...
|
by: xavier vazquez |
last post by:
I have a problem with a program that does not working properly...when the program run is suppose to generate a cross word puzzle , when the outcome show the letter of the words overlap one intop of...
|
by: xavier vazquez |
last post by:
have a problem with a program that does not working properly...when the program run is suppose to generate a cross word puzzle , when the outcome show the letter of the words overlap one intop of the...
|
by: ashish0799 |
last post by:
HI I M ASHISH I WANT ALGORYTHMUS OF THIS PROBLEM
Jigsaw puzzles. You would have solved many in your childhood and many people still
like it in their old ages also. Now what you have got to do...
|
by: oncue01 |
last post by:
Word Puzzle
Task
You are going to search M words in an N × N puzzle. The words may have
been placed in one of the four directions as from (i) left to right (E), (ii) right
to left (W), (iii) up...
| |
by: Phoe6 |
last post by:
Hi All,
I would like to request a code and design review of one of my program.
n-puzzle.py
http://sarovar.org/snippet/detail.php?type=snippet&id=83
Its a N-puzzle problem solver ( Wikipedia page...
|
by: Gio |
last post by:
I'm getting K&R (it's on the way), should I also get the Answer Book?
And while I'm there, should I get the Puzzle Book? Or should I save the
Puzzle Book for when I'm more advanced?
- Gio
...
|
by: honey777 |
last post by:
Problem: 15 Puzzle
This is a common puzzle with a 4x4 playing space with 15 tiles, numbered 1 through 15. One "spot" is always left blank. Here is an example of the puzzle:
The goal is to...
|
by: dmf1207 |
last post by:
Hi All! I'm new to javascript and need a little help with a simple puzzle im trying to design. I have a 600x100 pixel picture that I have sliced into 6 100x100 rectangles making a table of of 6...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |