Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Spht on December 28, 2005, 01:47 PM

Title: Fade from white to picture
Post by: Spht on December 28, 2005, 01:47 PM
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:

(http://www.valhallalegends.com/spht/ci_fade_sample.gif)

10 frames per second should suffice.
Title: Re: Fade from white to picture
Post by: Ringo on December 28, 2005, 01:52 PM
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:

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
Title: Re: Fade from white to picture
Post by: Spht on December 28, 2005, 09:04 PM
AlphaBlend works nicely and I just re-draw the text each update.  Thanks.