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
 TImageEN - Thread safe usage?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

cpstevenc

USA
120 Posts

Posted - Jan 10 2025 :  18:47:33  Show Profile  Reply
I've been using TImageEN in a thread for 10 years now for one process.

Simple process to load jpeg, check width/height, and rescale it if needed to a new file, tag new EXIF stuff on the jpeg.

It has been working fine for years, but now it seems not so much.

I am on Delphi 11.3 and ImageEN 11.4.0 for now.

In my thread, just the creation of the TImageEN will sometimes create an AV error.

I get this to happen in a small stand alone program, that all it does it Create / Load / Free. Randomly happens, but will happen in my tests.

If I wrap just the creation of the TImageEN in a tthread.Synchronize , it passes all every time.

So this probably tells me, i've been lucky for years on doing it the wrong way.

So my question is, what is the best way for threads?

I need to load Image.
I need to check width/height.
I need to rescale and output a new file.
I need to also tag EXIF data.





xequte

38730 Posts

Posted - Jan 10 2025 :  21:25:52  Show Profile  Reply
Hi

For the purposes you mention, there is no reason to use a visual control. You should just use a TIEBitmap.

> I need to load Image.

TIEBitmap.LoadFromFile()

> I need to check width/height

TIEBitmap.Width/Height

> I need to rescale and output a new file

TIEBitmap.Resample()
TIEBitmap.SaveToFile()


> I need to also tag EXIF data

TIEBitmap.Params.EXIF_* := ...;

Note: Ensure you have set TIEBitmap.ParamsEnabled := True before loading


Please see:

http://www.imageen.com/help/TIEBitmap.html

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

cpstevenc

USA
120 Posts

Posted - Jan 10 2025 :  21:58:54  Show Profile  Reply
Very nice... Thanks for the help. That seems to work just fine now!

This code I wrote so long ago and doing it wrong but it worked well all these years.

Which I was lucky I guess. I haven't had to really think about this until it came up.






Go to Top of Page

xequte

38730 Posts

Posted - Jan 11 2025 :  15:07:16  Show Profile  Reply
Hi

A TImageEnView (TImageEn is a legacy component, and internally they are now just a TImageEnView) should be safe to use in a thread if it is used non-visually, so I'd need to see your code to see where the issue is, but you are better to use a TIEBitmap anyway.



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