Jump to content

[VB] Alpha Blend


Recommended Posts

This is my first time posting code so be nice:

Put this code in the Declerations(at the top):

Option Explicit
'*************************************
'Copyright © 2001 by Alexander Anikin
'& DREAM Interactive - QQQ
'e-mail: aka@i.com.ua
'For more my code samples visit:
'http://hotmix.narod.ru
'*************************************
Private Declare Function AlphaBlend Lib "msimg32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal widthSrc As Long, ByVal heightSrc As Long, ByVal dreamAKA As Long) As Long                          'only Windows 98 or Later
Dim Num As Byte, nN%, nBlend&

This is the simple stuff :):

Private Sub Form_Activate()
Call Run_Blending
End Sub

Private Sub Form_Unload(Cancel As Integer)
End
End Sub

Now for the effects :D

You need to add a picture box and name it 'picSrc'.

Then find the two pictures you wish to blend and set one as the background of the form, and the other as the picture in picSrc.

Then add this code:

Private Sub Run_Blending()
Num = 255
nN = 5
Do
DoEvents
'***********************************************
 nBlend = vbBlue - CLng(Num) * (vbYellow + 1)
'It's Magic Formula is
'Alchemical Mixture of Elements of Gold & Sky
'It's obtained by an almost mystical way
'***********************************************
Num = Num - nN
If Num = 0 Then
  nN = -5
ElseIf Num = 255 Then
  nN = 5
End If
Me.Cls
AlphaBlend Me.hDC, 0, 0, picSrc.ScaleWidth, picSrc.ScaleHeight, picSrc.hDC, 0, 0, picSrc.ScaleWidth, picSrc.ScaleHeight, nBlend
Loop
End Sub

Change the value of 'nN' to increase/decrease speed of the blend, all comments by the original author have been left in the code(I just wanted to show you something cool that you may not have seen :rolleyes:

Have fun with this :D

Link to comment
Share on other sites

  • 3 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...