Beispiel #1
0
 public string GetThumb(int width, int height, ThumbMethod method = ThumbMethod.Resample)
 {
     return GetThumb(width, height, method, Source);
 }
Beispiel #2
0
 /// <summary>
 /// 取缩略图
 /// </summary>
 /// <param name="width">缩略图高</param>
 /// <param name="height">缩略图宽</param>
 /// <param name="crop">缩略方法</param>
 /// <returns>缩略图路径</returns>
 public static string GetThumb(int width, int height, ThumbMethod method, string source)
 {
     string temp = "";
     if (!string.IsNullOrEmpty(source))
     {
         if (File.Exists(source))//虚拟中控 缓存
         {
             temp = string.Concat(source, ".jpg");
         }
         else //中控网络资源
         {
             try
             {
                 temp = Path.GetExtension(source);
                 string tmstr = "";
                 switch (method)
                 {
                     case ThumbMethod.Resample:
                         tmstr = "_";
                         break;
                     case ThumbMethod.Crop:
                         tmstr = "x";
                         break;
                     default:
                         tmstr = "_";
                         break;
                 }
                 temp = string.Format("{0}.jpg{1}{2}_{3}.jpg", source.Substring(0, source.LastIndexOf(temp)),
                     tmstr, width, height);
             }
             catch { }
         }
     }
     return temp;
 }