用VC调节显示器亮度

时间:2012-03-18 08:09:10
【文件属性】:

文件名称:用VC调节显示器亮度

文件大小:2KB

文件格式:ZIP

更新时间:2012-03-18 08:09:10

显示器 亮度 调节 VC 源码

Gamma Manager is based on Gamma Slider control. This control allows to change gamma monitor on most graphic cards. The goal for this project is very simple and control is for VC6 & VC7. The other day I downloaded a N64 emulator but the screen was so black that I did not see anything. I had thus to find this solution to lighten my screen. I know that the tools of my video chart make it possible to change gamma of my screen, but it is faster with this tool. Implementation The implementation of this slider control is very easy. Import GammaSlider.h and GammaSlider.cpp into your project. Include reference to the class control. Add slider control on a form. Use ClassWizard to declare variable name derived from CGammaSlider control. That's it, enjoy! Under the hood Windows provides two APIs GetDeviceGammaRamp/ SetDeviceGammaRamp to perform gamma correction. In fact we need to have a 3 dimensional buffer of 256 WORD to manipulate gamma correction. To change gamma, it is necessary to change the RGB value of each color contained in the buffer by a float factor between 0.0 and 2.0. Example We need to save current gamma for future restore. Collapse Copy CodeWORD m_RampSaved[256*3]; if (!GetDeviceGammaRamp(::GetDC(NULL), m_RampSaved)) { TRACE("WARNING: Cannot initialize DeviceGammaRamp.\n"); }To change gamma, cycle into ramp buffer and change RGB color where Gamma is the float factor. Collapse Copy CodeWORD ramp[256*3]; for( int i=0; i<256; i++ ) { ramp[i+0] = ramp[i+256] = ramp[i+512] = (WORD)min(65535, max(0, pow((i+1) / 256.0, Gamma) * 65535 + 0.5)); } SetDeviceGammaRamp(::GetDC(NULL), ramp);Now to trap slider control message, we need to use a special message ON_WM_HSCROLL_REFLECT() that can provide message to be dispatched into control class itself.


【文件预览】:
GammaSlider.cpp
GammaSlider.h

网友评论

  • 挺好用的,下次还来
  • 应该没有调节显示器亮度,而是调了颜色,让显示器绘暗一些的图,和显示器本身的亮度调节不是一回事
  • 不是很理想
  • 源码太少自己的注释了