public static void SaveSmallImage(string photoPath, string savePath, int mWidth, int mHeight)
{
System.Drawing.Image image, aNewImage;
int newWidth, newHeight;
System.Drawing.Image.GetThumbnailImageAbort callb = null;
image = System.Drawing.Image.FromFile(System.Web.HttpContext.Current.Server.MapPath(photoPath));
newHeight = mHeight;
newWidth = mWidth;
if (mWidth == 0)
{
newWidth = image.Width / image.Height * newHeight;
}
if (mHeight == 0)
{
newHeight = image.Height / image.Width * newWidth;
}
aNewImage = image.GetThumbnailImage(newWidth, newHeight, callb, new System.IntPtr());
aNewImage.Save(System.Web.HttpContext.Current.Server.MapPath(savePath), System.Drawing.Imaging.ImageFormat.Jpeg);
}
分享到:
相关推荐
可以根据不同参数生成缩略图片,而且不变形
asp.net生成缩略图通用简单函数 asp.net生成缩略图通用简单函数
asp.net生成缩略图通用函数(支持多种生成方式)_支持图片裁减
asp.net 生成缩略图源码,只要你懂得文件上传,就会明白这个原理,首先是定义大小,其次是根据软件的内置画板来填充的!祝你们好运
原类生成的缩略图的问题在于:高或者宽可能会大于需求值。比如,我需要的图片宽为150,高为120,当原图 * 高为150,宽为150或差距不大时,生成的图片不会有变化,即也是高150,宽150,这样,当把这些图片显示到网页...
才用C# asp.net编写的生成缩略图软件。希望对大家有所帮助。绝对可用,实用。
asp.net 自动生成缩略图,asp.net 自动生成缩略图,asp.net 自动生成缩略图
当我们要上传图片的时候,往往需要生成缩略图,以往我们要使用第三方控件才能完成。在asp.net中用下面方法轻松搞定 Sub Page_Load(sender As Object, e As EventArgs) Dim image,aNewImage As System....
灵梦版缩略图插件,基于.NET2.0版本开发,可用于ASP.NET网站、应用程序等,插件特点:可指定生成图片大小(如生成图与原图比例不符不会变形),可自由指定图片质量(也可依此调整生成图片所占空间大小),可指定图片水印...
解决.net缩略图质量问题 Asp.net生成高质量缩略图
namespace web三层 { /// <summary> /// 显示请求图片的缩略图,以宽度100像素为最大单位 /// </summary> public class imgSmall : IHttpHandler { //图片所在文件夹 static string picturesPath = @”d:\...
本文详细介绍在ASP.NET中上传图片并生成缩略图 在ASP.NET中上传图片并生成缩略图!
asp.net 生成缩略图代码,需要的朋友可以参考下。
Asp.net图片生成缩略图 Asp.net图片生成缩略图
做站的时候经常会遇到要生成缩略图的功能,因为可能不同的情况需要用来不同大小的缩略图。 本文生成的图片都为正方形,只有正方形的缩略图才是保证图片足够清晰。 当我我这里说的正方形是先按比例压缩,然后加一个...
/// <summary> /// 生成缩略图 /// </summary> /// 源图路径(物理路径)</param> /// 缩略图路径(物理路径)</param> /// 缩略图宽度</param> /// 缩略图高度</param> /// ...
ASP.NET图片生成缩略图(VB.NET),高宽自定义
Asp.net上传图片同时生成缩略图和水印图