zoukankan      html  css  js  c++  java
  • .Net上传图片按比例自动缩小或放大

    以下为引用的内容:

    //// <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;
                }
            }

  • 相关阅读:
    背景图片拉伸显示CSS
    可序列化对象和byte[]数组之间的互转
    简单web性能测试工具——ab命令(ApacheBench)
    测试人员必须掌握的linu常用命令
    robot framework 如何处理循环条件下面的变量自增
    robot framework 的关键字Continue For Loop 用法
    robot framework 的AutoItLibrary常用关键字
    robot framework 关键字Switch Browser和Select Window的区别
    robot framework 接口测试 http协议post请求json格式
    robot framework 怎么验证搜索无记录,页面元素不存在
  • 原文地址:https://www.cnblogs.com/luluping/p/1403571.html
Copyright © 2011-2022 走看看