首页 新闻 会员 周边 捐助

截图和所选区域大小不一致

0
悬赏园豆:15 [待解决问题]

var path = Server.MapPath(Request.Params["path"] ?? "");
            path = path.Substring(0, path.LastIndexOf('\\')).Replace('\\', '/') + "/Scripts/ligerui/swfupload/uploadFile/";
            var newpath=path+Request.Params["imgname"].ToString();
            var abscissa = Request.Params["abscissa"].ToInt32(0);
            var ordinate = Request.Params["ordinate"].ToInt32(0);
            var width = Request.Params["Width"].ToInt32(0);
            var height = Request.Params["Height"].ToInt32(0);
            var size = Request.Params["size"].ToInt32(0);

            FileStream sFile = new FileStream(newpath, FileMode.Open);
            System.Drawing.Image initImage = System.Drawing.Image.FromStream(sFile, true);

            Int32 photoWidth = size;
            Int32 photoHeight = size;

            System.Drawing.Image templateImage = new System.Drawing.Bitmap(photoWidth, photoHeight);
            System.Drawing.Graphics templateG = System.Drawing.Graphics.FromImage(templateImage);
            templateG.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;//高质量、低速度复合
            templateG.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            templateG.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            templateG.Clear(Color.White);
            templateG.DrawImage(initImage, new System.Drawing.Rectangle(0, 0, photoWidth, photoWidth), new Rectangle(abscissa, ordinate, width, height), System.Drawing.GraphicsUnit.Pixel);
            //var newFileName = FileHelper.GetFileName();
            System.IO.DirectoryInfo idInfo = System.IO.Directory.CreateDirectory(path+CurrentAccount.Id);//创建文件夹
            path = path + CurrentAccount.Id + "/"+size+"x"+size+".jpg";
            templateImage.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg);
            initImage.Dispose();
            sFile.Dispose();
            //System.IO.File.Delete(path);
            return Json(@path, JsonRequestBehavior.AllowGet);

奈c的主页 奈c | 初学一级 | 园豆:187
提问于:2014-04-18 14:28
< >
分享
所有回答(1)
0

问题要描述清楚,一上来就贴一大段代码,

大家都很累呀,注意提问的方式。

xiashengwang | 园豆:209 (菜鸟二级) | 2014-06-24 17:34
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册