c# 图片缩小成小图片问题
描述:
表中保存原图信息
表结构table_pic(picid,attchment), attchment存放着图片路径
数据内容实例
picid         attchment
UG3D1H9FOO     /upload/UserFiles/pic1.png
原图保存路径
G:\My Documents\Visual Studio 2008\Projects\opckb_net\opckb_net\upload\UserFiles
想把各种格式的图(gif、jpg)缩小成固定宽度,存到G:\My Documents\Visual Studio 2008\Projects\opckb_net\opckb_net\upload\UserFiles
/// <summary>
     /// 返回缩小图片名称(包括路径)
     /// </summary>
     /// <param name="strOldPic">源图文件名(包括路径)</param>
     /// <param name="strNewPic">缩小后保存为文件名(包括路径)</param>
     ///  
     public string get_140(string strOldPic)
     {
         int _index = strOldPic.LastIndexOf('.');
         string strNewPic = strOldPic.Insert(_index, "_140");
         return strNewPic;
     }
/// <summary>
     /// 按比例缩小图片,自动计算高度
     /// </summary>
     /// <param name="strOldPic">源图文件名(包括路径)</param>
     /// <param name="strNewPic">缩小后保存为文件名(包括路径)</param>
     /// <param name="intWidth">缩小至宽度</param>
     public void SmallPic(string strOldPic, string strNewPic, int intWidth)
     {
         System.Drawing.Bitmap objPic, objNewPic;
         try
         {
             objPic = new System.Drawing.Bitmap(strOldPic);
             int intHeight = (intWidth / objPic.Width) * objPic.Height;
             objNewPic = new System.Drawing.Bitmap(objPic, intWidth, intHeight);
             objNewPic.Save(strNewPic);
         }
         catch (Exception exp) { throw exp; }
         finally
         {
             objPic = null;
             objNewPic = null;
         }
     }
调用
string s_ATTACHMENT = "/upload/UserFiles/pic1.png";
string pic_140 = get_140(s_ATTACHMENT);
SmallPic(s_ATTACHMENT, pic_140,140);
出现错误
System.ArgumentException: 参数无效
catch (Exception exp) { throw exp; }
调试时这是空的
objPic = new System.Drawing.Bitmap(strOldPic);
请问strOldPic这块应该怎么写?
------解决方案--------------------
自己解决了,好!
------解决方案--------------------
自己解决了,好!