Example #1
0
 /// <summary>
 /// 按照固定的某宽/某高等比例缩放图片
 /// </summary>
 /// <param name="Path"></param>
 /// <param name="Limitwidth">最大宽度</param>
 /// <param name="Limitheight">最大高度</param>
 /// <param name="OutWidth">输出宽度</param>
 /// <param name="OutHeight">输出高度</param>
 public static void GetImageThumbnailSize(string Path, int Limitwidth, int Limitheight, out int OutWidth, out int OutHeight)
 {
     if (!Wf_StringHelper.IsNullOrEmptyByTrim(Path))
     {
         //获取图片
         string filepath = System.Web.HttpContext.Current.Server.MapPath("/") + (Path.IndexOf('/') == 0 ? Path.Remove(0, 1) : Path);
         Image  image    = Image.FromFile(filepath);
         if (image != null)
         {
             if (Limitwidth > 0 && image.Width >= Limitwidth)                    //指定高度进行缩放
             {
                 OutWidth  = Limitwidth;
                 OutHeight = Wf_ConvertHelper.ToInt32(Limitwidth * image.Height / image.Width);
             }
             else if (Limitheight > 0 && image.Height >= Limitheight)    //指定宽度进行缩放
             {
                 OutHeight = Limitheight;
                 OutWidth  = Wf_ConvertHelper.ToInt32(Limitheight * image.Width / image.Height);
             }
             else
             {
                 OutWidth  = image.Width;
                 OutHeight = image.Height;
             }
             return;
         }
     }
     OutWidth  = 200;
     OutHeight = 200;
 }
Example #2
0
 /// <summary>
 /// 将字符串分割,返回int[]数组
 /// </summary>
 /// <param name="input">字符串</param>
 /// <returns>int[]</returns>
 public static int[] SplitRetInt(string input)
 {
     string[] strs = Split(input);
     int[]    ids  = new int[strs.Length];
     for (int i = 0; i < ids.Length; i++)
     {
         ids[i] = Wf_ConvertHelper.ToInt32(strs[i]);
     }
     return(ids);
 }
Example #3
0
 public static int GetHtmlPageCount(string html)
 {
     if (Wf_StringHelper.IsNullOrEmptyByTrim(html))
     {
         return(0);
     }
     try
     {
         Regex           regex  = new Regex("<span class=\"toprand-page-numpage\">.*?</span>");
         MatchCollection matchs = regex.Matches(html);
         string          count  = new Regex(@"^\+?[1-9]\d*$").Match(matchs[matchs.Count - 1].Value).Value;
         return(Wf_ConvertHelper.ToInt32(count));
     }
     catch { return(0); }
 }