/// <summary> /// 裁剪图片 返回服务器保存的路径 /// </summary> /// <param name="url"></param> /// <param name="startX"></param> /// <param name="startY"></param> /// <param name="iWidth"></param> /// <param name="iHeight"></param> /// <param name="filename">文件名</param> /// <param name="dirpath">保存路径</param> /// <returns></returns> public static string ImgCut(Bitmap bit, int startX, int startY, int iWidth, int iHeight, string filename = "1.jpeg", string dirpath = "图片保存目录") { var img = Cut(bit, startX, startY, iWidth, iHeight); if (!Directory.Exists(HttpContext.Current.Server.MapPath(dirpath))) { Directory.CreateDirectory(HttpContext.Current.Server.MapPath(dirpath)); } var filepath = dirpath + "/" + filename; img.Save(HttpContext.Current.Server.MapPath(filepath), ImageFormat.Jpeg); img.Clone(); img.Dispose(); return filepath; }