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.
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.
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.
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.
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With