. NET cropping pictures

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.