Android Question [Solved] FadeIn effect in BitmapCreator Effects

LucaMs

Expert
Licensed User
Longtime 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
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime 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)
 
Upvote 0

asales

Expert
Licensed User
Longtime 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")
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…