I have trouble re-using a globally allocated TImageEnIO / TImageEnProc (no, not multi-threaded).
I want to use the same instance but operate on different TBitMap/TIEBitMap/TImageEn/TImage, so I assign the IO's AttachedBitmap etc. to the one I want to work on now.
But I run into access violations in TIEBitMap.FreeImage, which gets called with a NIL instance (Stack Trace: TImageEnIO.SetAttachedBitmap -> TIEBitmap.EncapsulateTBitmap -> TIEBitmap.FreeImage).
I have tried setting the various "AttachedXXX" properties to NIL (to "clear" it) before assigning the AttachedBitmap, but that doesn't work either (in some cases, I even get an error when I set one of these to NIL).
What is the proper procedure to use the same TImageEnIO for different use cases (different AttachedXXX)?
What is the proper procedure to re-use a TImageEnIO / TImageEnProc? Should I disable all the AttachedXXX before assigning the correct one, or is an implicit disable of all other AttachedXXX done within a new assignment to any AttachedXXX property?
It should be enough just to assign a new object to AttachedXXX. If you see otherwise, let us know and we will test for that combination. There are some edge cases that may have an undocumented effect such as attaching a TIEBitmap after attaching a TBitmap.
Our recommendation would be not to reuse TImageEnIO or TImageEnProc at all. There would be negligible performance benefits to it. Just create them as needed.