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
 Animated GIF slow loading
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

FabCob

5 Posts

Posted - Jan 25 2022 :  05:49:36  Show Profile  Reply
Hello,

I use TcxImage (Devexpress) to load animated GIF and it's work fine.
I would like to migrate to ImageEn component but compared to Tcximage it is very very slow to load animated GIF.
For the moment I only want to show animation = Readonly without any interaction.
I have tried both TImageEn and TImageEnView component.

Loaded like this :

ImageEnView1.io.LoadFromFileGIF('c:\MyAnimatedPicture.gif');

or

ImageEnView1.LockUpdate;
try
 ImageEnView1.io.LoadFromFileGIF('c:\MyAnimatedPicture.gif');
finally
  ImageEnView1.UnLockUpdate;
end;


I have tried to change some properties but nothing has improved speed of loading. But there is a lot of properties. Or maybe it is because Imageen is oriented image editing ?
I'am sure that is exist a way to speed up loading of animated GIF !

Any suggestion ?

I use ImageEn version 10.0.0.0 with Delphi 10.3.3.

xequte

38608 Posts

Posted - Jan 25 2022 :  16:47:26  Show Profile  Reply
Hi

In our tests, we have found our GIF loading to be comparable to other libraries (e.g. essentially the same as loading via Windows Imaging Component). Is it the loading itself that you are saying is slow, i.e. have you put the performance timer around the LoadFromFileGIF() call?

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

FabCob

5 Posts

Posted - Jan 26 2022 :  11:01:46  Show Profile  Reply
Hello,


See in attachment full source and TcxImage is 500 times quicker than TImageEnView (at first loading) !




Only with this code :
procedure TForm18.b_TImageEnViewClick(Sender: TObject);
var
  LStopWatch:TstopWatch;
begin
  LStopWatch.Reset;
  LStopWatch.Start;
  ImageEnView1.IO.LoadFromFileGIF(ReturnGifFileName);
  LStopWatch.Stop;

  Edit2.text:=LStopWatch.ElapsedMilliseconds.tostring+' ms';

end;

function TForm18.ReturnGifFileName:TFilename;
begin
  result:= tpath.Combine( ExtractFilePath(paramstr(0)),ANIMATED_GIF_FILENAME);
end;

procedure TForm18.b_TcxImageClick(Sender: TObject);
var
  LStopWatch:TstopWatch;
begin
  LStopWatch.Reset;
  LStopWatch.Start;
  cxImage1.Picture.LoadFromFile(ReturnGifFileName);
  LStopWatch.Stop;

  Edit1.text:=LStopWatch.ElapsedMilliseconds.tostring+' ms';

end;







attach/FabCob/2022126105920_AnimatedGif.zip
3681.35 KB



Download Attachment: 2022126105920_AnimatedGif.zip
Go to Top of Page

xequte

38608 Posts

Posted - Jan 26 2022 :  22:51:55  Show Profile  Reply
OK, so the issue here is one of GIF merging.

