Live Wallpaper; Background

trebun

Member
Licensed User
Longtime User
Hi,

I need help to scale the background images for my live wallpaper.

I take a random flyer from my site with the url:

>> http://.../electronic/fcDownload.php (only some test flyer available)

In the attachments, I uploaded my project (construction area - haha! - not all will work correctly. If all things are done, I will upload and share the code in "Basic4android Share Your Creations"! Promise!)

In the WallpaperService I need to scale the backgroundimage with the right ratio. I need this dynamicly, because not all flyer have the same scaling.

B4X:
Sub LWM_OffsetChanged (Engine As LWEngine)
      
   If Flyer.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.Canvas.DrawBitmap(Flyer, Null, Engine.Rect)

   Else
      Engine.Canvas.DrawColor(Colors.Black)
      Engine.Canvas.DrawText(AResMap.Get("other_placeholder_on_screen"), 120dip, 120dip, Typeface.DEFAULT_BOLD, 30, Colors.White, "LEFT")
   End If
   
   Engine.RefreshAll
End Sub

This works good, but all images on my GNex or N7 are clinched. I think it is a problem with "FullWallpaperHeight" (=1280). But on both devices, I have software buttons they must be subtracted from the "FullWallpaperHeight".

I test it with
B4X:
pScreenHeight=GetDeviceLayoutValues.Height
pScreenWidth=GetDeviceLayoutValues.Width

But I have no Idea with the nice offset x/y. So, please :sign0085:

Regards,
trebun
 

Attachments

  • stretch_wallpaper.jpg
    stretch_wallpaper.jpg
    92.3 KB · Views: 645
Last edited:

Prosg

Active Member
Licensed User
Longtime User
For my tablet Galaxy tab it's 230

for the emulator 320 x 480 scale 1 it's to much probably around 95

i want to know why the black strip have this width

after we could try to find a function to fit

i'm going to test this :

Log("original.Width : " & original.Width )
Log ( "TargetX :" & TargetX)
Log ("actualImageWidth" & : actualImageWidth)

to understand

it's not a solution for landscape but for the black strip

here the result if you find something

original.Width : 360
origRatio : 0.5625
TargetX :1050
targetRatio :0.8203125
scale : 2
actualImageWidth : 720
 
Last edited:
Upvote 0

trebun

Member
Licensed User
Longtime User
Mh, I don't think its the right way, because all my flyers have now the wrong ratio.... ;-)

You can't calculate the right ratio and after this subtract some different values. That must be done in the right ratio...

//Edit: I don't have stripes on my backgroud, is only on your wallpaper. I have just a problem with the landscape...
 
Upvote 0

Prosg

Active Member
Licensed User
Longtime User
the right ratio as be done by erel

the problem we have is that phone use different size so you must fit or crop (if bigger size)


//Edit: I don't have stripes on my backgroud, is only on your wallpaper. I have just a problem with the landscape...

how that possible you have find a solution for the black strip ?
 
Last edited:
Upvote 0

Prosg

Active Member
Licensed User
Longtime User
do you have test with a 320 x 480 mdpi emulator ?

i have always the black strip

test^^
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Hi Fili.
Answering you request from here I could have a look at your problem.
Do you have a test project I could play with ?
Do have a sample image ?
You should leave me some time, I have never used the LiveWallpapers library and need first to learn how it works.

Best regards.
 
Upvote 0

Prosg

Active Member
Licensed User
Longtime User
Thx for help klaus,

2 problems :

- Lanscape wallpaper in tablet, i recreat a post here :
http://www.basic4ppc.com/forum/basi...1-livewallpaper-image-landscape-portrait.html

- In this post you could see Erel code is scaling image code.

This code scale well pictures but there is 4 usually screens :

320 x 480
480 x 800
720 x 1280
800 x 1280

The pictures of my wallpaper live is 800 x 1280 so when it's scale for 320 x 480 or 480x800 there is a black strip.

The ideal is scall as better and fit cause there is no other choose.

Here is the problem :p
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Well, you haven't answered my two questions so I repeat them :
Do you have a test project I could play with ?
Do have a sample image ?

Best regards.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
When I spoke about a test project I meant a small project with source code!
Otherwise I must create a new project from scratch.
It would be easier for the helper to have a same image as you to make tests in the same conditions.

Best regards.
 
Upvote 0

Prosg

Active Member
Licensed User
Longtime User
thx for your help klaus but i'm in a new version of my projet and a lot of think have change

i use 4 size of pictures for 4 devices.

so i can't give u the old project

Trebun have also a problem with landscape as i link u

sorry for my bad english :p maybe i can speak in french if you are suizerland :p
 
Upvote 0

trebun

Member
Licensed User
Longtime User
Sorry, I answer Klaus in German... ;-)
------------------------------------

Hallo Klaus,

