日期:2014-05-17 浏览次数:21370 次
/// <summary>
/// 生成缩略图
/// </summary>
/// <param name="originalImagePath">源路径</param>
/// <param name="thumbnailPath">目标路径</param>
/// <param name="width">宽</param>
/// <param name="height">高</param>
/// <param name="mode">缩略模式</param>
public static Image MakeThumbnail(string originalImagePath, int width, int height, string mode)
{
Image originalImage = Image.FromFile(originalImagePath);
int towidth = width;
int toheight = height;
int x = 0;
int y = 0;
int ow = originalImage.Width;
int oh = originalImage.Height;
switch (mode)
{
case "HW"://指定高宽缩放(可能变形)
break;
case "W"://指定宽,高按比例
toheight = originalImage.Height * width / originalImage.Width;
break;
case "H"://指定高,宽按比例
towidth = originalImage.Width * height / originalImage.Height;
break;
case "Cut"://指定高宽裁减(不变形) &nb