如何:将 BMP 图像转换为 PNG 图像
通常,需要转换图像文件格式。 可以通过调用 Image 类的 Save 方法,并将 ImageFormat 指定为所需的图像文件格式来轻松完成转换。
示例
以下示例从一个类型加载 BMP 图像,并以 PNG 格式保存该图像。
private void SaveBmpAsPNG()
{
Bitmap bmp1 = new Bitmap(typeof(Button), "Button.bmp");
bmp1.Save(@"c:\button.png", ImageFormat.Png);
}
Private Sub SaveBmpAsPNG()
Dim bmp1 As New Bitmap(GetType(Button), "Button.bmp")
bmp1.Save("c:\button.png", ImageFormat.Png)
End Sub
编译代码
此示例需要:
Windows 窗体应用程序。
对
System.Drawing.Imaging
命名空间的引用。
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