public void SetBrightness(double _brightness) { if (_brightness <= BRIGHTNESS_MAX && _brightness >= BRIGHTNESS_MIN) { RAMP ramp = new 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 * ((int)_brightness + 128); if (iArrayValue > 65535) { iArrayValue = 65535; } ramp.Red[i] = ramp.Blue[i] = ramp.Green[i] = (ushort)iArrayValue; } SetDeviceGammaRamp(GetDC(IntPtr.Zero), ref ramp); } }
public static extern bool GetDeviceGammaRamp(IntPtr hDC, ref RAMP lpRamp);