LiveWallpaper Image landscape and portrait

Prosg

Active Member
Licensed User
Longtime User
I use liveWallpaper Librarie but with tablet the screen orientation of the Livewallpaper change. As my picture as fixed at portrait i want to have always portrait (Orientation landscape : picture Portrait too)

I know that i have to something like that but all the test i do is not correct :(

B4X:
If GetDeviceLayoutValues.Width > GetDeviceLayoutValues.Height Then
'Landscape
Else
'Portrait
End If

here is the code where i have to check

B4X:
Sub LWM_OffsetChanged (Engine As LWEngine)
   Dim petitEcran As Int = 0
    If image.IsInitialized AND resized.IsInitialized = False Then
   If  Engine.ScreenWidth = 320 Then petitEcran = 95
        resized = ResizeImage(image, Engine.FullWallpaperWidth + petitEcran, Engine.FullWallpaperHeight)
    End If
    If resized.IsInitialized Then
'        Engine.Rect.Left = -Engine.CurrentOffsetX
'        Engine.Rect.Top = -Engine.CurrentOffsetY
'        Engine.Rect.Right = -Engine.CurrentOffsetX + Engine.FullWallpaperWidth
'        Engine.Rect.Bottom = -Engine.CurrentOffsetY + Engine.FullWallpaperHeight
        Engine.Rect.Left = -(Engine.FullWallpaperWidth - actualImageWidth) / 2
        Engine.Rect.Top = 0
        Engine.Rect.Right = Engine.Rect.Left + Engine.FullWallpaperWidth
        Engine.Rect.Bottom = Engine.FullWallpaperHeight
        Engine.Canvas.DrawBitmap(resized, Null, Engine.Rect)
    End If
    Engine.RefreshAll
End Sub

thx for your help
 

trebun

Member
Licensed User
Longtime User
Fili,

you open to much threads for the same issue. ;-)

@Erel,
Fili wants a solution to draw the background from the live wallpaper to portrait, the icons can be rotated, just the background shall not...

Gruß,
trebun
 
Upvote 0

Prosg

Active Member
Licensed User
Longtime User
Thank you for your help ... but what I missed?

B4X:
Sub LWM_OffsetChanged (Engine As LWEngine)
    If image.IsInitialized AND resized.IsInitialized = False Then
        resized = ResizeImage(image, Engine.FullWallpaperWidth, Engine.FullWallpaperHeight)
    End If
    If resized.IsInitialized Then
        Engine.Rect.Left = -(Engine.FullWallpaperWidth - actualImageWidth) / 2
        Engine.Rect.Top = 0
        Engine.Rect.Right = Engine.Rect.Left + Engine.FullWallpaperWidth
        Engine.Rect.Bottom = Engine.FullWallpaperHeight
        'Engine.Canvas.DrawBitmap(resized, Null, Engine.Rect)
      If GetDeviceLayoutValues.Width > GetDeviceLayoutValues.Height Then
      'Landscape
      Engine.Canvas.DrawBitmapRotated(resized, Null, Engine.Rect, -90)
   Else
      'Portrait
      Engine.Canvas.DrawBitmapRotated(resized, Null, Engine.Rect, 0)
   End If
    End If
    Engine.RefreshAll
End Sub

errorRotate.jpg
 
Upvote 0

Prosg

Active Member
Licensed User
Longtime User
I try a lot of time with the way you give me erel but no succes... My fault sorry

I try another way who it's working :

B4X:
Sub LWM_OffsetChanged (Engine As LWEngine)
    If image.IsInitialized AND resized.IsInitialized = False Then
        resized = ResizeImage(image, Engine.FullWallpaperWidth, Engine.FullWallpaperHeight)
    End If
    If resized.IsInitialized Then
   
      If GetDeviceLayoutValues.Width > GetDeviceLayoutValues.Height Then
         'Landscape
         Engine.Rect.Left = 0
         Engine.Rect.Top =  -(Engine.FullWallpaperWidth - actualImageWidth) / 2
         Engine.Rect.Right = Engine.FullWallpaperHeight
         Engine.Rect.Bottom = Engine.Rect.Top + Engine.FullWallpaperWidth
         Engine.Canvas.DrawBitmapRotated(resized, Null, Engine.Rect, -90)
      Else
         'Portrait
         Engine.Rect.Left = -(Engine.FullWallpaperWidth - actualImageWidth) / 2
           Engine.Rect.Top = 0
           Engine.Rect.Right = Engine.Rect.Left + Engine.FullWallpaperWidth
           Engine.Rect.Bottom = Engine.FullWallpaperHeight
           Engine.Canvas.DrawBitmap(resized, Null, Engine.Rect)   
      End If
      

    End If
    Engine.RefreshAll
   

End Sub

Thx a lot for help
 
Upvote 0
Top