How to preserve png transparency?
Maybe try changing pixel format form PixelFormat.Format24bppRgb
to PixelFormat.Format32bppRgb
. You need the extra 8 bits to hold the alpha channel.
Using PixelFormat.Format32bppRgb didn't work for me. What worked however is using oldImage.PixelFormat when drawing the new image. So the corresponding line of code becomes:
using (Bitmap newImage = new Bitmap(newSize.Width, newSize.Height, oldImage.PixelFormat))