using System; using System.Runtime.InteropServices; namespace ConsoleApplication1 { class Program { [DllImport("gdi32.dll")] public static extern bool SetDeviceGammaRamp(IntPtr hDC, ref Wolla lpwolla); [DllImport("user32.dll", EntryPoint = "GetDC")] public static extern IntPtr GetDC(IntPtr ptr); [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct Wolla { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public UInt16[] Red; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public UInt16[] Green; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] public UInt16[] Blue; } static void Main(string[] args) { if (args.Length > 0) { Wolla wolla = new Wolla(); wolla.Red = new ushort[256]; wolla.Green = new ushort[256]; wolla.Blue = new ushort[256]; for (int i = 1; i < 256; i++) { wolla.Red[i] = wolla.Green[i] = wolla.Blue[i] = (ushort)(Math.Min(65535, Math.Max(0, Math.Pow((i + 1) / 256.0, Convert.ToInt32(args[0]) * 0.1) * 65535 + 0.5))); } SetDeviceGammaRamp(GetDC(IntPtr.Zero), ref wolla); } else { Console.Write("Husk Gamma Værdi, mellem 3 og 44"); Console.ReadLine(); } } } }