求助,正确获取屏幕物理大小

时间:2021-07-05 20:33:50
   请问如何正确获取屏幕的物理大小,我使用如下语句
    int nScreenWidth;  
    HDC hdcScreen = ::GetDC(NULL);  
    nScreenWidth = GetDeviceCaps(hdcScreen, HORZSIZE); 
   可惜获得的物理尺寸值和我的屏幕实际物理尺寸值相去甚远。且在不同分辨率的情况下获得的值也不一样,物理尺寸不是应该不变的吗?
   还有,我希望绘图是根据物理尺寸来的,比如每隔5毫米画一条线。我是根据屏幕分辨率和物理长度的比值来实现的,如果无法正确获取物理大小那么比值就不对,所以拜托大家帮帮忙

7 个解决方案

#1


这个肯定不行,应该不能通过API的方法获得显示器实际尺寸,除非另外编程,有驱动程序有接口告诉你。
Windows不可能知道你接的显示器有多大。

#2


hints:存在EDID里面的

#3


引用 1 楼 VisualEleven 的回复:
这个肯定不行,应该不能通过API的方法获得显示器实际尺寸,除非另外编程,有驱动程序有接口告诉你。
Windows不可能知道你接的显示器有多大。

那如何在不同的的分辨率下,正确的画出特定物理长度的图?

#4


引用 2 楼 derekrose 的回复:
hints:存在EDID里面的

如何使用?读取?

#5


GetMonitorInfo试试

#6


EDID 读取这个来实现。。现在EDID Ver 2

#7


00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F	0123456789ABCDEF
00 00 FF FF FF FF FF FF 00 41 0C 50 08 01 01 01 01 ........A.P.....
10 10 11 01 03 08 2F 1E 78 2E 93 45 A3 55 4A 98 27 ...../.x..E.UJ.'
20 15 50 54 BF EF 00 B3 00 A9 40 95 0F 95 00 81 C0 .PT......@......
30 81 40 71 4F 81 80 21 39 90 30 62 1A 27 40 68 B0 .@qO..!9.0b.'@h.
40 36 00 DA 28 11 00 00 1C 00 00 00 FF 00 43 4A 31 6..(.........CJ1
50 30 37 31 36 30 34 31 38 37 30 00 00 00 FC 00 50 0716041870.....P
60 68 69 6C 69 70 73 20 32 30 30 57 53 00 00 00 FD hilips 200WS....
70 00 38 4C 1E 5D 11 70 0A 20 32 30 30 57 53 00 18 .8L.].p. 200WS..

Header 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x00
Manufacture Name PHL
Product Code 0x0850
Serial Number 0x01010101 ()
Week 0x10 (16)
Year 0x11 (2007)
Version 0x01 (1)
Revision 0x03 (3)
Video Input 0x08 (Analog)
  Singal Level Standard 0.700,0.300 (1.000 V p-p)
  Setup 0
  Separate syncs. Supported
  Composite sync. Not supported
  Sync. on green video Not supported
  Serration of Vsync. pulse No
Max Horizontal Image Size 0x2F (47cm)
Max Vertical Image Size 0x1E (30cm)
Gamma 0x78 (2.200)
FeatureSupport 0x2E
  Standby 0
  Suspend 0
  Active off/Very low power 1
  Display type RGB color
  Color space, sRGB 1
  Preferred Timing Mode 1
  Default GTF supported 0
Color Characteristic 0x93 0x45 0xA3 0x55 0x4A 0x98 0x27 0x15 0x50 0x54
  Red_x 0x28E (0.639)
  Red_y 0x155 (0.333)
  Green_x 0x128 (0.289)
  Green_y 0x263 (0.597)
  Blue_x 0x09D (0.153)
  Blue_y 0x054 (0.082)
  White_x 0x141 (0.313)
  White_y 0x151 (0.329)
Established Timings 0xBF 0xEF 0x00
  720 x 400 @ 70Hz
  640 x 480 @ 60Hz
  640 x 480 @ 67Hz
  640 x 480 @ 72Hz
  640 x 480 @ 75Hz
  800 x 600 @ 56Hz
  800 x 600 @ 60Hz
  800 x 600 @ 72Hz
  800 x 600 @ 75Hz
  832 x 624 @ 75Hz
  1024 x 768 @ 60Hz
  1024 x 768 @ 70Hz
  1024 x 768 @ 75Hz
  1280 x 1024 @ 75Hz
Standard Timing #1 0xB3 0x00
  1680 x 1050 @ 60Hz (16:10)
