public static Resolution[] EnumerateResolutions() { List<Resolution> resolutions = new List<Resolution>(); bool lResult = true; int i = 0; Win32Api.DEVMODE dm = new Win32Api.DEVMODE(); do { lResult = Win32Api.EnumDisplaySettings(null, i, ref dm); Resolution res = new Resolution(); res.Width = dm.dmPelsWidth; res.Height = dm.dmPelsHeight; if (!(resolutions.Contains(res)) && (dm.dmBitsPerPel == 32)) { resolutions.Add(res); } i += 1; } while (lResult == true); return resolutions.ToArray(); }
public static Resolution FromRectangle(Rectangle r) { Resolution res = new Resolution(); res.Width = r.Width; res.Height = r.Height; res.ColorDepth = 32; return res; }