Android Question [Solved] FadeIn effect in BitmapCreator Effects

asales

Well-Known Member
Licensed User
I have the FadeOut effect in the BitmapCreator Effects library:
https://www.b4x.com/android/forum/threads/b4x-bitmapcreator-effects.93608/
where the original bitmap is changed to a black background.

How I can do a "FadeIn" effect, where the black background turned to original bitmap, without have a black image to made the transition?

fadein2.jpg


Thanks in advance for any tip.
 

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
 
Upvote 0

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)
 
Upvote 0

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")
 
Upvote 0
Top