Looping Animation with LiveWallpaper Library

Highwinder

Active Member
Licensed User
Longtime User
I am in the process of getting schooled (and humbled) by the new Live Wallpaper Library. Major thanks to Erel for cranking that bad boy out. :)

My problem is that I still have not got my head around its use. I'm still a B4A noob, so it's more than just the Live Wallpaper's complexities I'm dealing with.

All I'm trying to do is create a simple live wallpaper that loops through a series of still images and replays them over and over as a looping animation at about 30 frames per second. That's it. One would think this is relatively simple. Well, it's been kicking my ass, and I'm pretty sure I've butchered Erel's example to the embarrassingly pathetic point of wanting to wear a bag over my head.

Details:

1. I have attempted to use the "LiveWallpaper Image" example as a starting point just to get my bearings.

2. I do not want a layout screen of any kind popping up, so I have attempted to disable the one in the example by basically commenting it out. I only want the live wallpaper service to cycle through the series of animatio images I have produced. That's all I want. No menus, no image selection, nothing else.

Any help on this would be appreciated.

:sign0104:

- Highwinder
 
Last edited:

Gigatron

Member
Licensed User
Longtime User
Hi

Not realy understand your problem maybe this example help your project.

Here is Gigatron image routine, this will change rectangle image every x milliseconds.....

LW service


B4X:
      'Service module
Sub Process_Globals
   Dim lwm As LWManager
   Dim LiveEngine As LWEngine
   Dim initialized As Boolean: initialized = False
   Dim imageName As String : imageName = "tempImage"
   Dim image As Bitmap
   Dim backgroundColor As Int
   backgroundColor = 0x0
   
     
   Dim bmp As Bitmap
 
    Dim Accelerometer As PhoneAccelerometer
   
   
   Dim rec As Rect
   Dim rec2 As Rect
    
   Dim tck As Int
   Dim rdx,ypos As Int
   Dim fl1 As List
    
   Dim flindex As Int
   
   flindex=0
   Dim style As String
    Dim nb(30) As Int
   
    Dim xx,yy As Int
End Sub


B4X:
Sub Service_Create
   lwm.Initialize("lwm", True)

   fl1.Initialize
   image.Initialize(File.DirAssets,"012.jpg") ' default pic
'   
' store image from dir asset to fl1 list......
       fl1.AddAll(Array As String("pr0.png","pr1.png","pr2.png","pr3.png","pr4.png","pr5.png","pr6.png","pr7.png","pr8.png","pr9.png","pr10.png","pr11.png","pr12.png","pr13.png","pr14.png","pr15.png","pr16.png","pr17.png","pr18.png","pr19.png","pr20.png","pr21.png","pr22.png","pr23.png","pr24.png","pr25.png","pr26.png","pr27.png","pr28.png","pr29.png"))
'   
   tck=1000 ' 1 second
   lwm.StartTicking(tck) 'Start the wallpaper timer (1000 milliseconds).
    
    
    
     rec2.Initialize(0,0,480,860)
   
     
End Sub



B4X:
Sub lwm_Tick (Engine As LWEngine)
   
   'engine.Canvas.DrawRect(rec2,Colors.Transparent,True,5dip)
   
   
     Engine.Canvas.DrawBitmap(image, Null,engine.Rect)   ' pour arriere plan
   rec.Initialize(0+rdx,200+ypos,500+rdx,500+ypos)
 
   
        bmp.Initialize(File.DirAssets,fl1.Get(flindex))
    engine.Canvas.DrawBitmapRotated(bmp,Null,rec,0)
    flindex=flindex+1
   If flindex>29 Then flindex=0 'nombre d'images de la liste
   
   
  Engine.RefreshAll   
End Sub

Maybe some variables are not used...but it's working...
Good Luck.
 
Last edited:
Upvote 0

Highwinder

Active Member
Licensed User
Longtime User
Mucho Thanko

Gigatron,

Thank you, yes, this does help quite a bit and does indeed point me in the right direction.

Are the images you are using for this at 480x860 in size?


Tremendous thanks,

- Highwinder
 
Last edited:
Upvote 0
Top