Private voidgetimg () {if(Request.Files.Count <1){return;}varImgup = request.files[0];string[] imgsize = request["imgsize"]. Split ('&');intx = Convert.ToInt32 (decimal. Parse (imgsize[0]. ToString ()));inty = Convert.ToInt32 (decimal. Parse (imgsize[1]. ToString ()));intW = Convert.ToInt32 (decimal. Parse (imgsize[2]. ToString ()));intH = Convert.ToInt32 (decimal. Parse (imgsize[3]. ToString ())); Stream Stream=Imgup. InputStream;//defining an intercept rectangleSystem.Drawing.Rectangle Croparea =NewSystem.Drawing.Rectangle (x, Y, W, h);//the size of the area to intercept//Loading Pictures//System.Drawing.Image img = System.Drawing.Image.FromStream (New System.IO.MemoryStream ( System.IO.File.ReadAllBytes (OldPath));System.Drawing.Image img =System.Drawing.Image.FromStream (stream);//Defining Bitmap ObjectsSystem.Drawing.Bitmap Bmpimage =NewSystem.Drawing.Bitmap (IMG);//to CropSystem.Drawing.Bitmap Bmpcrop =Bmpimage.clone (Croparea, Bmpimage.pixelformat);//Save as new fileBmpcrop.save (Server.MapPath ("~") +"/jcrop/aaa.jpg");//Releasing Objectsbmpimage.dispose (); img. Dispose (); Bmpcrop.dispose ();}
. NET cropping pictures