Bildschirmhelligkeit erhöhen/verringern

  • VB.NET

Es gibt 3 Antworten in diesem Thema. Der letzte Beitrag () ist von Leseratte.

    Bildschirmhelligkeit erhöhen/verringern

    Hallo,
    ich habe eine Frage. Ich möchte ein Programm bastel, welches (unter anderem) die Bildschirmhelligkeit verändert. Ich habe einen Code für VB 6 gefunden, habe aber keine Ahnung, wie ich den Übersetzen muss. Da k0ommt ein feher mit any & einer mit Ole_color/Olecolor
    Könnt ihr euch den mal ansehen :?:

    VB.NET-Quellcode

    1. Option Explicit
    2. Public Declare Sub CopyMemory Lib "kernel32" Alias _
    3. "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
    4. Public Structure OLECOLOR ' Hier hab ich schonn rausbekommen, wie man den Bereich macht
    5. Dim RedOrSys As Byte
    6. Dim green As Byte
    7. Dim blue As Byte
    8. Dim Type As Byte
    9. End Structure 'Bis hier
    10. Public Function getCol(VBColor As Long) As OLECOLOR
    11. CopyMemory getCol, VBColor, Len(getCol)
    12. End Function
    13. Public Function changeBrightness(lngDiff As Long, c As OLE_COLOR) As OLE_COLOR
    14. Dim col As OLECOLOR
    15. Dim red As Long, green As Long, blue As Long
    16. col = getCol(c)
    17. red = col.RedOrSys: green = col.green: blue = col.blue
    18. If Abs(lngDiff) > 255 Then changeBrightness = c
    19. red = red + lngDiff
    20. green = green + lngDiff
    21. blue = blue + lngDiff
    22. If red < 0 Then red = 0
    23. If red > 255 Then red = 255
    24. If green < 0 Then green = 0
    25. If green > 255 Then green = 255
    26. If blue < 0 Then blue = 0
    27. If blue > 255 Then blue = 255
    28. changeBrightness = RGB(red, green, blue)
    29. End Function

    Danke im Vorraus

    Leseratte

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Leseratte“ () aus folgendem Grund: Keine durchsreichung im VB-Tag

    As Any wird zu As Object und As Long wird zu As Integer(VB6 ist As Long 32 Bit und bei .Net As Int...glaub ich zumindest...:P)
    Type Structure kenn ich nicht,...ich dachte VB 6 wäre Type und Structure .Net
    Ich wollte auch mal ne total überflüssige Signatur:
    ---Leer---

    jvbsl schrieb:

    Type Structure kenn ich nicht,...ich dachte VB 6 wäre Type und Structure .Net
    Mist! Das Type sollte eig. durchgetrichen sein: Type Structure
    Aber das probier ich mal aus. Danke
    EDIT: Schade, hat auch nicht geklappt. Ich habe einen anderen Code gefunden, dort kommt jetzt kein Fehler, aber passieren tut auch nix:

    VB.NET-Quellcode

    1. Option Explicit On
    2. Public Class Form1
    3. Private Ramp1(0 To 255, 0 To 2) As Integer
    4. Private Ramp2(0 To 255, 0 To 2) As Integer
    5. Private Declare Function GetDeviceGammaRamp Lib "gdi32" (ByVal hdc As Long, ByVal lpv As Object) As Long
    6. Private Declare Function SetDeviceGammaRamp Lib "gdi32" (ByVal hdc As Long, ByVal lpv As Object) As Long
    7. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As Object, ByVal Source As Object, ByVal Length As Long)
    8. Public Function Int2Lng(ByVal IntVal As Integer) As Long
    9. CopyMemory(Int2Lng, IntVal, 2)
    10. End Function
    11. Public Function Lng2Int(ByVal Value As Long) As Integer
    12. CopyMemory(Lng2Int, Value, 2)
    13. End Function
    14. Private Sub Set(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Butt1.Click
    15. Dim iCtr As Integer
    16. Dim lVal As Long
    17. GetDeviceGammaRamp(Me.CreateGraphics.GetHdc, Ramp1(0, 0))
    18. For iCtr = 0 To 255
    19. lVal = Int2Lng(Ramp1(iCtr, 0))
    20. Ramp2(iCtr, 0) = Lng2Int(Int2Lng(Ramp1(iCtr, 0)) / 2)
    21. Ramp2(iCtr, 1) = Lng2Int(Int2Lng(Ramp1(iCtr, 1)) / 2)
    22. Ramp2(iCtr, 2) = Lng2Int(Int2Lng(Ramp1(iCtr, 2)) / 2)
    23. Next iCtr
    24. SetDeviceGammaRamp(Me.CreateGraphics.GetHdc, Ramp2(0, 0))
    25. End Sub
    26. End Class

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Leseratte“ ()