Valhalla Legends Forums Archive | Visual Basic Programming | Fade from white to picture

AuthorMessageTime
Spht
I'm looking for an efficient way of doing an animated fade transition from total white to a picture.  The picture is always only 473x175.  There is also text .Print'ed on the area which needs to stay during the transition.

For example:

[img]http://www.valhallalegends.com/spht/ci_fade_sample.gif[/img]

10 frames per second should suffice.
December 28, 2005, 7:47 PM
Ringo
AlphaBlend() should be perfect for that if you raise the opacity on a timer or somthing.

[EDIT]:
Hmm give this ago:
Haveing 2 pictures to fade into each other:
[code]
Public Type ALPHAFADE
    BlendOp As Byte
    BlendFlags As Byte
    SourceConstantAlpha As Byte
    AlphaFormat As Byte
End Type
Private Declare Function AlphaBlend Lib "msimg32.dll" (ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal BLENDFUNCT As Long) As Long

Private Sub SetOpacity(intOpacity As Integer)
    Dim AB As ALPHAFADE
    Dim BlendValue As Long
    With AB
        .BlendOp = 0
        .BlendFlags = 0
        .SourceConstantAlpha = intOpacity
        .AlphaFormat = 0
    End With
    'copy the type to a Long
    CopyMemory BlendValue, BF, 4
    'AlphaBlend the picture from Picture1 over the picture of Picture2
    AlphaBlend Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, BlendValue
End Sub
[/code]
December 28, 2005, 7:52 PM
Spht
AlphaBlend works nicely and I just re-draw the text each update.  Thanks.
December 29, 2005, 3:04 AM

Search