Android Question [Solved] FadeIn effect in BitmapCreator Effects

LucaMs

Expert
Licensed User
Just one way to do it inside the example.

In the class Example, declare a global variable:
B4X:
' Class Example
Sub Class_Globals
'...
'...
'...
    Private FadedOut As Boolean
and change the routine FadeOut_Animated:
B4X:
Private Sub FadeOut_Animated (iv As B4XView)
   Dim bc As BitmapCreator
   bc.Initialize(OriginalBmp.Width / OriginalBmp.Scale, OriginalBmp.Height / OriginalBmp.Scale)
   bc.FillRect(xui.Color_Transparent, bc.TargetRect)
   If FadedOut Then
       effects.TransitionAnimated(1500, bc.Bitmap, OriginalBmp, iv)
   Else
       effects.TransitionAnimated(1500, OriginalBmp, bc.Bitmap, iv)
   End If
   FadedOut = Not(FadedOut)
End Sub
 

Erel

Administrator
Staff member
Licensed User
As Luca wrote the code to make a fade in effect is exactly the same as fade out, you just need to switch the 'FromBmp' and 'ToBmp':
B4X:
  Dim bc As BitmapCreator
   bc.Initialize(OriginalBmp.Width / OriginalBmp.Scale, OriginalBmp.Height / OriginalBmp.Scale)
   bc.FillRect(xui.Color_Transparent, bc.TargetRect)
   effects.TransitionAnimated(1500, bc.Bitmap, OriginalBmp, iv)
 

asales

Well-Known Member
Licensed User
Thanks both of you!

I made the changes and change this part of the code to start with no bitmap:
B4X:
AddImageAndLabel2(Null, "FadeIn (Click)", "FadeIn_Animated")
 
Top