[.net] Dimensions of display in centimeters

Started by
5 comments, last by Mike.Popoloski 16 years, 10 months ago
Hello, I am trying to get dimensions of my display in centimeters (programmically in C# code). How could I achieve this? Thanks in advance.
Advertisement
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).
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.
Mike Popoloski | Journal | SlimDX
Actually, this information is reported in the EDID from the monitor. Undoubtably many devices will report this incorrectly though.
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?
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.
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.
Mike Popoloski | Journal | SlimDX

This topic is closed to new replies.

Advertisement