码迷,mamicode.com
首页 > 其他好文 > 详细

裁剪图片

时间:2016-04-18 17:09:24      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:

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

 

裁剪图片

标签:

原文地址:http://www.cnblogs.com/OleRookie/p/5404961.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!