Results 1 to 12 of 12

Thread: [Win-API] (VB6) Fader (in and out) ??

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Posts
    29

    Question

    Hi, I want a fader for my little Game, which 'fade in' the colours on start and 'fade out' the colour on the end.

    Like in movies, when a scene is at end, so I want it in my game, is it possible in use whis an API-function or how can I make it ??

    Thanx for Your replies, MAJA.

  2. #2
    Guest
    Is this what your looking for?

    Code:
    Private Sub BlackToWhite(frm As Form)
        For i = 0 To 255
            DoEvents
            For x = 1 To 50000
            Next x
            frm.BackColor = RGB(i, i, i)
        Next i
    End Sub
    
    Private Sub WhiteToBlack(frm As Form)
        For i = 255 To 0 Step -1
            DoEvents
            For x = 1 To 50000
            Next x
            frm.BackColor = RGB(i, i, i)
        Next i
    End Sub

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Posts
    29

    Wink A little different...

    Hi, the way is the right, but I want a fader for all colours on the screen... if a graphic is shown, the fader must fade in from black to the colour(s)-number from the graphic - or in other words, it must go from dark to bright and from bright to dark - from black (dark) to for example red (in the graphic, and or green, dark-green, yellow... and so on) (normal colour - bright) - and now I mean I want a fader for all colours in such a way... how I say... how You can see it in movies - fading out a scene at end and fading in a scene at the beginning !! Not only the BackColour - I want all colours to fade !!

    MAJA. ;-)

  4. #4
    Guest
    Just a little arranging around. You do know how to use RGB, don't you?

    R = Red
    G = Green
    B = Blue

    Code:
    Private Sub BlackToBlue(frm As Form)
        For i = 255 To 0 Step -1
            DoEvents
            For x = 1 To 50000
            Next x
            frm.BackColor = RGB(0, 0, i)
        Next i
    End Sub
    
    Private Sub BlueToBlack(frm As Form)
        For i = 0 To 255
            DoEvents
            For x = 1 To 50000
            Next x
            frm.BackColor = RGB(0, 0, i)
        Next i
    End Sub
    
    Private Sub BlackToRed(frm As Form)
        For i = 255 To 0 Step -1
            DoEvents
            For x = 1 To 50000
            Next x
            frm.BackColor = RGB(i, 0, 0)
        Next i
    End Sub
    
    Private Sub RedToBlack(frm As Form)
        For i = 0 To 255
            DoEvents
            For x = 1 To 50000
            Next x
            frm.BackColor = RGB(i, 0, 0)
        Next i
    End Sub
    
    Private Sub BlackToGreen(frm As Form)
        For i = 255 To 0 Step -1
            DoEvents
            For x = 1 To 50000
            Next x
            frm.BackColor = RGB(i0, i, 0)
        Next i
    End Sub
    
    Private Sub GreenToBlack(frm As Form)
        For i = 0 To 255
            DoEvents
            For x = 1 To 50000
            Next x
            frm.BackColor = RGB(0, i, 0)
        Next i
    End Sub
    
    'etc.
    'etc.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Posts
    29

    Exclamation Yes, but...

    Yes I know the procedur of using the colour-routine, but You dont understand what I mean, excuse me, but I have for example a 'picture' on the screen and I want to fade in or out the complete screen within the graphics, text and all the things in it from brightness to darkness or from darkness to brightness, not only the background... hope You now understand me !! ;-)

    Greetings, MAJA.

  6. #6
    Lively Member
    Join Date
    Oct 2000
    Location
    Leicestershire; ENGLAND
    Posts
    71
    This may depend on the method that you are using to display the bitmap on the form in the first place.
    In order to achieve what I think you want, you need to do basically what Matthew says, however, you need to operate on the active pallette for the BMP.
    The easiest way to fade the entire picture out, is to slowly reduce each of the colours in the pallette to 0, refreshing the image after each iteration.
    Restoring (fading-in) the picture may be more difficult - you would have to save a copy of the pallette, reset all of the values to 0, and then slowly increment the pallette values to the saved values.
    I do not think you cn acheive this easily using the standard picture control, so you may have to look at the API's for graphic display.

  7. #7
    Guest
    You need to do it for each pixel. To retrieve a pixel, use the GetPixel API and to draw a pixel, use the SetPixel API.

  8. #8
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134

    DirectDraw or Direct3D RM

    I know what you mean. You want to Alpha-Blend.

    Use directdraw to ALPHA-BLEND with black.
    Or use Direct3D RM, put your graphic on a plain always visible, and then use the alpha-blend techniques found there.

    I can't give you what you need, but if you want to make a powerful application, I suggest DarkBasic.

    www.darkbasic.com
    -or-
    www.darkbasic.co.uk

    Download the trial version. This program is very good. It has DirectDraw, 3D, Sound, Music, and Show built in. It takes ten lines to create a 3D cube. Even less, if you want. I suggest you give it a try.

    Of course, if you want to use VB and no DirectDraw/3D, then here is the stuff:

    Code:
    Type RGBIt
      OldRed as Integer
      OldGrn as Integer
      OldBlu as Integer
      Red as Integer
      Green as Integer
      Blue as Integer
    End Type
    
    Function Alpha(A as RGBIt,E as RGBIt,AmtSrc as Integer) as RGBIt
    Dim B,C,D
    
      B = ((A.Red * AmtSrc) + (E.Red * 255-AmtSrc)) / 255
      C = ((A.Blue * AmtSrc) + (E.Blue * 255-AmtSrc)) / 255
      D = ((A.Green * AmtSrc) + (E.Green * 255-AmtSrc)) / 255
    
      Alpha.OldRed = A.Red
      Alpha.OldGrn = A.Green
      Alpha.OldBlu = A.Blue
      Alpha.Red = B
      Alpha.Green = D
      Alpha.Blue = C
    
    End Function
    
    'usage:
    
    'Timer Intervals should be 20 for fast fade, 50 for medium, 100 for slow
    K.Red=0
    K.Green=0
    K.Blue=255
    A.Red=255
    A.Green=0
    A.Blue=0
    
    B=Alpha(K,B,127)
    'should end up as a darkish purple
    Also check out http://www.cason.addr.com/!
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Posts
    29

    Smile Example ??

    Dit You have a fully example of the code You give me ?
    I want to try it, this way.

    Thanx, MAJA.

  10. #10
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    Don't know if you are sorted with answers to your question but I found this previous thread

    http://forums.vb-world.net/showthrea...threadid=21834

    It starts off talking about using the Backcolor like you don't want to then goes into more indepth methods.


    Things I do when I am bored: DotNetable

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Posts
    29

    YES !!

    Thank You very, very much... I have found for what Iám locking for !! (alphablending.dll)

    Thanx, MAJA.

  12. #12
    New Member
    Join Date
    Nov 2000
    Location
    UK Liverpool
    Posts
    10

    Arrow

    you can aldo use the BitBlt for this, using the scrxor or scrand methods, It may help some one else to know!
    hehe Don't get too cocky or the irony gods will kick your but!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width