PDA

Click to See Complete Forum and Search --> : [Win-API] (VB6) Fader (in and out) ??


majasoft
Oct 30th, 2000, 04:08 AM
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.

Oct 30th, 2000, 06:09 AM
Is this what your looking for?


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

majasoft
Oct 30th, 2000, 06:41 AM
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. ;-)

Oct 30th, 2000, 01:40 PM
Just a little arranging around. You do know how to use RGB, don't you?

R = Red
G = Green
B = Blue

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.

majasoft
Oct 30th, 2000, 03:17 PM
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.

Orpheus
Nov 1st, 2000, 06:25 AM
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.

Nov 1st, 2000, 02:57 PM
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.

Sastraxi
Nov 1st, 2000, 03:59 PM
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:


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/!

majasoft
Nov 2nd, 2000, 02:27 AM
Dit You have a fully example of the code You give me ?
I want to try it, this way.

Thanx, MAJA.

davidrobin
Nov 3rd, 2000, 05:14 AM
Don't know if you are sorted with answers to your question but I found this previous thread

http://forums.vb-world.net/showthread.php?threadid=21834

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

majasoft
Nov 3rd, 2000, 06:07 AM
Thank You very, very much... I have found for what Iám locking for !! (alphablending.dll)

Thanx, MAJA.

DoctorMO
Nov 6th, 2000, 02:16 PM
you can aldo use the BitBlt for this, using the scrxor or scrand methods, It may help some one else to know!