获取画面的原始分辨率 [英] Get native resolution of screen

查看:202
本文介绍了获取画面的原始分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让一个屏幕的原始分辨率在C#?

Is there a way to get the native resolution of a screen in c#?

这是我想问的原因是,我有一些曲线,这是非常重要的,他们看起来是一样的,不管什么样的分辨率。当屏幕不处于原始分辨率,他们看起来有点不同比以前,我想显示一个警告,即是如此。

The reason that I ask is that I have some curves and it is very important that they look the same no matter what resolution. When the screen isn't in native resolution they look somewhat different than before and I want to show a warning that that is the case.

推荐答案

从我的经验,最好的解决方法是提取自监视的 EDID

From my experience the best solution is to extract that information from the monitors' EDID

如何获得原始分辨率的回答是:<一href="http://stackoverflow.com/questions/10073261/how-to-fetch-the-native-resolution-of-attached-monitor-from-edid-file-through-vb">How通过VB6.0?

How to get the native resolution is answered in: How to fetch the NATIVE resolution of attached monitor from EDID file through VB6.0?

我已经做了一些JavaScript,获取该决议出的8个字节开始于54。

i have made a little javascript that gets the resolution out of the 8 bytes starting at 54.

var dtd = 0;
var edid =  new Uint8Array(8);
var i = 0;

edid[i++] = 0x0E;
edid[i++] = 0x1F;
edid[i++] = 0x00;
edid[i++] = 0x80;
edid[i++] = 0x51;
edid[i++] = 0x00;
edid[i++] = 0x1B;
edid[i++] = 0x30;

var horizontalRes = ((edid[dtd+4] >> 4) << 8) | edid[dtd+2] ;
var verticalRes = ((edid[dtd+7] >> 4) << 8) | edid[dtd+5];
console.log(horizontalRes+", "+verticalRes);

和这里是一个C#版本:

and here is a C# version:

    static Point ExtractResolution(byte [] edid)
    {
        const int dtd = 54;
        var horizontalRes = ((edid[dtd + 4] >> 4) << 8) | edid[dtd + 2];
        var verticalRes = ((edid[dtd + 7] >> 4) << 8) | edid[dtd + 5];
        return new Point(horizontalRes, verticalRes);
    }

这篇关于获取画面的原始分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