Sign in to follow this  
Montynis

[.net] Dimensions of display in centimeters

Recommended Posts

Hello, I am trying to get dimensions of my display in centimeters (programmically in C# code). How could I achieve this? Thanks in advance.

Share this post


Link to post
Share on other sites
You can't. The computer has no information about the physical size of a monitor, to say nothing of projectors, or cloned displays (regular screen+projector).

Share this post


Link to post
Share on other sites
I'm afraid that you may be out of luck as far as the actual size of the monitor goes. You can easily find the size in pixels using the Screen class. Why exactly do you need the physical size of the monitor?

If you really need the size in centimeters, then you are going to have to do one of two things. First, you can try using the GetDeviceCaps function by using PInvoke to import the function. The only problem with this method is that the function almost always reports inaccurate sizes, sometimes up to 3 or 4 centimeters off the expected result.

The only other option would be to just ask the user what size monitor they have. For example, you could have a configuration section of the program where the user would enter the size of the monitor (ie. 15 inc, 17 inc, 20 inc), and the type of the monitor (LCD, CRT, projector) and then you could calculate the actual width and height of the monitor.

Share this post


Link to post
Share on other sites
Actually, this information is reported in the EDID from the monitor. Undoubtably many devices will report this incorrectly though.

Share this post


Link to post
Share on other sites
Quote:
Original post by ussnewjersey4
I'm afraid that you may be out of luck as far as the actual size of the monitor goes. You can easily find the size in pixels using the Screen class. Why exactly do you need the physical size of the monitor?


I need physical size of the monitor in order to create a scale on a map (map can be zoomed in or out). This scale shows what does one centimeter of screen means in reality (for example 1 cm : 50 km).

Has anybody any ideas how scale function is implemented in programs like Google Earth?

Share this post


Link to post
Share on other sites
Quote:
Original post by Montynis
Quote:
Original post by ussnewjersey4
I'm afraid that you may be out of luck as far as the actual size of the monitor goes. You can easily find the size in pixels using the Screen class. Why exactly do you need the physical size of the monitor?


I need physical size of the monitor in order to create a scale on a map (map can be zoomed in or out). This scale shows what does one centimeter of screen means in reality (for example 1 cm : 50 km).

Has anybody any ideas how scale function is implemented in programs like Google Earth?


And why do you need to know this? Will users be placing a ruler up against their monitor? Do you have any understanding about CRT monitors and how they are not fixed in the size that they display pixels (ever wonder what those little button at the bottom of the monitor do?) The only scale ruler that you will be using, and what Google uses, is one related to screen pixels, displayed on the screen. Because the ruler is on the screen, it's physical scale does not matter. You can take a snapshot of that screen and display it on a 50 foot high screen, and the rulers scale will still be accurate, showing that this[-------] is equal to one mile.

Share this post


Link to post
Share on other sites
Quote:
Original post by Montynis
Quote:
Original post by ussnewjersey4
I'm afraid that you may be out of luck as far as the actual size of the monitor goes. You can easily find the size in pixels using the Screen class. Why exactly do you need the physical size of the monitor?


I need physical size of the monitor in order to create a scale on a map (map can be zoomed in or out). This scale shows what does one centimeter of screen means in reality (for example 1 cm : 50 km).

Has anybody any ideas how scale function is implemented in programs like Google Earth?


Yes, its quite easy actually. Use the Screen class to get the size in pixels, and then just say that 1 pixel equals 1 km, or something like that. It doesn't matter what the base unit is as long as everything is proportioned correctly.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this