| |
VB & Windows APISetDeviceGammaRamp funktioniert nicht | | | Autor: dbmaxpayne | Datum: 14.06.11 12:48 |
| Hi,
ich versuche in einer VB6 Anwendung die Gamma-Kurve zu verändern um die Helligkeit zu steuern.
Das funktioniert auch soweit.
Allwedings nur bis 50%.
Darunter passiert einfach garnichts mehr und die Funktion gibt FALSE zurück.
Ich habe schon ein bisschen gelesen und es soll wohl bei Windows 98 funktionieren.
Was kann ich also bei Betriebssystemen über Windows 98 tun, damit ich die Helligkeit weiter verringern kann?
Danke und Gruß Mark | |
Re: SetDeviceGammaRamp funktioniert nicht | | | Autor: dbmaxpayne | Datum: 14.06.11 13:02 |
| 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 lVal As Long
Dim iCtr As Integer
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)
Ramp2(iCtr, 1) = Lng2Int(Int2Lng(Ramp1(iCtr, 1)) / 2)
Ramp2(iCtr, 2) = Lng2Int(Int2Lng(Ramp1(iCtr, 2)) / 2)
Next iCtr
Debug.Print 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 Ramp2(iCtr, 2) = Lng2Int(Int2Lng(Ramp1(iCtr, 2)) / 2)
/2 funktioniert hierbei noch.
Alles was darüber hinausgeht, funktioniert nicht und führt zu einem FALSE bei SetDeviceGammaRamp | |
Re: SetDeviceGammaRamp funktioniert nicht | | | Autor: dbmaxpayne | Datum: 14.06.11 15:15 |
| Hi,
ich habs zwar nicht ganz hinbekommen den Code unter VB6 zum Laufen zu bringen, aber wenn ich mir folgende Zeile mal anschaue:
'wValue = Min&(nIndex * (wBrightness + 128), 65535) Scheint da ja auch ein Offset von 128 gesetzt zu werden.
Also auch 50% von 256.
Daher gehe ich mal davon aus, dass hier dasselbe Problem wie bei mir auftreten wird.
Gruß Mark | |
Re: SetDeviceGammaRamp funktioniert nicht | | | Autor: Martoeng (Moderator) | Datum: 14.06.11 20:30 |
| Also bei mir funktioniert der verlinkte (und in VB konvertierte) Code ganz gut:
Function SetBrightness(ByVal wBrightness As Long) As Long
' /*
' Changes the brightness of the entire screen.
' This function may not work properly in some video cards.
'
' The wBrightness value should be a number between 0 and 255.
' 128 = Regular brightness
' above 128 = brighter
' below 128 = darker
'
' If hDC is NULL, SetBrightness automatically load and release
' the display device context for you.
'
' */
Dim bReturn As Long, nIndex As Long
Dim wValue As Long
bReturn = 0
' //Generate the 256-colors array for the specified wBrightness value.
Dim GammaArray(0 To 255, 0 To 2) As Integer
For nIndex = 0 To 255
wValue = Min(nIndex * (wBrightness + 128), 65535)
GammaArray(nIndex, 0) = Lng2Int(wValue)
GammaArray(nIndex, 1) = Lng2Int(wValue)
GammaArray(nIndex, 2) = Lng2Int(wValue)
List2.AddItem nIndex & ": " & wValue 'GammaArray(nIndex, 0)
Next
' //Set the GammaArray values into the display device context.
bReturn = SetDeviceGammaRamp(Me.hDC, GammaArray(0, 0))
SetBrightness = bReturn
End Function
Function Min(ByVal val1 As Long, ByVal val2 As Long) As Long
If val1 > val2 Then
Min = val2
Else
Min = val1
End If
End Function vbarchiv.dll (Freeware), Tutorials uvm. auf http://www.martoeng.com. | |
Re: SetDeviceGammaRamp funktioniert nicht | | | Autor: dbmaxpayne | Datum: 15.06.11 08:18 |
| Hi,
danke für deine Hilfe und Konvertierung.
Dein Beispiel zeigt aber das gleiche Verhalten wie meine Version.
Ich kann den Bildschirm nicht mehr als 50% abdunkeln.
Falls Du noch eine Idee hast, wäre das super
Oder gibt es evtl. noch andere Möglichkeiten als SetDeviceGammaRamp?
Gruß Mark | |
Re: SetDeviceGammaRamp funktioniert nicht | | | Autor: dbmaxpayne | Datum: 15.06.11 12:18 |
| Hi,
es funktioniert schon bis SetBrightness(0).
Allerdings ist das dann 50% der Starthelligkeit.
Wobei ich aber gerne noch weiter abdunkeln würde. Also quasi wirklich bis Helligkeit=0=schwarz.
Mark | |
Re: SetDeviceGammaRamp funktioniert nicht | | | Autor: dbmaxpayne | Datum: 15.06.11 14:45 |
| Soweit ich gelesen habe ist das aber bei Windows 95/98/ME machbar.
Bei XP und aufwärts prüft SetDeviceGammaRamp auf "zu komplexe" Rampen und verweigert dann mit einem FALSE die Ausführung. | |
Re: SetDeviceGammaRamp funktioniert nicht | | | Autor: dbmaxpayne | Datum: 15.06.11 15:39 |
| Sind sie hoffentlich auch nicht^^
Und auf schwarz möchte ich ja auch nicht. Aber halt noch etwas dunkler als 50%.
Um mal konkret zu werden, geht es um die CarPC Software cPOS.
Diese habe ich im Auto im Einsatz.
Leider kann ich bei meinen TFT dort aber nur extremst umständlich die Bildschirmhelligkeit verändern und 50% Gamma ist nachts noch zu hell. | |
| Sie sind nicht angemeldet! Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.
Einloggen | Neu registrieren |
|
|
TOP! Unser Nr. 1
Neu! sevDataGrid 3.0
Mehrspaltige Listen, mit oder ohne DB-Anbindung. Autom. Sortierung, Editieren von Spalteninhalten oder das interaktive Hinzufügen von Datenzeilen sind ebenso möglich wie das Erstellen eines Web-Reports. Weitere InfosTipp des Monats TOP Entwickler-Paket
TOP-Preis!!
Mit der Developer CD erhalten Sie insgesamt 24 Entwickler- komponenten und Windows-DLLs. Die Einzelkomponenten haben einen Gesamtwert von 1605.50 EUR...
Jetzt nur 599,00 EURWeitere Infos
|