I am trying to fade between two pictures. They each have their own Picture box and i am updating a third that contains the fading. I am using GetPixel and SetPixel, but it is really slow. Are there any faster methods of fading?
Thanks
-George
Printable View
I am trying to fade between two pictures. They each have their own Picture box and i am updating a third that contains the fading. I am using GetPixel and SetPixel, but it is really slow. Are there any faster methods of fading?
Thanks
-George
Create a Slider and set the min to 0 and the mex to 255
this code will fade the picture1 and picture3 into picture2
VB Code:
Option Explicit Const AC_SRC_OVER = &H0 Private Type BLENDFUNCTION 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 Declare Sub RtlMoveMemory Lib "kernel32.dll" (Destination As Any, Source As Any, ByVal Length As Long) Private Sub Slider1_Change() Dim BF As BLENDFUNCTION, lBF As Long Picture2.Picture = Picture3.Picture 'set the parameters With BF .BlendOp = AC_SRC_OVER .BlendFlags = 0 .SourceConstantAlpha = Slider1.Value .AlphaFormat = 0 End With 'copy the BLENDFUNCTION-structure to a Long RtlMoveMemory lBF, BF, 4 AlphaBlend Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, lBF Picture2.Refresh End Sub