using (var bmp = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppArgb))
using (var g = Graphics.FromImage(bmp))
{
g.Clear(Color.Transparent);
g.DrawImage(image, 0, 0);
bmp.Save("image.bmp", ImageFormat.Bmp);
}
The question should be clear: why saving to BMP trashes transparency to black, while saving to PNG keeps it ?
Just to clarify: image is in Format8bppIndexed format and its palette does contain transparent colors (e.g. it draws correctly onto form/picturebox)
Edit: My bad, Bitmap.Save() actually saves BMP in Format32bppRgb format, even though the bitmap format is Format32bppArgb.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…