Bild teilweise transparent machen und auf anderes Bild blitten

  • VB6

Es gibt 1 Antwort in diesem Thema. Der letzte Beitrag () ist von Aeonos.

    Bild teilweise transparent machen und auf anderes Bild blitten

    Hi Leute ich bins mal wieder ^^

    IMO stehe ich vor dem Problem, dass ich über ein Bild ein anderes blitten möchte,
    aber so, dass das neue Bild nur zu einem bestimmten Prozentsatz sichtbar ist.
    Also sowas wie bei Photoshop mit dem Color/Gardient/Pattern Overlay mit
    einer bestimmten Opacity. Das soll also nur so ein Schimmer von dem einen
    auf dem anderen Bild angezeigt werden.

    Weiß jemand wie man das realisieren könnte.
    LoL ^^ hab ne Lösung gefunden

    Wenn jemand das gleiche Problem hat, einfach drei Pictureboxen anlegen, deren AutoRedraw auf True setzen
    und dann das hier einfügen

    Visual Basic-Quellcode

    1. Private Type BLENDFUNCTION
    2. BlendOp As Byte
    3. BlendFlags As Byte
    4. SourceConstantAlpha As Byte
    5. AlphaFormat As Byte
    6. End Type
    7. ' BlendOp:
    8. Private Const AC_SRC_OVER = &H0
    9. ' AlphaFormat:
    10. Private Const AC_SRC_ALPHA = &H1
    11. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
    12. lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)
    13. Private Declare Function AlphaBlend Lib "MSIMG32.dll" ( _
    14. ByVal hdcDest As Long, _
    15. ByVal nXOriginDest As Long, _
    16. ByVal nYOriginDest As Long, _
    17. ByVal nWidthDest As Long, _
    18. ByVal nHeightDest As Long, _
    19. ByVal hdcSrc As Long, _
    20. ByVal nXOriginSrc As Long, _
    21. ByVal nYOriginSrc As Long, _
    22. ByVal nWidthSrc As Long, _
    23. ByVal nHeightSrc As Long, _
    24. ByVal lBlendFunction As Long _
    25. ) As Long
    26. Private Sub Form_Paint()
    27. Dim lBlend As Long
    28. Dim bf As BLENDFUNCTION
    29. ' Draw the first picture:
    30. bf.BlendOp = AC_SRC_OVER
    31. bf.BlendFlags = 0
    32. bf.SourceConstantAlpha = 255
    33. bf.AlphaFormat = 0
    34. CopyMemory lBlend, bf, 4
    35. AlphaBlend Picture3.hDC, 0, 0, _
    36. Picture1.ScaleWidth \ Screen.TwipsPerPixelX, _
    37. Picture1.ScaleHeight \ Screen.TwipsPerPixelY, _
    38. Picture1.hDC, 0, 0, _
    39. Picture1.ScaleWidth \ Screen.TwipsPerPixelX, _
    40. Picture1.ScaleHeight \ Screen.TwipsPerPixelY, _
    41. lBlend
    42. ' Now draw the second picture with 50% transparency over the top:
    43. bf.SourceConstantAlpha = 128
    44. CopyMemory lBlend, bf, 4
    45. AlphaBlend Picture3.hDC, 0, 0, _
    46. Picture2.ScaleWidth \ Screen.TwipsPerPixelX, _
    47. Picture2.ScaleHeight \ Screen.TwipsPerPixelY, _
    48. Picture2.hDC, 0, 0, _
    49. Picture2.ScaleWidth \ Screen.TwipsPerPixelX, _
    50. Picture2.ScaleHeight \ Screen.TwipsPerPixelY, _
    51. lBlend
    52. End Sub