DataGrid: load images when in view

Richard Gaskin ambassador at fourthworld.com
Fri Nov 8 19:10:00 EST 2019


Bob Sneidar wrote:

> On Nov 8, 2019, at 12:25 , Richard Gaskin via use-livecode wrote:
>> The DG will only populate rows as they are brought into view.
>> At any given time the number of rendered rows = the number of
>> visible rows.
>> 
>> I once made a media browser that allows access to 2600 images,
>> and the DG handled it like a champ.
> 
> If he only queries for the data for the visible records.
> Otherwise the query is going to take as long as it takes
> to DL all the data.

True dat.

In our app we solved that problem easily enough, since we only needed 
thumbnails for the list view:

Each of those was less than 200px, and after a little experimenting I 
found that lowering the jpegQuality just a bit when creating those 
thumbnails lowered file size significantly.

Then I packed all 2600 images into an array keyed by file name, encoded 
and zipped it.

The result was a single LSON.gz archive that weighed in at about 1.5 
MBs, and came over the wire in seconds.  Took about as long as the data 
file that references those images.

Our row populating routine used the array to set the thumbnail in the 
DG.

Later when we added a feature to allow image uploads, we added a routine 
to keep the thumbnail archive up to date along with the full-sized 
master.

In four years of production it ran like a champ, seriously outperforming 
a similar tool made by another department in Java (at much greater 
expense).  It's not that Java itself is slower, but just that LC's 
flexibility let us be more clever. :)

--
   Richard Gaskin
   Fourth World Systems
   Software Design and Development for the Desktop, Mobile, and the Web
   ____________________________________________________________________
   Ambassador at FourthWorld.com                
http://www.FourthWorld.com




More information about the use-livecode mailing list