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
 Image loading with TImageEn AsynchMode
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

harry113

3 Posts

Posted - Sep 16 2015 :  10:56:40  Show Profile  Reply
Hi,

Can I use TImageEn AsychMode to load 2 or more different images different TIEBitmaps in parallel?

Something like this example from the help file but for loading?

// multithread saving
Var
Bmp: TIEBitmap;
Io: TImageEnIO;
Begin
Bmp := TIEBitmap.Create;
Io := TImageEnIO.CreateFromBitmap(bmp);

Io.LoadFromFile('C:\input.bmp');
Io.AsyncMode := True; // this makes a thread foreach input/output task
Io.SaveToFile('D:\i1.jpg'); // thread-1
Io.SaveToFile('D:\i2.jpg'); // thread-2
Io.SaveToFile('D:\i3.jpg'); // thread-3

// waits all threads finish
Io.WaitThreads();
...
End;




xequte

38517 Posts

Posted - Sep 17 2015 :  01:16:23  Show Profile  Reply
Hi

A TIEBitmap can only store one image, so if you load two images simultaneosly, the second image would replace the first one. Why not just create two TImageEnIO's?

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

harry113

3 Posts

Posted - Sep 17 2015 :  03:34:42  Show Profile  Reply
Hi,

I tried to do it that way,
...

bm1:= TIEBitmap.create;
bm2:= TIEBitmap.create;

IO1:= TImageEnIO.Create(nil);
IO2:= TImageEnIO.Create(nil);


IO1.AsyncMode:= True;
IO2.AsyncMode:= True;

IO1.AttachedIEBitmap:= bm1;
IO2.AttachedIEBitmap:= bm2;

IO1.LoadFromFile('File1.jpg');
IO2.LoadFromFile('File2.jpg');

IO1.WaitThreads;
IO2.WaitThreads;

FreeAndNil(IO1);
FreeAndNil(IO2);

...

Ofcourse after loading I need bm1 und bm2 for further work.

In my example I used this schema to load up to 8 files in parallel with mixed results - WaitThreads crashed, empty bm1, access violations etc...

Is there some sample Code for loading files in parallel in Asynch Mode?

Best Regards,

Harry

Go to Top of Page

xequte

38517 Posts

Posted - Sep 17 2015 :  21:23:11  Show Profile  Reply
Hi Harry

That code should work fine. I just tested it to be sure. If you are seeing a crash please post a full example.

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