Picture path
String OldPath = Server.MapPath ("/111.jpg");
New picture Path
String NewPath = System.IO.Path.GetExtension (OldPath);
Set the coordinates and size of the interception
int x =, y = 0, Width =, height = 500;
Calculates the new file name and adds _new to the old file name
NewPath = oldpath.substring (0, Oldpath.length-newpath.length) + "_new" + NewPath;
Response.Write (OldPath);
Response.Write ("<br>");
Response.Write (NewPath);
Response.Write ("<br>");
Defining a truncated rectangle
System.Drawing.Rectangle Croparea = new System.Drawing.Rectangle (x, y,width, height); The size of the area to intercept
Determine where the excess is
If (img. Width < x + width) | | Img. Height < y + height)
{
Response.Write ("The intercepted area exceeds the height and width of the picture itself");
Img. Dispose ();
Return
}
Defining Bitmap objects
System.Drawing.Bitmap bmpimage = new System.Drawing.Bitmap (IMG);
to crop
System.Drawing.Bitmap Bmpcrop = Bmpimage.clone (Croparea, Bmpimage.pixelformat);
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.