国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
一段裁切圖片的代碼 Asp.Net Cropper Image

完整代碼如下:

C# 代碼
//圖片路徑
String oldPath = Server.MapPath("~/aaaa.jpg");

//新圖片路徑
String newPath = System.IO.Path.GetExtension(oldPath);

//設(shè)置截取的坐標(biāo)和大小
int x = 0, y = 10, width = 200, height = 200;

//計(jì)算新的文件名,在舊文件名后加_new
newPath = oldPath.Substring(0, oldPath.Length - newPath.Length) + "_new" + newPath;
Response.Write(oldPath);
Response.Write(
"<br>");
Response.Write(newPath);
Response.Write(
"<br>");
//定義截取矩形
System.Drawing.Rectangle cropArea = new System.Drawing.Rectangle(x, y, width, height); //要截取的區(qū)域大小

//加載圖片
System.Drawing.Image img = System.Drawing.Image.FromStream(new System.IO.MemoryStream(System.IO.File.ReadAllBytes(oldPath)));

//判斷超出的位置否
if ((img.Width < x + width) || img.Height < y + height)
{
  Response.Write(
"截取的區(qū)域超過(guò)了圖片本身的高度、寬度.");
  img.Dispose();
  
return;
}
//定義Bitmap對(duì)象
System.Drawing.Bitmap bmpImage = new System.Drawing.Bitmap(img);

//進(jìn)行裁剪
System.Drawing.Bitmap bmpCrop = bmpImage.Clone(cropArea, bmpImage.PixelFormat);

//保存成新文件
bmpCrop.Save(newPath);

//釋放對(duì)象
img.Dispose();
bmpCrop.Dispose();

 

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開(kāi)APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
powershell 圖片識(shí)別
C# :實(shí)現(xiàn)水印與圖片合成,并利用Graphics 壓縮圖像質(zhì)量 , (委托實(shí)現(xiàn)listB...
WinForm控件與WPF控件的交互
C#如何釋放已經(jīng)加載的圖片
C#圖片存到資源文件,以及調(diào)用圖片
筆記10: 變換圖像
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服