'Example by Florian Brucker (sirtorf@web.de)
'
'Paste this code into a form of a new project
'You better don't close this via the
'stop-button of the ide but the x-button of
'the form.
Option Explicit
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 Sub Form_Load()
'----------------------------------------------------------------
Dim iCtr As Integer
Dim lVal As Long
'----------------------------------------------------------------
GetDeviceGammaRamp Me.hdc, Ramp1(0, 0)
For iCtr = 0 To 255
lVal = Int2Lng(Ramp1(iCtr, 0))
Ramp2(iCtr, 0) = Lng2Int(Int2Lng(Ramp1(iCtr, 0)) / 2)
'Die folgenden Zeilen für ROT auskommentieren:
Ramp2(iCtr, 1) = Lng2Int(Int2Lng(Ramp1(iCtr, 1)) / 2)
Ramp2(iCtr, 2) = Lng2Int(Int2Lng(Ramp1(iCtr, 2)) / 2)
Next iCtr
SetDeviceGammaRamp Me.hdc, Ramp2(0, 0)
'----------------------------------------------------------------
End Sub
Private Sub Form_Unload(Cancel As Integer)
'----------------------------------------------------------------
SetDeviceGammaRamp Me.hdc, Ramp1(0, 0)
'----------------------------------------------------------------
End Sub
Public Function Int2Lng(IntVal As Integer) As Long
'----------------------------------------------------------------
CopyMemory Int2Lng, IntVal, 2
'----------------------------------------------------------------
End Function
Public Function Lng2Int(Value As Long) As Integer
'----------------------------------------------------------------
CopyMemory Lng2Int, Value, 2
'----------------------------------------------------------------
End Function
saludos