The current code to transform images uses an image processing library
to do the work. For many common image types the image data must first
be massaged into the correct format and data structures that are
needed by the general-purpose image processing library. Also, since
the library does not provide an operation which both transforms the
data and also composites the results into a destination image, there
is always at least one intermediate buffer created for each transform
operation, possibly more if various image format conversions end up
being necessary to communicate with the library's internal formats.
It should be possible to create our own routines to perform the
task of image transformation and blending/compositing it into a
destination in one operation with no expensive intermediate buffers.
Finally, the glue code that translates our internal image formats
and data into the format needed by the library has been the source
of many recent bugs and it has been difficult to maintain that
code. Image transformation loops written specifically to our own
internal data structures should not only perform better, but produce
fewer bugs in the future.