以编程方式更改屏幕颜色平衡

时间:2014-01-13 14:27:18

标签: c# c++ vb.net windows gdi

GDI32.DLL中用于更改Windows上色彩平衡的函数名称是什么?

例如要更改设备gamma,我需要使用SetDeviceGammaRamp

[DllImport("GDI32.dll")]
private unsafe static extern bool SetDeviceGammaRamp(Int32 hdc, void* ramp);

1 个答案:

答案 0 :(得分:0)

您可以调整屏幕的RGB值并使用与您提到的完全相同的功能更改其亮度:SetDeviceGammaRamp

见这里: http://www.nirsoft.net/vc/change_screen_brightness.html

函数的第二个参数,即传递RGB值:

//Generate the 256-colors array for the specified wBrightness value.
        WORD GammaArray[3][256];

        for (int iIndex = 0; iIndex < 256; iIndex++)
        {
            int iArrayValue = iIndex * (wBrightness + 128);

            if (iArrayValue > 65535)
                iArrayValue = 65535;

            GammaArray[0][iIndex] = 
            GammaArray[1][iIndex] = 
            GammaArray[2][iIndex] = (WORD)iArrayValue;

        }

        //Set the GammaArray values into the display device context.
        bReturn = SetDeviceGammaRamp(hGammaDC, GammaArray);