先看調用的方法:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class test_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
generalImage();
}
private void generalImage()
{
string savePath = @"images/123.jpg";//原圖路徑
string smallPath = @"images/small/123.jpg";//要生成的小圖
savePath = Server.MapPath(savePath);//這一步別忘了。
smallPath = Server.MapPath(smallPath);//同樣這裡也不要忘了。
YD.Common.ImageClass imageClass = new YD.Common.ImageClass();
imageClass.ShowThumbnail(savePath, smallPath, 200, 153);//這樣調用
}
}
生成小圖的類:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
/// <summary>
/// ImageClass 的摘要說明
/// </summary>
namespace YD.Common
{
public class ImageClass
{
public bool ThumbnailCallback()
{
return false;
}
public