Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get native resolution of screen

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.

like image 787
Mathias Avatar asked Aug 12 '13 13:08

Mathias


People also ask

How do I find my native resolution on Windows 10?

In the “Settings” window, select the “System” option. In the “System” settings menu, on the sidebar to the left, select “Display.” In the right pane, scroll down to the “Scale and Layout” section. Here, the value displayed in the “Display Resolution” drop-down menu is your current screen resolution.

How do I make my 1920X1080 my native resolution?

Right click on the empty area of the desktop and select “Display settings”. Then, under “Resolution”, your current resolution will be written. Click on it and a drop down menu will appear. Select 1920X1080.

Is 1920X1080 native?

The native resolution is the Horizontal by Vertical pixel count. For example, if the resolution is 1920x1080, that means there are 1920 horizontal pixels by 1080 vertical pixels on the DMD Chip.


1 Answers

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

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

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);

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);
    }
like image 80
clamp Avatar answered Oct 06 '22 01:10

clamp