日期:2014-05-17 浏览次数:20433 次
/// <summary>
/// 生成缩略图
/// </summary>
/// <param name="strBigFile">原图文件</param>
/// <param name="strSmallFile">生成缩略图文件</param>
/// <param name="smallSize">缩略图大小</param>
public void MakeSmall(string strBigFile, string strSmallFile, Size smallSize)
{
Bitmap bmp=new Bitmap(Image.FromFile(strBigFile),smallSize);
bmp.Save(strSmallFile);
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Web.UI;
/// <summary>
/// 生成缩略图
/// </summary>
/// <param name="originalImagePath">源图路径(物理路径)</param>
/// <param name="thumbnailPath">缩略图路径(物理路径)</param>
/// <param name="width">缩略图宽度</param>
/// <param name="height">缩略图高度</param>
/// <param name="mode">生成缩略图的方式</param>
public static void MakeThumbnail(string originalImagePath, string thumbnailPath, 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"://指定高宽缩放(可能变形) &n