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