我试验了传入me.hdc和传入 getdc(getforgrundwindow)都不能控制视频亮度,只能调整屏幕亮度,视频亮度不变。

解决方案 »

  1.   

    显卡属性中 一般都有 颜色调整 ,其中有一项肯定是 把颜色应用于的下拉项,包含:桌面、覆盖、全部,其中这个覆盖 指的就是视频窗口,请问这个东西怎么实现哦。是否是用 SetDeviceGammaRamp(某个特殊的dc,gamma值)?
      

  2.   

    Option Explicit
    'Gamma Type
    Private Type Gamma
        Red As Integer
        Green As Integer
        Blue As Integer
    End Type
    Private GammaDay As Gamma                'Day Gamma
    Private GammaNight As Gamma              'Night Gamma'Gamma APIs
    Private Ramp1(0 To 255, 0 To 2) As Integer
    Private Ramp2(0 To 255, 0 To 2) As Integer
    Private Declare Function GetDeviceGammaRamp Lib "gdi32" (ByVal hdc As Long, lpv As Any) As Long
    Private Declare Function SetDeviceGammaRamp Lib "gdi32" (ByVal hdc As Long, lpv As Any) As Long
    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
    Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function GetDesktopWindow Lib "user32" () As Long'Set Gamma
    Public Sub SetGamma(ByVal intRed As Integer, ByVal intGreen As Integer, ByVal intBlue As Integer)
    Dim i As Integer
    Dim ScrDC As Long
        
        'Get Screen's DC
        ScrDC = GetDC(GetDesktopWindow)
        intRed = intRed / 2
        intGreen = intGreen / 2
        intBlue = intBlue / 2
        'Change Ramp
        For i = 0 To 255
            If intRed < 0 Then Ramp2(i, 0) = ConvToSignedValue(ConvToUnSignedValue(Ramp1(i, 0)) * (100 - Abs(intRed)) / 100)
            If intRed = 0 Then Ramp2(i, 0) = Ramp1(i, 0)
            If intRed > 0 Then Ramp2(i, 0) = ConvToSignedValue(65535 - ((65535 - ConvToUnSignedValue(Ramp1(i, 0))) * (100 - intRed) / 100))
            If intGreen < 0 Then Ramp2(i, 1) = ConvToSignedValue(ConvToUnSignedValue(Ramp1(i, 1)) * (100 - Abs(intGreen)) / 100)
            If intGreen = 0 Then Ramp2(i, 1) = Ramp1(i, 1)
            If intGreen > 0 Then Ramp2(i, 1) = ConvToSignedValue(65535 - ((65535 - ConvToUnSignedValue(Ramp1(i, 1))) * (100 - intGreen) / 100))
            If intBlue < 0 Then Ramp2(i, 2) = ConvToSignedValue(ConvToUnSignedValue(Ramp1(i, 2)) * (100 - Abs(intBlue)) / 100)
            If intBlue = 0 Then Ramp2(i, 2) = Ramp1(i, 2)
            If intBlue > 0 Then Ramp2(i, 2) = ConvToSignedValue(65535 - ((65535 - ConvToUnSignedValue(Ramp1(i, 2))) * (100 - intBlue) / 100))
        Next
        'Set Gamma
        SetDeviceGammaRamp ScrDC, Ramp2(0, 0)
    End Sub
    'Save Gamma
    Public Sub SaveGamma()
        Dim ScrDC As Long
        
        'Get Screen's DC
        ScrDC = GetDC(GetDesktopWindow)
        
        'Reset it
        GetDeviceGammaRamp ScrDC, Ramp1(0, 0)
    End Sub
    'RestoreGamma
    Public Sub RestoreGamma()
        Dim ScrDC As Long
        
        'Get Screen's DC
        ScrDC = GetDC(GetDesktopWindow)
        
        'Reset it
        SetDeviceGammaRamp ScrDC, Ramp1(0, 0)
    End Sub
    Private Function ConvToSignedValue(lngValue As Long) As Integer
        'Cheezy method for converting to signed integer
        If lngValue <= 32767 Then
            ConvToSignedValue = CInt(lngValue)
            Exit Function
        End If
        
        ConvToSignedValue = CInt(lngValue - 65535)
    End Function
    Private Function ConvToUnSignedValue(intValue As Integer) As Long
        'Cheezy method for converting to unsigned integer
        If intValue >= 0 Then
            ConvToUnSignedValue = intValue
            Exit Function
        End If
        
        ConvToUnSignedValue = intValue + 65535
    End Function
    Private Sub Command1_Click()
        GammaDay.Red = 0
        GammaDay.Green = 0
        GammaDay.Blue = 0
        SetGamma GammaDay.Red, GammaDay.Green, GammaDay.Blue
    End Sub
    Private Sub Command2_Click()
        GammaNight.Red = -64
        GammaNight.Green = -64
        GammaNight.Blue = -64
        SetGamma GammaNight.Red, GammaNight.Green, GammaNight.Blue
    End Sub
    Private Sub Form_Load()
        SaveGamma
    End Sub
    Private Sub Form_Unload(Cancel As Integer)
        RestoreGamma
    End Sub
      

  3.   

    在播放的视频中调整视频亮度是比较难的。我所知道的MCI中有这样的命令。