在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
public bool ThumbnailCallback() { return false; } ////oldfile原图地址, newfile新图地址 private void ShowThumbnail(string oldfile,string newfile) { System.Drawing.Image image =System.Drawing.Image.FromFile(oldfile); //获取原图高度和宽度 int oldh = image.Height; int oldw = image.Width; int neww,newh; neww=100;newh=100; //直接设定新图的高宽,,等比缩放代码略, try { System.Drawing.Image.GetThumbnailImageAbort callb=new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback); System.Drawing.Image bt=new System.Drawing.Bitmap(neww,newh); System.Drawing.Graphics gr=System.Drawing.Graphics.FromImage(bt); gr.Clear(Color.White); gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; gr.DrawImage(image, new Rectangle(0,0,neww,newh), 0, 0, oldw,oldh, GraphicsUnit.Pixel); switch(oldfile.Substring(oldfile.Length-3).ToUpper()) { case "JPG": bt.Save(newfile,ImageFormat.Jpeg); break; case "GIF": bt.Save(newfile,ImageFormat.Gif); break; case "PNG": bt.Save(newfile,ImageFormat.Png); break; default: bt.Save(newfile,ImageFormat.Jpeg); break; } gr.Dispose(); bt.Dispose(); image.Dispose(); } catch{} } |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论