Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. text;
Using system. Windows. forms;
Using system. runtime. interopservices; // This item must be referenced
// Warning: experiment with this Code may cause problems to the display of your monitor. It takes two hours to check API usage.
// However, I have tried nothing (BS: Not my own machine)
Namespace windowsapplication1
...{
Public partial class form1: Form
...{
Public form1 ()
...{
Initializecomponent ();
}
Private void button#click (Object sender, eventargs E)
...{
Setgamma (trackbar1.value );
}
[Dllimport ("gdi32.dll")]
Public static extern int getdevicegammaramp (intptr HDC, ref ramp lpramp );
Ramp ramp = new ramp ();
[Dllimport ("gdi32.dll")]
Public static extern int setdevicegammaramp (intptr HDC, ref ramp lpramp );
[Dllimport ("user32.dll")]
Static extern intptr getdc (intptr hwnd );
[Structlayout (layoutkind. Sequential, charset = charset. ANSI)]
Public struct Ramp
...{
[Financialas (unmanagedtype. byvalarray, sizeconst = 256)]
Public uint16 [] Red;
[Financialas (unmanagedtype. byvalarray, sizeconst = 256)]
Public uint16 [] green;
[Financialas (unmanagedtype. byvalarray, sizeconst = 256)]
Public uint16 [] blue;
}
Void setgamma (INT gamma)
...{
Ramp. Red = new ushort [256];
Ramp. Green = new ushort [256];
Ramp. Blue = new ushort [256];
For (INT I = 1; I <256; I ++)
...{
// Gamma must be between 3 and 44
Ramp. red [I] = ramp. green [I] = ramp. blue [I] = (ushort) (math. min (65535, math. max (0, math. pow (I + 1)/256.0, Gamma * 0.1) * 65535 + 0.5 )));
}
Setdevicegammaramp (getdc (intptr. Zero), ref ramp );
}
}
}
Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. text;
Using system. Windows. forms;
Using system. runtime. interopservices; // This item must be referenced
// Warning: experiment with this Code may cause problems to the display of your monitor. It takes two hours to check API usage.
// However, I have tried nothing (BS: Not my own machine)
Namespace windowsapplication1
...{
Public partial class form1: Form
...{
Public form1 ()
...{
Initializecomponent ();
}
Private void button#click (Object sender, eventargs E)
...{
Setgamma (trackbar1.value );
}
[Dllimport ("gdi32.dll")]
Public static extern int getdevicegammaramp (intptr HDC, ref ramp lpramp );
Ramp ramp = new ramp ();
[Dllimport ("gdi32.dll")]
Public static extern int setdevicegammaramp (intptr HDC, ref ramp lpramp );
[Dllimport ("user32.dll")]
Static extern intptr getdc (intptr hwnd );
[Structlayout (layoutkind. Sequential, charset = charset. ANSI)]
Public struct Ramp
...{
[Financialas (unmanagedtype. byvalarray, sizeconst = 256)]
Public uint16 [] Red;
[Financialas (unmanagedtype. byvalarray, sizeconst = 256)]
Public uint16 [] green;
[Financialas (unmanagedtype. byvalarray, sizeconst = 256)]
Public uint16 [] blue;
}
Void setgamma (INT gamma)
...{
Ramp. Red = new ushort [256];
Ramp. Green = new ushort [256];
Ramp. Blue = new ushort [256];
For (INT I = 1; I <256; I ++)
...{
// Gamma must be between 3 and 44
Ramp. red [I] = ramp. green [I] = ramp. blue [I] = (ushort) (math. min (65535, math. max (0, math. pow (I + 1)/256.0, Gamma * 0.1) * 65535 + 0.5 )));
}
Setdevicegammaramp (getdc (intptr. Zero), ref ramp );
}
}
}