/* public static void TurnOffDevice(int devNum, Devmode mode) * { * var result = NativeMethods.TurnOffMonitorEx(GetDeviceName(devNum), int null, int null, 0, int null); * if (result > 0) * return; * }*/ public static void SetGamma(int gamma) { if (gamma <= 256 && gamma >= 1) { DisplayDevice.RAMP ramp = new DisplayDevice.RAMP(); ramp.Red = new ushort[256]; ramp.Green = new ushort[256]; ramp.Blue = new ushort[256]; for (int i = 1; i < 256; i++) { int iArrayValue = i * (gamma + 128); if (iArrayValue > 65535) { iArrayValue = 65535; } ramp.Red[i] = ramp.Blue[i] = ramp.Green[i] = (ushort)iArrayValue; } NativeMethods.SetDeviceGammaRamp(NativeMethods.GetDC(IntPtr.Zero), ref ramp); } }
public static extern bool SetDeviceGammaRamp(IntPtr hDC, ref DisplayDevice.RAMP lpRamp);