How can I determine the screen size in inches programatically
8 ビュー (過去 30 日間)
古いコメントを表示
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
2025 年 10 月 9 日
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
2025 年 10 月 9 日
編集済み: Stephen23
2025 年 10 月 9 日
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:
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!