Standard Timing #2 0xA9 0x40
  1600 x 1200 @ 60Hz (4:3)
Standard Timing #3 0x95 0x0F
  1440 x 900 @ 75Hz (16:10)
Standard Timing #4 0x95 0x00
  1440 x 900 @ 60Hz (16:10)
Standard Timing #5 0x81 0xC0
  1280 x 720 @ 60Hz (16:9)
Standard Timing #6 0x81 0x40
  1280 x 960 @ 60Hz (4:3)
Standard Timing #7 0x71 0x4F
  1152 x 864 @ 75Hz (4:3)
Standard Timing #8 0x81 0x80
  1280 x 1024 @ 60Hz (5:4)
Detailed Timing Descriptor 0x21 0x39 0x90 0x30 0x62 0x1A 0x27 0x40 0x68 0xB0 0x36 0x00 0xDA 0x28 0x11 0x00 0x00 0x1C 
  1680 x 1050 @ 58Hz
  Pixel clock 146.250MHz
  Horizontal active 1680 pixels
  Horizontal blanking 610 pixels
  Vertical active 1050 pixels
  Vertical blanking 39 pixels
  Horizontal sync. offset 104 pixels
  Horizontal sync. width 176 pixels
  Vertical sync. offset 3 lines
  Vertical sync. width 6 lines
  Horizontal Image Size 474 mm
  Vertical Image Size 296 mm
  Horizontal Border 0 pixels
  Vertical Border 0 lines
  Non-interlaced
  Normal display, no stereo
  Analog composite
  sync on green video line only
Monitor Descriptor 0x00 0x00 0x00 0xFF 0x00 0x43 0x4A 0x31 0x30 0x37 0x31 0x36 0x30 0x34 0x31 0x38 0x37 0x30 
  Monitor Serial Number CJ10716041870
Monitor Descriptor 0x00 0x00 0x00 0xFC 0x00 0x50 0x68 0x69 0x6C 0x69 0x70 0x73 0x20 0x32 0x30 0x30 0x57 0x53 
  Monitor Name Philips 200WS
Monitor Descriptor 0x00 0x00 0x00 0xFD 0x00 0x38 0x4C 0x1E 0x5D 0x11 0x70 0x0A 0x20 0x32 0x30 0x30 0x57 0x53 
  Monitor range limits
  Min. Vertical rate 56Hz
  Max. Vertical rate 76Hz
  Min. Horizontal rate 30kHz
  Max. Horizontal rate 93kHz
  Max. Pixel Clock 170MHz
Extension Flag 0x00
Checksum 0x18

EDID 的解析数据。。

#1


这个肯定不行,应该不能通过API的方法获得显示器实际尺寸,除非另外编程,有驱动程序有接口告诉你。
Windows不可能知道你接的显示器有多大。

#2


hints:存在EDID里面的

#3


引用 1 楼 VisualEleven 的回复:
这个肯定不行,应该不能通过API的方法获得显示器实际尺寸,除非另外编程,有驱动程序有接口告诉你。
Windows不可能知道你接的显示器有多大。

那如何在不同的的分辨率下,正确的画出特定物理长度的图?

#4


引用 2 楼 derekrose 的回复:
hints:存在EDID里面的

如何使用?读取?

#5


GetMonitorInfo试试

#6


EDID 读取这个来实现。。现在EDID Ver 2

#7


00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F	0123456789ABCDEF
00 00 FF FF FF FF FF FF 00 41 0C 50 08 01 01 01 01 ........A.P.....
10 10 11 01 03 08 2F 1E 78 2E 93 45 A3 55 4A 98 27 ...../.x..E.UJ.'
20 15 50 54 BF EF 00 B3 00 A9 40 95 0F 95 00 81 C0 .PT......@......
30 81 40 71 4F 81 80 21 39 90 30 62 1A 27 40 68 B0 .@qO..!9.0b.'@h.
40 36 00 DA 28 11 00 00 1C 00 00 00 FF 00 43 4A 31 6..(.........CJ1
50 30 37 31 36 30 34 31 38 37 30 00 00 00 FC 00 50 0716041870.....P
60 68 69 6C 69 70 73 20 32 30 30 57 53 00 00 00 FD hilips 200WS....
70 00 38 4C 1E 5D 11 70 0A 20 32 30 30 57 53 00 18 .8L.].p. 200WS..

