如何在vb.net中裁剪图像?
发布时间:2020-12-17 00:25:52 所属栏目:大数据 来源:网络整理
导读:图像可以是任何东西.它可以是jpg,png,任何东西. 加载它. 裁剪它.假设从左侧删除前100个像素. 保存到同一个文件 使用 Graphics.DrawImage Method (Image,RectangleF,GraphicsUnit)方法. Dim fileName = "C:file.jpg" Dim CropRect As New Rectangle(100,100,
图像可以是任何东西.它可以是jpg,png,任何东西.
加载它. 裁剪它.假设从左侧删除前100个像素. 保存到同一个文件
使用
Graphics.DrawImage Method (Image,RectangleF,GraphicsUnit)方法.
Dim fileName = "C:file.jpg" Dim CropRect As New Rectangle(100,100,100) Dim OriginalImage = Image.FromFile(fileName) Dim CropImage = New Bitmap(CropRect.Width,CropRect.Height) Using grp = Graphics.FromImage(CropImage) grp.DrawImage(OriginalImage,New Rectangle(0,CropRect.Width,CropRect.Height),CropRect,GraphicsUnit.Pixel) OriginalImage.Dispose() CropImage.Save(fileName) End Using (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容