源代码:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
namespace paomiangege
{
public class ImageConvert
{
private int ICON_W = 64;
private int ICON_H = 64;
public ImageConvert()
{
}
//fileinpath,origaly picture file path,fileoutpath save filepath,index the ImageFormat you want to convert to
public string Convert(string fileinpath, string fileoutpath, string index)
{
try
{
Bitmap bitmap = new Bitmap(fileinpath);
index = index.ToLower();
switch (index)
{
case "jpg": bitmap.Save(fileoutpath, ImageFormat.Jpeg); break;
case "jpeg": bitmap.Save(fileoutpath, ImageFormat.Jpeg); break;
case "bmp": bitmap.Save(fileoutpath, ImageFormat.Bmp); break;
case "png": bitmap.Save(fileoutpath, ImageFormat.Png); break;
case "emf": bitmap.Save(fileoutpath, ImageFormat.Emf); break;
case "gif": bitmap.Save(fileoutp