Header 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x00
Manufacture Name PHL
Product Code 0x0850
Serial Number 0x01010101 ()
Week 0x10 (16)
Year 0x11 (2007)
Version 0x01 (1)
Revision 0x03 (3)
Video Input 0x08 (Analog)
  Singal Level Standard 0.700,0.300 (1.000 V p-p)
  Setup 0
  Separate syncs. Supported
  Composite sync. Not supported
  Sync. on green video Not supported
  Serration of Vsync. pulse No
Max Horizontal Image Size 0x2F (47cm)
Max Vertical Image Size 0x1E (30cm)
Gamma 0x78 (2.200)
FeatureSupport 0x2E
  Standby 0
  Suspend 0
  Active off/Very low power 1
  Display type RGB color
  Color space, sRGB 1
  Preferred Timing Mode 1
  Default GTF supported 0
Color Characteristic 0x93 0x45 0xA3 0x55 0x4A 0x98 0x27 0x15 0x50 0x54
  Red_x 0x28E (0.639)
  Red_y 0x155 (0.333)
  Green_x 0x128 (0.289)
  Green_y 0x263 (0.597)
  Blue_x 0x09D (0.153)
  Blue_y 0x054 (0.082)
  White_x 0x141 (0.313)
  White_y 0x151 (0.329)
Established Timings 0xBF 0xEF 0x00
  720 x 400 @ 70Hz
  640 x 480 @ 60Hz
  640 x 480 @ 67Hz
  640 x 480 @ 72Hz
  640 x 480 @ 75Hz
  800 x 600 @ 56Hz
  800 x 600 @ 60Hz
  800 x 600 @ 72Hz
  800 x 600 @ 75Hz
  832 x 624 @ 75Hz
  1024 x 768 @ 60Hz
  1024 x 768 @ 70Hz
  1024 x 768 @ 75Hz
  1280 x 1024 @ 75Hz
Standard Timing #1 0xB3 0x00
  1680 x 1050 @ 60Hz (16:10)
Standard Timing #2 0xA9 0x40
  1600 x 1200 @ 60Hz (4:3)
Standard Timing #3 0x95 0x0F
  1440 x 900 @ 75Hz (16:10)
Standard Timing #4 0x95 0x00
  1440 x 900 @ 60Hz (16:10)
Standard Timing #5 0x81 0xC0
  1280 x 720 @ 60Hz (16:9)
Standard Timing #6 0x81 0x40
  1280 x 960 @ 60Hz (4:3)
Standard Timing #7 0x71 0x4F
  1152 x 864 @ 75Hz (4:3)
Standard Timing #8 0x81 0x80
  1280 x 1024 @ 60Hz (5:4)
Detailed Timing Descriptor 0x21 0x39 0x90 0x30 0x62 0x1A 0x27 0x40 0x68 0xB0 0x36 0x00 0xDA 0x28 0x11 0x00 0x00 0x1C 
  1680 x 1050 @ 58Hz
  Pixel clock 146.250MHz
  Horizontal active 1680 pixels
  Horizontal blanking 610 pixels
  Vertical active 1050 pixels
  Vertical blanking 39 pixels
  Horizontal sync. offset 104 pixels
  Horizontal sync. width 176 pixels
  Vertical sync. offset 3 lines
  Vertical sync. width 6 lines
  Horizontal Image Size 474 mm
  Vertical Image Size 296 mm
  Horizontal Border 0 pixels
  Vertical Border 0 lines
  Non-interlaced
  Normal display, no stereo
  Analog composite
  sync on green video line only
Monitor Descriptor 0x00 0x00 0x00 0xFF 0x00 0x43 0x4A 0x31 0x30 0x37 0x31 0x36 0x30 0x34 0x31 0x38 0x37 0x30 
  Monitor Serial Number CJ10716041870
Monitor Descriptor 0x00 0x00 0x00 0xFC 0x00 0x50 0x68 0x69 0x6C 0x69 0x70 0x73 0x20 0x32 0x30 0x30 0x57 0x53 
  Monitor Name Philips 200WS
Monitor Descriptor 0x00 0x00 0x00 0xFD 0x00 0x38 0x4C 0x1E 0x5D 0x11 0x70 0x0A 0x20 0x32 0x30 0x30 0x57 0x53 
  Monitor range limits
  Min. Vertical rate 56Hz
  Max. Vertical rate 76Hz
  Min. Horizontal rate 30kHz
  Max. Horizontal rate 93kHz
  Max. Pixel Clock 170MHz
Extension Flag 0x00
Checksum 0x18

EDID 的解析数据。。