473,666 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GraphicsUnits - puzzle

I am just starting with C# Graphics programming and need some help with this.

As I understand it, setting "..PageUnit=Gra phicsUnits.Mill imeter" 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(PaintEv entArgs e)
{
Graphics g=e.Graphics;
g.PageUnit = GraphicsUnit.Mi llimeter;
Rectangle bb= new Rectangle(0,0,1 00,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(PaintEv entArgs e)
{
Graphics g=e.Graphics;
g.PageUnit = GraphicsUnit.In ch;
RectangleF bb= new RectangleF(0,0, 3.937008f,3.937 008f);
g.DrawRectangle (new Pen(Color.Red,1/g.DpiX ),Rectangle.Rou nd(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
Nov 16 '05 #1
3 5061
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=Gra phicsUnits.Mill imeter" 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(PaintEv entArgs e)
{
Graphics g=e.Graphics;
g.PageUnit = *GraphicsUnit.M illimeter;
Rectangle bb= new Rectangle(0,0,1 00,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(PaintEv entArgs e)
{
Graphics g=e.Graphics;
g.PageUnit = *GraphicsUnit.I nch;
RectangleF bb= new RectangleF(0,0, 3.937008f,3.937 008f);*
g.DrawRectangle (new Pen(Color.Red,1/g.DpiX ),Rectangle.Rou nd(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

Nov 16 '05 #2
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**@oakleafso ftwareNOSPAM.co .uk> wrote in
news:eN******** *****@TK2MSFTNG P10.phx.gbl...
I am just starting with C# Graphics programming and need some help with
this.

As I understand it, setting "..PageUnit=Gra phicsUnits.Mill imeter" 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(PaintEv entArgs e)
{
Graphics g=e.Graphics;
g.PageUnit = GraphicsUnit.Mi llimeter;
Rectangle bb= new Rectangle(0,0,1 00,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(PaintEv entArgs e)
{
Graphics g=e.Graphics;
g.PageUnit = GraphicsUnit.In ch;
RectangleF bb= new RectangleF(0,0, 3.937008f,3.937 008f);
g.DrawRectangle (new Pen(Color.Red,1/g.DpiX ),Rectangle.Rou nd(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
Nov 16 '05 #3
As long as the printed reports are accurate I am happy with that.

Thanks for the very fast reply

Phil

"Niki Estner" <ni*********@cu be.net> wrote in message
news:OX******** ******@TK2MSFTN GP11.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**@oakleafso ftwareNOSPAM.co .uk> wrote in
news:eN******** *****@TK2MSFTNG P10.phx.gbl...
I am just starting with C# Graphics programming and need some help with
this.

As I understand it, setting "..PageUnit=Gra phicsUnits.Mill imeter" 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(PaintEv entArgs e)
{
Graphics g=e.Graphics;
g.PageUnit = GraphicsUnit.Mi llimeter;
Rectangle bb= new Rectangle(0,0,1 00,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(PaintEv entArgs e)
{
Graphics g=e.Graphics;
g.PageUnit = GraphicsUnit.In ch;
RectangleF bb= new RectangleF(0,0, 3.937008f,3.937 008f);
g.DrawRectangle (new Pen(Color.Red,1/g.DpiX ),Rectangle.Rou nd(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

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6096
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 There are lots of these on the net, made in java, flash, C++, javascript, etc. and as shareware, but none seem to be solving the puzzle by
1
13088
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 the other....how i can fix this the program look like this import java.util.ArrayList; import java.util.Random;
0
2013
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 other....how i can fix this this run the random words for the program import javax.swing.JOptionPane; import java.util.ArrayList; import java.util.Random; public class CrossWordPuzzleTester {
5
4460
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 is to solve jigsaw puzzles using the computer. The jigsaw puzzle here is a square of dimension d (a puzzle with d^2 pieces) and the jigsaw pieces (all same dimensions) are of dimensions H x W (Which means the pieces have ‘H’ rows of ‘W’...
3
3201
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 to bottom (S), or (iv) bottom to up (N). The program will print the starting place and the direction of each word. Limitations The number of words to be searched can be at most 100, the size of the puzzle N can be minimum 5 maximum 20....
6
2571
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 and http://norvig.com/ltd/test/n-puzzle.lisp ) I have used OO Python for the above program and would like comments on my approach as I am just starting with OOP.
2
2694
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 -- AND NOW FOR A WORD (an IF blog):
4
19940
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 get the tiles in order, 1 through 15, from left to right, top to bottom, by just sliding tiles into the empty square. In this configuration, the goal would be to get the 14 and 15 to switch places, without affecting any of the other squares. Your...
5
4829
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 columns and 1 row. I wanted to make a "swap puzzle" where the user clicks on one image then the other and they swap. At first load i want to have the puzzle in a scrambled order and then when they complete it I want to alert the user with how many clicks...
0
8448
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8871
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8552
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8640
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5666
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.