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

  • 相关阅读:
    微擎签名出错 invalid signature
    微擎 pdo_fetchall() 函数
    Qt 文本文件的读写操作
    Qt Qlistwidget、Qlistview
    Qt保留小数点后一位、两位……
    Excel怎么快速删除全部空行
    光学镜头参数详解(EFL、TTL、BFL、FFL、FBL/FFL、FOV、F/NO、RI、MTF、TV-Line、Flare/Ghost)
    Image J 介绍
    C# MODBUS协议上位机程序
    C/C++ memmove与memcpy的区别及实现
  • 原文地址:https://www.cnblogs.com/luluping/p/1403571.html
Copyright © 2011-2022 走看看