C#中上传图片按比例自动缩小或放大
2008-01-02 15:38
746 查看
/**//// <summary>
/// 按比例缩小图片,自动计算宽度
/// </summary>
/// <param name="strOldPic">源图文件名(包括路径)</param>
/// <param name="strNewPic">缩小后保存为文件名(包括路径)</param>
/// <param name="intHeight">缩小至高度</param>
public void SmallPicWidth(string strOldPic, string strNewPic, int intHeight)
...{
System.Drawing.Bitmap objPic, objNewPic;
try
...{
objPic = new System.Drawing.Bitmap(strOldPic);
int intWidth = (intHeight / objPic.Height) * objPic.Width;
objNewPic = new System.Drawing.Bitmap(objPic, intWidth, intHeight);
objNewPic.Save(strNewPic);
}
catch (Exception exp) ...{ throw exp; }
finally
...{
objPic = null;
objNewPic = null;
}
}
/**//// <summary>
/// 缩小图片
/// </summary>
/// <param name="strOldPic">源图文件名(包括路径)</param>
/// <param name="strNewPic">缩小后保存为文件名(包括路径)</param>
/// <param name="intWidth">缩小至宽度</param>
/// <param name="intHeight">缩小至高度</param>
public void SmallPic(string strOldPic, string strNewPic, int intWidth, int intHeight)
...{
System.Drawing.Bitmap objPic, objNewPic;
try
...{
objPic = new System.Drawing.Bitmap(strOldPic);
objNewPic = new System.Drawing.Bitmap(objPic, intWidth, intHeight);
objNewPic.Save(strNewPic);
}
catch (Exception exp)
...{ throw exp; }
finally
...{
objPic = null;
objNewPic = null;
}
}
相关文章推荐
- .Net上传图片按比例自动缩小或放大
- .Net中上传图片按比例自动缩小或放大
- .Net中上传图片按比例自动缩小或放大
- .net上传图片按比例自动缩小或放大
- .Net实现上传图片按比例自动缩小或放大的方法
- .Net实现上传图片按比例自动缩小或放大的方法
- 一个可以使得上传的图片大小按照指定的宽度,高度自动按比例进行缩放的函数(C#)
- [JS]JS控制图片超过宽度自动缩小图片等比例缩放源代码实例
- 鼠标滚动实现图片的放大和缩小(C#2.0)
- [网络收集]使用ASP.net(C#)批量上传图片并自动生成缩略图,文字水印图,图片水印图
- 基于jQuery的图片不完全按比例自动缩小
- 网页图片变形解决方法-固定宽度高度按比例自动缩小CSS
- jQuery: 图片不完全按比例自动缩小
- 使用ASP.net(C#)批量上传图片并自动生成缩略图,文字水印图,图片水印图
- C#图片上传,加水印,自动生成缩略图类
- 在线图片上传、预览、裁切、放大、缩小之 cropbox.js 的应用
- C#上传图片并按比例生成缩略图
- 图片自动按比例缩小代码(防止页面被图片撑破)
- 使用ASP.net(C#)批量上传图片并自动生成缩略图,文字水印图,图片水印图