您现在的位置是:网站首页> 编程资料编程资料
.Net实现上传图片按比例自动缩小或放大的方法_实用技巧_
2023-05-24
406人已围观
简介 .Net实现上传图片按比例自动缩小或放大的方法_实用技巧_
本文实例主要展示了.Net实现上传图片按比例自动缩小或放大的方法,是非常实用的功能。分享给大家供大家参考之用。具体方法如下:
/////// 按比例缩小图片,自动计算宽度 /// /// 源图文件名(包括路径) /// 缩小后保存为文件名(包括路径) /// 缩小至高度 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; } } /**/////// 缩小图片 /// /// 源图文件名(包括路径) /// 缩小后保存为文件名(包括路径) /// 缩小至宽度 /// 缩小至高度 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; } }
希望本文所述实例对大家的asp.net程序设计有一定的借鉴价值。
您可能感兴趣的文章:
相关内容
- 推荐8项提高 ASP.NET Web API 性能的技术_实用技巧_
- asp.net 修饰符介绍(关于public、private、protected、internal)_实用技巧_
- asp.net利用后台实现直接生成html分页的方法_实用技巧_
- 四个常用的.NET的SQLHELPER方法实例_实用技巧_
- 拦截asp.net输出流并进行处理的方法_实用技巧_
- Asp.net中Response.Charset与Response.ContentEncoding区别示例分析_实用技巧_
- asp.net页面SqlCacheDependency缓存实例_实用技巧_
- asp.net中SqlCacheDependency缓存技术概述_实用技巧_
- asp.net中Timer无刷新定时器的实现方法_实用技巧_
- asp.net实现批量删除实例_实用技巧_
