How can I determine the screen size in inches programatically

조회 수: 28 (최근 30일)
George
George 2025년 10월 9일 4:33
편집: Stephen23 2025년 10월 9일 10:05
I need to determine the screen size in inches so I can size by figures properly. Using the get(groot) with "units" set to inches returns the wrong dimensions, and using the ScreenSize in pixels and ScreenPixelsPerInch also returns the wrong results. In fact ScreenSize in pixels includes Windows scaling for the monitor in questions, not the actual screen size in pixel.
  댓글 수: 1
Rik
Rik 2025년 10월 9일 6:51
As far as I'm aware, Windows is fairly inconsisten with what it reports to programs regarding the screen size. You might need an external program.
This would also depend on the screen correctly reporting the physical size in the first place, which is not a given.

댓글을 달려면 로그인하십시오.

답변 (1개)

Stephen23
Stephen23 2025년 10월 9일 7:39
편집: Stephen23 2025년 10월 9일 10:05
Windows 7 was arguably the last version where screensize determination was relatively straightforward. Here's why:
Windows 8 introduced DPI scaling awareness levels and began the transition to more complex display scaling
Windows 10 significantly complicated matters with:
  • Per-monitor DPI scaling
  • Mixed DPI environments
  • Dynamic DPI changes without logout
Windows 11 continues and extends Windows 10's approach, making non-trivial to determine the screensize. In fact, it really depends on what you mean by screensize...
That said, even in Windows 7, you had to account for DPI scaling, but the system was much more predictable.
This might work:
% Get all screen devices
jge = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment();
gds = jge.getScreenDevices();
% For each monitor
for k = 1:length(gds)
gd1 = gds(k);
bounds = gd1.getDefaultConfiguration().getBounds();
fprintf('Monitor %d:\n', k);
fprintf(' Position: (%d, %d)\n', bounds.x, bounds.y);
fprintf(' Size: %d x %d\n', bounds.width, bounds.height);
end
You might be able to use a third-party tool to access the EDID:

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품


릴리스

R2025b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by