in der Anlage findest du ein kleines Projekt, ich habe die wichtigsten Routinen nur eingefügt, um das Projekt klein zu halten! Es gibt keine Fehlerbehandlung oder "Fallbacks" um unerwartete Szenarien abzufangen. Um es einfach zu halten, habe ich auch auf eine Einstellungsseite verzichtet. Es gibt auch keine Prüfung, ob eine Internetverbindung besteht. Einfach nur hoffen, dass ein Flyer geladen werden kann und dieser wird dann eben angezeigt. Kann ab und an paar Sekunden dauern - aber es kommt, wenn kein Fehler von HTTPUtils2 angezeigt wird... ;-)

Das Problem was Fili und ich haben, ist das im "Landscape"-Modus das Bild weiterhin im Portrait angezeigt werden soll (Fili's Wunsch). Mein Wunsch wäre eher, das Bild neu zu skalieren und ggf. nur einen Ausschnitt anzuzeigen - aber das spielt erstmal keine Rolle.

Vielleicht findest du ein eine Lösung!?

Wie man einen LiveWallpaper auswählt, muss ich wohl nicht beschreiben, das Problem tritt auch erst bei neueren Android - Versionen auf, wo man den Homescreen auch entsprechend drehen kann, oder halt über weitere Launcher, die über diese Funktion verfügen.

Es wird HTTPUtils2 verwendet und LiveWallpaper, HTTP (für HTTPUtils2) und StringUtils (ebenfalls für HTTPUtils2)...

Gruß,
trebun

PS: Google-Translation: http://bit.ly/13plFDA ;-)
 

Attachments

  • LiveWallpaper_DEMO.zip
    10.3 KB · Views: 252
Last edited:
Upvote 0

Prosg

Active Member
Licensed User
Longtime User
Ah en français enfin :)

donc je te disais Klaus :) Comment va les chers bouviers suisse:p

Ayant travaillé a Genève pendant un court moment j'étais fasciné par vos chiens ^^

Sinon pour faire simple, j'ai une application qui a des wallpapers d'une artiste manga.

Erel nous a aidé a faire un scalling. Mais en réalité le scalling n'est pas vraiment la solution à mon problème car comme c'est du dessin, le scall des images sont pas parfaites. Et en plus si c'est pas le même ratio, y'a une bande noir qui apparait.
Aussi j'ai préféré opté pour chaque illustration de faire 4 images
320x480 ; 480 x 800 ; 720 x 1280 et 800 x1280

je pense que tu seras d'accord avec cela.

Ensuite en ce qui concerne le mode portrait paysage, ca serait intéressant que sur les tablettes comme ma galaxy tab 2, l'image reste toujours en portrait car il m'est impossible de fournir du paysage d'un dessin. Ca j'ai pas réussi à le faire.

Mon 3ème problème c'est de transformer cette fonction java :
B4X:
WallpaperManager wpm = (WallpaperManager) getSystemService(WALLPAPER_SERVICE);
WallpaperInfo info = wpm.getWallpaperInfo();
if (info != null && info.getComponent().equals(new ComponentName(this, getClass()))) {
    Log.d(TAG, "We're already running");
    // Still might be a preview, but the user is already running your LWP.
} else {
    Log.d(TAG, "We're not running, this should be a preview");
    // Should definitely be a preview.
}

en basic4android car je dois savoir le nom du live wallpaper actuel. Et si ce n'est pas le mien alors j'envoi la popup de choix de wallpaper

J'ai essayer d'obtenir de l'aide sur ce post sans succès : http://www.basic4ppc.com/forum/basic4android-updates-questions/25140-reflector-name-service.html

Car c'est vrai que ça devient confus la toutes nos demandes

Voila :) en ce qui concerne mon projet. J'avoue que comme yukie c'est cassé les pieds a refaire 4 images / illustration mon urgence est de transformer ce code java pour refaire une maj (pour plus avoir les bande noir) Je verrais la rotation plus tard.

Merci de m'aider si tu le peux

Ps: le drapeau suisse est bien carré :p et c'est pas une anomalie^^
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
@Filt.
How many threads will you open with the same problem ?
Which one are we supposed to answer ?
I told you that I will have a look at it and have begun but I need to understand how all this stuff is working ant this takes its time.
If it were that simple I think you would already have got an answer.
Leave the helpers some time.
With all these threads I'm more inclined to give up rather than to continue.

@Filt
Combien de threads avec le même problème veux-tu encore ouvrir avec ?
Auquel sommes nous supposés répondre ?
Je t'ai dit que j'allais regarder le problème et j'ai commencé mais je dois d'abord apprendre comment tout ça fonctionne et ça prend son temps.
Si c'était si simple que ça je pense que tu aurais déjà reçu une réponse.
Laisse du temps à ceux que aident.
Car avec toutes ces demandes répétées j'aurais plutôt tendance à laisser tomber que de continuer.

Best regards.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Sure, I am working with your test project :).

But as I aready said it needs its time. I've never worked with LiveWallpapers berfore.
In general I post back only when I have a solution and not inbetween.
And afters some hours of trying to understand why things don't work as you expect them to work need breaks and I leave it besides and continue afterwards.
It could need perhaps a few days and tomorrow I'm not at home all day.

Best regards.
 
Upvote 0
Top