ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 TImageEnMView - Lots of thumbnails (~300) and speed.
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

cpstevenc

USA
113 Posts

Posted - Nov 22 2022 :  10:48:43  Show Profile  Reply
Using Delphi 11.2 - win32
ImageEN - v11.4.0

Working with lots of "emotes" PNG files.

Almost 900 of them. Split between three

112x112 , 56x56, 28x28

If only A few , speed seems fine.

But once I populate everything, speed takes A hit when navigating.

You can see blank spots for a while until it populates.

I've tried using DiskCache and ImageCacheUseDisk with 300 limit. Which is 3 more than what I have available.

This doesn't speed anything up it seems? PLUS it makes the images bad.

Bad as in duplicated over and over.

If I clear the cache and repopulate, same issues.

1st image, Duplicates with the DisCache and ImageCacheUseDisk. Maybe issue of settings, or using both? not sure.




2nd image, Navigating, blank images for 5+ seconds until they populate.



3rd image, can see 2nd list, duplicated over and over. 3rd image list, the UI is all kinds of messed up.




I have played with ThumbnailResampleFilter to currently rfWICLinear... going for speed over quality. Which I can't tell any difference in either.

So currently now.... DiskCache / ImageCache turned off as doesn't seem to help currently, and clobbers / duplicates.

Basically , like to get these populate as fast as possible, and reduce / remove the issue of thumbnails missing for a few seconds while they populate/draw in when navigating.



xequte

38176 Posts

Posted - Nov 22 2022 :  18:55:24  Show Profile  Reply
Hmmm, it's hard to see any reason for performance issues there. Can you please email me your test application.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

cpstevenc

USA
113 Posts

Posted - Nov 22 2022 :  20:56:38  Show Profile  Reply
Emailed it but attached it here too.

Slimed down to the bare code needed.



attach/cpstevenc/20221122205046_emotetest.zip
5924.05 KB
Go to Top of Page

xequte

38176 Posts

Posted - Nov 22 2022 :  23:01:39  Show Profile  Reply
OK, so there were some performance issues with the app..

Disk caching...

Firstly, set this which works better where filenames are closely matched:

  DiskCacheAlgorithm := -$00008004;

Secondly, you need to use a unique folder for your caching, e.g.

    imageListG4.DiskCache.Folder :=  'D:\emotetest\cache1';
    imageListG2.DiskCache.Folder :=  'D:\emotetest\cache2';
    imageListG1.DiskCache.Folder :=  'D:\emotetest\cache3';

In my testing that gives very good performance (after the initial caching).


Actual vs on-demand filling...

You are filling the content at startup, so ensure that you do not discard any images just because they are not visible:

  imageListG4.MaintainInvisibleImages := -1;
  imageListG2.MaintainInvisibleImages := -1;
  imageListG1.MaintainInvisibleImages := -1;
  imageListG4.StoreType := ietThumb;
  imageListG2.StoreType := ietThumb;
  imageListG1.StoreType := ietThumb;



Your Threaded fill...

You use a thread to fill the content, which is unnecessary as ImageEn will do that for you.

If you are using disk caching, you will get much better responsiveness by just performing a regular fill...

procedure TForm1.PopulateImages();
var
  files: TStringDynArray;
  filename: string;
begin
  imageListG4.StoreType := ietThumb;
  imageListG2.StoreType := ietThumb;
  imageListG1.StoreType := ietThumb;  

  imageListG4.MaintainInvisibleImages := -1;
  imageListG2.MaintainInvisibleImages := -1;
  imageListG1.MaintainInvisibleImages := -1;

  imageListG4.LockPaint;
  imageListG2.LockPaint;
  imageListG1.LockPaint;
  try
    files := TDirectory.GetFiles(FEmoteFolder, '*.png', TSearchOption.soAllDirectories);
    for filename in files do
    begin
      if pos('.1.0.png', filename) > 0 then
        imageListG1.AppendImage(filename);

      if pos('.2.0.png', filename) > 0 then
        imageListG2.AppendImage(filename);

      if pos('.3.0.png', filename) > 0 then
        imageListG4.AppendImage(filename);
    end;

  finally
    imageListG4.SelectImage(0);
    imageListG4.UnlockPaint;
    imageListG2.UnlockPaint;
    imageListG1.UnlockPaint;
  end;
end;


But I prefer loading on demand...

...
    files := TDirectory.GetFiles(FEmoteFolder, '*.png', TSearchOption.soAllDirectories);
    for filename in files do
    begin
      if pos('.1.0.png', filename) > 0 then
        imageListG1.AppendImage(filename + IEM_Path_Index_Delimiter + '[0]' );

      if pos('.2.0.png', filename) > 0 then
        imageListG2.AppendImage(filename + IEM_Path_Index_Delimiter + '[0]' );

      if pos('.3.0.png', filename) > 0 then
        imageListG4.AppendImage(filename + IEM_Path_Index_Delimiter + '[0]' );
    end;
...



Also try the demo:

\Demos\Multi\MViewPerformance\Performance.dpr

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

cpstevenc

USA
113 Posts

Posted - Nov 23 2022 :  10:52:50  Show Profile  Reply
Thanks I'll check this out!

I used a thread, because my current app code has A thread, to download images from a web server and does some other work while populating. The images could be added/removed/ect .. so I won't be just loading from a folder like in the example.

So it was quite a bit simplified for this, but wanted it A thread for this at least to show that I was doing work in a thread.

Anyways

DiskCacheAlgorithm

Where is this? I don't see this in the ImageEn Source.

for idx := 0 to self.ComponentCount - 1 do
  begin
    if self.Components[idx] is TImageEnMView then
    begin
      (Components[idx] as TImageEnMView).DiskCache.Folder := Extractfilepath(application.ExeName) + '\cache\' +
        Components[idx].Name;
      (Components[idx] as TImageEnMView).DiskCache.MinWidth := 5;
      (Components[idx] as TImageEnMView).DiskCache.MinHeight := 5;
      (Components[idx] as TImageEnMView).DiskCache.Enabled := true;
      (Components[idx] as TImageEnMView).MaintainInvisibleImages := -1;
      (Components[idx] as TImageEnMView).StoreType := ietthumb;
    end;
  end;


I did this on my app startup... and it's working extremely well now!

Thanks!


Go to Top of Page

xequte

38176 Posts

Posted - Nov 23 2022 :  15:07:48  Show Profile  Reply
Whoops sorry, DiskCacheAlgorithm is not available until 11.4.5, which should be out next week.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: