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
 Using TImageEnMView.LoadSnapshot
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Patrick Quinn

United Kingdom
81 Posts

Posted - Nov 17 2012 :  10:50:20  Show Profile  Reply
Hi

I want to use TImageEnMView.LoadSnapshot when loading thumbnails from a directory, but can't see any examples in the Demos.
I just want to check the correct way of using it.

Do I load the snapshot with

TImageEnMView.LoadSnapshot

then immediately use

TImageEnMView.FillFromDirectory

to make sure the thumbnails are shown are correct (in case folder contents have changed)?

Is this the best way of doing it?

Thanks

Patrick

Patrick Quinn

United Kingdom
81 Posts

Posted - Nov 20 2012 :  13:50:16  Show Profile  Reply
I've tried similar code to this, but it isn't doing what I expected.
with ImageEnMViewMain do
    begin
        //  Save snapshot of current thumbnails
        if Length(CurrentDirectory) > 0 then
          try
            SaveSnapshot(CurrentDirectory + '\SNAPSHOT.FILE');
          except end;
        Clear;

        //  Load thumbnails snapshot from new directory      
        if FileExists(NewDirectory + '\SNAPSHOT.FILE') then
          begin
            LoadSnapshot(NewDirectory + '\SNAPSHOT.FILE');
            Update;
          end;

        //  Reload thumbnails from images (in case directory contents has changed)
        try
          LockPaint;
          Clear;
          FillFromDirectory(NewDirectory);
        finally
          UnLockPaint;
          Paint;
        end;
   end;
Does SaveSnapshot just save thumbnails from images containing embedded thumbnails? There is very little information in the help file on how to use this.

regards

Patrick
Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 20 2012 :  17:59:02  Show Profile  Reply
Patrick;

I think you are expecting too much from LoadSnapshot and FillFromDirectory.

All that LoadSnapShot does is to fill ImageEnMView with bitmaps saved to a snp file. SaveSnapShot saves all images, caches, texts and thumbnails size in the specified ile. This is useful to create caching mechanism like Windows .db files, to load quickly an entire directory of images.

When you call TImageEnMView.LoadSnapshot it fills ImageEnMView with images contained in the snapshot file much faster than any other ImageEnMView.IO method. That's its purpose - to quickly load a saved set of images into ImageEnMView.

When you call TImageEnMView.LoadSnapshot in your example code followed by TImageEnMView.Clear, Clear removes all the images you just loaded with LoadSnapshot. Then when you call FillFromDirectory(NewDirectory) ImageEnMView is populated again with images in the NewDirectory.

What you are doing is of little value and actually not sound because you are filling ImageEnMView, then immediately removing the images you just loaded and then refilling ImageEnMView with images again.

You might be able to write a procedure that compares all of the filenames in ImageEnMView with a list of files in the new folder. Unfortunately will will require quite a bit of time and probably would be very slow with folders with large numbers of files so you negate any value of using LoadFromSnapShot anyway.

You might be better off just building a stringlist of filenames in the CurrectDirectory and a stringlist of filenames in the NewDirectory and compare the files in each list to extract filenames not already in the CurrentDirectory. Once you have a list of missing files you can just append the missing images to the end of ImageEnMView.

One way you might be able to speed this up is to use TShellNotification or some other third-party shell notification component to create a new snapshot of the files in the folder whenever a new file is added to the folder using ImageEn but that is well beyond what I would attempt to do here.

I am sorry I could not have been more optimistic about solving your problem. You may be able to achieve this, but it will take quite a bit of thought, significant amount of code and time to develop it.

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: