Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 1 Jahr, 2 Monaten
Letzter Beitrag:
vor 1 Jahr, 1 Monat
Beteiligte Autoren:
Luis Antonio Gutiérrez Flores, Yogi Yang

[WM20] - Lazy loading of images from remote server

Startbeitrag von Yogi Yang am 21.04.2017 05:26


I am trying to load images from a web server using following code in a looper:

IF ErrorOccurred = False THEN
sResult is Buffer = HTTPGetResult(httpResult)
IF Position(sResult,"404") THEN
Info(HTMLToText(sResult)) // or some other error handling to indicate the file was not found
IF Length(sResult) > 0 THEN
LOOP_Content.ATT_AttThumbnail[nLooperItemNum] = sResult
END //IF Position(sResult,"404") THEN
END //IF ErrorOccurred = Fals

The images are of size 512 x 512 pixels. But to load 25 to 40 images it is taking a hell of a time.

Is there any way by which we can load the images as and when a particular looper item becomes visible (comes on screen)?

Please guide me as to how to speed up the loading of images if there are any other better ways.



I've never done this but by looking at the help you can do the following.
Initially load your looper with 10 images, then you can calculate by x and y position of a certain looper row when to load the next 10 images when the user scrolls enough. Define the some variables with the X and Y Position that have your 10th looper row when it is visible at the end of the looper, for example X = 0 and Y = 680, depending on your device, also you can do some operations to assign certain percent of the screen to be this limit, for example the lower quarter of your screen, and when the 10th row of the looper is inside this position, you can load the next 10 images, you'll need to set a counter to know where you are positioned, because when loading the next 10 now you'll need the position of the 20th row, and so on. I guess you'll need to add the Rollover event in your looper and do the next code

xLimit and yLimit can be global variables where you have your limits as I mentioned before, and nCounter also a global variable where you count which is your last row at the moment

nRow is int = LooperInfoXY(LOOP_Looper1, liLineNumber, xLimit, yLimit)
IF nRow = nCounter THEN
//Load next 10 images
nCounter += 10

Don't know if this will work, just an idea I had. Good luck!

von Luis Antonio Gutiérrez Flores - am 08.05.2017 21:22

Thanks for the idea!

Here is what I will do.

First I will load 10 images and then show a button Load More... Now when the user clicks on this button will load 10 more images and so on....

Once again thanks.


von Yogi Yang - am 09.05.2017 10:46
Yup that will also work! You're welcome :D

von Luis Antonio Gutiérrez Flores - am 09.05.2017 13:28
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.