This PR optimizes the TImage32.CopyToDc method by using a much faster PremultiplyAlpha function and using it to copy and pre-multiply the alpha channel of the pixels in one step into the bitmap's memory.
The old code first copied the image scanlines and then called PremultiplyAlpha on them, reading and writing every pixels twice. The new code only reads and writes the pixels once.
It also fixes the double pre-multiplying of the alpha channel of the image in TImage32.CopyToDc, if it is called with Transparent=True and the image was already pre-multiplied by a call to TImage32.PremultiplyAlpha.
This PR optimizes the TImage32.CopyToDc method by using a much faster PremultiplyAlpha function and using it to copy and pre-multiply the alpha channel of the pixels in one step into the bitmap's memory.
The old code first copied the image scanlines and then called PremultiplyAlpha on them, reading and writing every pixels twice. The new code only reads and writes the pixels once.
It also fixes the double pre-multiplying of the alpha channel of the image in TImage32.CopyToDc, if it is called with Transparent=True and the image was already pre-multiplied by a call to TImage32.PremultiplyAlpha.