UQYT

c# 图片格式转换

发一个没什么技术含量的东东,调API的话会比较繁琐,代码如下

 

\图片格式转换
publicvoid ImageFormatter(string sourcePath, string distationPath, string format) {
System.Drawing.Bitmap bitmap
=new System.Drawing.Bitmap(sourcePath);
switch (format.ToLower()) {
case"bmp":
bitmap.Save(distationPath, System.Drawing.Imaging.ImageFormat.Bmp);
break;
case"emf":
bitmap.Save(distationPath, System.Drawing.Imaging.ImageFormat.Emf);
break;
case"gif":
bitmap.Save(distationPath, System.Drawing.Imaging.ImageFormat.Gif);
break;
case"ico":
bitmap.Save(distationPath, System.Drawing.Imaging.ImageFormat.Icon);
break;
case"jpg":
bitmap.Save(distationPath, System.Drawing.Imaging.ImageFormat.Jpeg);
break;
case"png":
bitmap.Save(distationPath, System.Drawing.Imaging.ImageFormat.Png);
break;
case"tif":
bitmap.Save(distationPath, System.Drawing.Imaging.ImageFormat.Tiff);
break;
case"wmf":
bitmap.Save(distationPath, System.Drawing.Imaging.ImageFormat.Wmf);
break;
default: thrownew Exception("无法转换此格式!");
}
}

    

分类:

技术点:

相关文章:

  • 2021-10-25
  • 2021-11-01
  • 2021-11-10
  • 2021-09-11
  • 2021-10-25
  • 2021-11-11
  • 2021-09-05
猜你喜欢
  • 2021-09-13
  • 2021-09-13
  • 2021-09-13
  • 2021-12-16
  • 2021-09-13
  • 2021-09-05
  • 2021-10-08
相关资源
相似解决方案