Loading a single frame with ImageEn is fast, e.g. loading frame 0 is four times faster than TImage (I don't have DevExpress).




But if you need to load the 100th frame, for example, then all 99 frames before the frame we want must be loaded to ensure we have the correct content for frame 100 (as the frame is generally a merge of all the ones before it).

So the way around that is caching. ImageEn caches the previous frame so that the next frame can be loaded extra quickly. At present it only does this when seeking or playing frames, but we will add a GIFCaching property to TImageEnIO in the next update.

You can email us for it if you like.

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

xequte

38608 Posts

Posted - Jan 26 2022 :  23:18:33  Show Profile  Reply
For the next release we have also added an all frames option to cache all frames of the GIF file in memory. It is slow for the first load, but all subsequent frame loads will be instantaneous.

You would only use that option if you need to access the frames in a non-consecutive order (accessing them randomly or playing the frames backwards, for example).

// General usage to speed up loading of GIF frames
ImageEnView1.IO.GIFFrameCaching := iefcAlways;
cnt := IEGetFileFramesCount( GetGifFilename() );
for i := 0 to cnt - 1 do
begin
  ImageEnView1.IO.GIF_ImageIndex := i;
  ImageEnView1.IO.LoadFromFileGIF( GetGifFilename() );
  ImageEnView1.IO.PrintImage();
end;

// Caching of all frames so that we can access random frames very quickly (initial load is slower, and uses more memory)
ImageEnView1.IO.GIFFrameCaching := iefcAllFrames;
ImageEnView1.IO.GIF_ImageIndex := idx;
ImageEnView1.IO.LoadFromFileGIF( GetGifFilename() );


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

FabCob

5 Posts

Posted - Jan 27 2022 :  03:01:23  Show Profile  Reply
Hello Nigel,

Thank you for your quick answer.

My purpose is only to load and play a animated GIF.
In my software, at login time like on Windows, my end user can choose them photo but it can be an animated GIF. So I only need the quicker loading. 7 s it to long when it's take only 15 ms with Devexpress TcxImage !


So I will wait your next release to test it.
Go to Top of Page

xequte

38608 Posts

Posted - Jan 27 2022 :  15:05:20  Show Profile  Reply
Hi

What version of ImageEn are you using? If animating from frame 0, the first and each subsequent frame should only take <100ms

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

FabCob

5 Posts

Posted - Jan 28 2022 :  01:56:59  Show Profile  Reply
Hi,

I use :
ImageEn 10.0.0 (11 April 2021)
Go to Top of Page

FabCob

5 Posts

Posted - Jan 28 2022 :  03:31:55  Show Profile  Reply
Hello,

I have just update to 10.3.

Now the first loading take same time as DevExpress Tcximage but the next loadings are very long.

So I have tried to add "ImageEnView1.playing:=false;" without any changed in time loading :

procedure TForm18.b_TImageEnViewClick(Sender: TObject);
var
  LStopWatch:TstopWatch;
  cnt:integer;
begin
  LStopWatch.Reset;
  LStopWatch.Start;

  if ImageEnView1.playing then
    ImageEnView1.playing:=false;
  ImageEnView1.IO.LoadFromFileGIF(ReturnGifFileName);
  if not ImageEnView1.playing then
    ImageEnView1.playing:=True;
  LStopWatch.Stop;

  Edit2.text:=LStopWatch.ElapsedMilliseconds.tostring+' ms';

end;


Same with :
procedure TForm18.b_TImageEnViewClick(Sender: TObject);
var
  LStopWatch:TstopWatch;
  cnt:integer;
begin
  LStopWatch.Reset;
  LStopWatch.Start;
  ImageEnView1.LockUpdate;
  if ImageEnView1.playing then
    ImageEnView1.playing:=false;
  ImageEnView1.IO.LoadFromFileGIF(ReturnGifFileName);
  if not ImageEnView1.playing then
    ImageEnView1.playing:=True;
  ImageEnView1.UnLockUpdate;
  LStopWatch.Stop;

  Edit2.text:=LStopWatch.ElapsedMilliseconds.tostring+' ms';

end;



Same with :
procedure TForm18.b_TImageEnViewClick(Sender: TObject);
var
  LStopWatch:TstopWatch;
  cnt:integer;
begin
  LStopWatch.Reset;
  LStopWatch.Start;
 // ImageEnView1.LockUpdate;
  if ImageEnView1.playing then
    ImageEnView1.playing:=false;
  ImageEnView1.Clear;
  ImageEnView1.IO.LoadFromFileGIF(ReturnGifFileName);
  if not ImageEnView1.playing then
    ImageEnView1.playing:=True;
  //ImageEnView1.UnLockUpdate;
  LStopWatch.Stop;

  Edit2.text:=LStopWatch.ElapsedMilliseconds.tostring+' ms';

end;


It's take more time each time I click on my button ...
Go to Top of Page

xequte

38608 Posts

Posted - Jan 28 2022 :  17:08:08  Show Profile  Reply
Hi

Please email me for a source update that supports more GIF frame caching options.

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