I'm just had a look at this thread. I have some comments about the use of TMemroyStream. This can be a great little class to use. However in order to make the most of it I would make use of the capacity property. Also you coul d try and only have one TMemroyStream that all the Init calls use.

You set the capacity to your max size of image then continually use that same stream as a buffer. One of the problems with TMemoryStream is it allocates memory on the fly if you write to it and the capacity < size. it's always better to grad a whole chunk in one go.

Hopefully using one TMemoryStream buffer will cut down on having to create and destroy the stream each time as well.

Hope this helps.