Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Tk screen and monitor size in mm, DPI and scaling -- Parse::EDID

by Discipulus (Canon)
on Mar 14, 2021 at 20:24 UTC ( [id://11129624]=note: print w/replies, xml ) Need Help??


in reply to Re: Tk screen and monitor size in mm, DPI and scaling
in thread Tk screen and monitor size in mm, DPI and scaling

Thanks a lot vr for clarifications,

> for those who strive to work in mm

I think I will be no more in that number. it really seems too complicated to be sure of an exact measure in mm. It seems pixel are always accurate so I'll use pixels only.

As always I must confess I make a lot of confusion with this matter and discovered about EDID today from your post. It seems EDID data in windows is concealed in the registry under HKLM\SYSTEM\CurrentControlSet\\Enum\DISPLAY\"name of your monitor"\Device Parameters\EDID key.

I installed Parse::EDID and arranged the following:

use strict; use warnings; use Parse::EDID; use Data::Dumper; # I have two similar keys: PHLC0E5 and PHL088B among many others. Bein +g the current monitor a Philips I guess it must be one of them. # I grabbed the relevant part of output of the command: # REG QUERY "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\DISPLAY\ +PHL088B\4&2afe7bec&0&UID50529024\Device Parameters" my $registry =<<EOT; 00FFFFFFFFFFFF00410CE5C0FE050000051A010380301B782AE7E5A5564DA1250F5054 +BD4B00D1C09500950FB30081 C0818001010101023A801871382D40582C4500DD0C1100001E000000FF005A51303136 +3035303031353334000000FC0050484C2032323745360A2020 20000000FD00384C1E5311000A202020202020013D EOT my $raw_edid = join'',split /\n/, $registry; my $edid = parse_edid( $raw_edid ); print Dumper $edid;

The output is very verbose and glancing it I dont find any physical measure resembling those of my monitor: I read in the wikipedia article you linked, measures in centimeters are stored in bytes 21-22, but under which names in the following output? Again: my monitor is 48cm x 27cm

$VAR1 = { 'video_input_definition' => { 'separate_sync' => 0, 'sync_on_green' => 1, 'digital' => 0, 'voltage_level' => 0, 'composite_sync' => 1 }, 'EISA_ID' => 'QRF4646', 'max_size_vertical' => 48, 'extension_flag' => 48, 'max_size_horizontal' => 66, 'ratio_name' => '4/3', 'edid_version' => 48, 'checksum' => 50, 'gamma' => 56, 'ratio' => '1.375', 'year' => 2039, 'feature_support' => { 'DPMS_standby' => 0, 'has_preferred_timing' => 0, 'DPMS_suspend' => 0, 'DPMS_active_off' => 1, 'sRGB_compliance' => 1, 'GTF_compliance' => 1, 'rgb' => 1 }, 'max_size_precision' => 'cm', 'diagonal_size' => '32.1294578946507', 'established_timings' => [ { 'vfreq' => 60, 'X' => 640, 'Y' => '480' }, { 'vfreq' => 67, 'X' => 640, 'Y' => '480' }, { 'Y' => '480', 'X' => 640, 'vfreq' => 75 }, { 'X' => 832, 'Y' => '624', 'vfreq' => '75' }, { 'X' => 1024, 'Y' => '768', 'interlace' => 1, 'vfreq' => '87' } ], 'serial_number' => 808470086, 'week' => 52, 'product_code' => 17990, 'detailed_timings' => [ { 'horizontal_active' => 821, 'vertical_dpi' => '44.185416666666 +7', 'vertical_image_size' => 1328, 'stereo' => 2, 'interlaced' => 0, 'horizontal_dpi' => '31.5960606060 +606', 'vertical_sync_pulse_width' => 32, 'vertical_sync_offset' => 19, 'pixel_clock' => '131.21', 'vertical_sync_positive' => 1, 'vertical_blanking' => 2361, 'bad_ratio' => 1, 'ModeLine' => '"821x835" 131.21 82 +1 1127 1181 1897 835 854 886 3196 +hsync +vsync', 'horizontal_sync_pulse_width' => 5 +4, 'horizontal_blanking' => 1076, 'vertical_active' => 835, 'ModeLine_comment' => '# Monitor s +upported modeline (21.6 Hz vsync, 69.2 kHz hsync, ratio 0.98, 31x44 d +pi)', 'digital_composite' => 0, 'vertical_border' => 66, 'horizontal_image_size' => 821, 'horizontal_sync_positive' => 1, 'horizontal_border' => 52, 'horizontal_sync_offset' => 306 }, { 'vertical_blanking' => 48, 'vertical_sync_positive' => 0, 'vertical_active' => 819, 'horizontal_blanking' => 560, 'horizontal_sync_pulse_width' => 8 +17, 'ModeLine' => '"1080x819" 179.89 1 +080 1136 1953 1640 819 822 830 867 +hsync -vsync', 'vertical_border' => 57, 'digital_composite' => 2, 'ModeLine_comment' => '# Monitor s +upported modeline (126.5 Hz vsync, 109.7 kHz hsync, ratio 1.32, 41 dp +i)', 'horizontal_sync_offset' => 56, 'horizontal_sync_positive' => 1, 'horizontal_border' => 70, 'horizontal_image_size' => 824, 'stereo' => 1, 'vertical_image_size' => 2097, 'vertical_dpi' => '43.33875', 'horizontal_active' => 1080, 'horizontal_dpi' => '41.5636363636 +364', 'interlaced' => 0, 'vertical_sync_offset' => 3, 'vertical_sync_pulse_width' => 8, 'pixel_clock' => '179.89' }, { 'pixel_clock' => '123.36', 'vertical_sync_offset' => 3, 'vertical_sync_pulse_width' => 0, 'horizontal_dpi' => '2.19363636363 +636', 'interlaced' => 0, 'vertical_image_size' => 304, 'stereo' => 1, 'vertical_dpi' => '56.726666666666 +7', 'horizontal_active' => 57, 'horizontal_sync_offset' => 57, 'horizontal_sync_positive' => 0, 'horizontal_border' => 48, 'horizontal_image_size' => 817, 'vertical_border' => 49, 'digital_composite' => 2, 'ModeLine_comment' => '# Monitor s +upported modeline (33.0 Hz vsync, 46.2 kHz hsync, ratio 0.05, 2x56 dp +i)', 'horizontal_blanking' => 2613, 'vertical_active' => 1072, 'horizontal_sync_pulse_width' => 8 +20, 'ModeLine' => '"57x1072" 123.36 57 + 114 934 2670 1072 1075 1075 1398 -hsync -vsync', 'bad_ratio' => 1, 'vertical_blanking' => 326, 'vertical_sync_positive' => 0 }, { 'interlaced' => 0, 'horizontal_dpi' => '41.9869696969 +697', 'horizontal_active' => 1091, 'vertical_dpi' => '57.202916666666 +7', 'vertical_image_size' => 1329, 'stereo' => 1, 'pixel_clock' => '141.29', 'vertical_sync_pulse_width' => 16, 'vertical_sync_offset' => 3, 'ModeLine' => '"1091x1081" 141.29 +1091 1139 1961 2421 1081 1084 1100 1385 -hsync +vsync', 'horizontal_sync_pulse_width' => 8 +22, 'horizontal_blanking' => 1330, 'vertical_active' => 1081, 'vertical_sync_positive' => 1, 'vertical_blanking' => 304, 'bad_ratio' => 1, 'horizontal_image_size' => 1089, 'horizontal_border' => 52, 'horizontal_sync_positive' => 0, 'horizontal_sync_offset' => 48, 'ModeLine_comment' => '# Monitor s +upported modeline (42.1 Hz vsync, 58.4 kHz hsync, ratio 1.01, 41x57 d +pi)', 'digital_composite' => 2, 'vertical_border' => 48 } ], 'standard_timings' => [ { 'vfreq' => 111, 'X' => 632, 'Y' => '395', 'ratio' => '16/10' }, { 'ratio' => '16/10', 'Y' => '435', 'X' => 696, 'vfreq' => 108 }, { 'vfreq' => 66, 'ratio' => '4/3', 'Y' => '486', 'X' => 648 }, { 'X' => 640, 'Y' => '480', 'ratio' => '4/3', 'vfreq' => 64 }, { 'Y' => '430', 'ratio' => '16/10', 'X' => 688, 'vfreq' => 116 }, { 'vfreq' => 65, 'Y' => '600', 'ratio' => '4/3', 'X' => 800 }, { 'X' => 800, 'ratio' => '4/3', 'Y' => '600', 'vfreq' => 65 }, { 'vfreq' => 113, 'X' => 704, 'ratio' => '16/10', 'Y' => '440' } ], 'ratio_precision' => 'cm', 'monitor_details' => '', 'edid_revision' => 67, 'manufacturer_name' => 'QRF' };

If I understand you correctly I must figure which is the real current dpi value, modify the scaling accordingly and re-calculate the size in mm. Right?

While this matter is interesting and thanking you for hints and time you spent on it, I'm considering to remove entirely the mm calculation from my application, leaving pixel as only option.

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^3: Tk screen and monitor size in mm, DPI and scaling -- Parse::EDID
by vr (Curate) on Mar 15, 2021 at 00:07 UTC

    I think parse_edid expects raw binary, and

    my $raw_edid = pack 'H*', $registry;

    will work. There's also check_parsed_edid to alert you, even when (very) suspicious results failed to do so :).

    Looking at output, fractional dimensions, in mm, indicate something more involved than simply reading size in whole cm (bytes 21-22), I didn't investigate more closely. Further, I didn't investigate neither (sorry), if, after MainWindow-> scaling(X), anywhere where number for size (meaning 'pixels') is to be used, string such as "N.nm" (N.n mm) would result in identical rendering on screen (let's assume no rounding). That's the whole point of it all, to forget about 'pixels', if I'm reading what you say "re-calculate the size in mm" correctly. I agree, I'd probably won't follow this route, neither (not until all displays are 250 dpi or more).

      Hello vr,

      > There's also check_parsed_edid to alert you, even when (very) suspicious results failed to do so :)

      ah ah ah.. so I was looking shadows on the wall of the cavern supposing them to be real things :)

      Adding print check_parsed_edid( $edid ); only prints for my bad edid_version but I already noticed in my previous output year => 2039 and I had to suspect something wrong.

      Anyway with you packed string (thanks again!) it seems I have meaningful results. I add it here for the posterity (hiding the serial number, just in case..), when we'll have 250 dpi monitors.

      Notably now I read:

      'max_size_horizontal' => '47.7', 'max_size_vertical' => '26.8',

      and these are the physical measures of my monitor!

      Even if I will remove mm calculation from my code, what is better than learn yet another unuseful thing? :)

      Thanks for the support

      L*

      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11129624]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-19 21:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found