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

  • 相关阅读:
    Cortex-M3 在C中上报入栈的寄存器和各fault状态寄存器
    Cortex-M3 双堆栈指针(MSP&PSP)
    Cortex-M3 异常返回值EXC_RETURN
    Cortex-M3 异常中断响应与返回
    Cortex-M3 操作模式与特权等级
    Cortex-M3 R0~R15寄存器组 & 特殊功能寄存器组
    【Python】批量修改指定目录下所有文件的文件名/后缀
    【EMV L2】EMV终端数据
    【EMV L2】Cardholder Verification Rule(CVR) Format
    【EMV L2】GPO响应以及AIP、AFL
  • 原文地址:https://www.cnblogs.com/luluping/p/1403571.html
Copyright © 2011-2022 走看看