Some video cards allows you to programmingly modify the Gamma Ramp values. You can use this feature to change the brightness of the entire screen. The SetDeviceGammaRamp API function receive an array of 256 RGB values. Increasing the values in this array will make your screen brighter, and decreasing these values will make your screen darker. You can also increase or decrease the intesity of the red/green/blue components. For example: Increasing the blue component in all RGB values will add more blue color to the entire display.
The following class encapsulates the calls to GetDeviceGammaRamp and SetDeviceGammaRamp, and provides the SetBrightness function for setting the brightness of the screen.
Class header file: (gammaramp.h)
Class C++ File: (gammaramp.cpp)
Example for using the CGammaRamp class:
Download Sample Project (For running in Visual C++ 6.0 or greater)
Labels:
Visual C++
The following class encapsulates the calls to GetDeviceGammaRamp and SetDeviceGammaRamp, and provides the SetBrightness function for setting the brightness of the screen.
Class header file: (gammaramp.h)
#ifndef GAMMARAMP_H_
#define GAMMARAMP_H_
/*
CGammaRamp class
Encapsulates the Gamma Ramp API and changes the brightness of
the entire screen.
Written by Nir Sofer.
http://www.nirsoft.net
*/
class CGammaRamp
{
protected:
HMODULE hGDI32;
HDC hScreenDC;
typedef BOOL (WINAPI *Type_SetDeviceGammaRamp)(HDC hDC, LPVOID lpRamp);
Type_SetDeviceGammaRamp pGetDeviceGammaRamp;
Type_SetDeviceGammaRamp pSetDeviceGammaRamp;
public:
CGammaRamp();
~CGammaRamp();
BOOL LoadLibrary();
void FreeLibrary();
BOOL LoadLibraryIfNeeded();
BOOL SetDeviceGammaRamp(HDC hDC, LPVOID lpRamp);
BOOL GetDeviceGammaRamp(HDC hDC, LPVOID lpRamp);
BOOL SetBrightness(HDC hDC, WORD wBrightness);
};
#endif
|
Class C++ File: (gammaramp.cpp)
#include
|
Example for using the CGammaRamp class:
#include
|
Download Sample Project (For running in Visual C++ 6.0 or greater)
Responses
0 Respones to "Changing the screen brightness programmingly - By using the Gamma Ramp API"
Post a Comment