C#生成缩略图源码
先看调用的方法:
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.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
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
补充:软件开发 , C# ,
上一个:使用c#过滤HTML代码
下一个:C#实现详解DataTable的计算功能