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);
问题要描述清楚,一上来就贴一大段代码,
大家都很累呀,注意提问的方式。