### 代码
```csharp
Image img = Image.FromFile(filename);
// Assumes myImage is the PNG you are converting
using (var b = new Bitmap(img.Width, img.Height)) {
b.SetResolution(img.HorizontalResolution, img.VerticalResolution);
using (var g = Graphics.FromImage(b)) {
g.Clear(Color.White);
g.DrawImageUnscaled(img, 0, 0);
}
// Now save b as a BMP like you normally would
b.Save(@路径, System.Drawing.Imaging.ImageFormat.Bmp);
}
```
原文链接: https://stackoverflow.com/questions/6513633/convert-transparent-png-to-jpg-with-non-black-background-color