如何在vb.net中裁剪图像?

前端之家收集整理的这篇文章主要介绍了如何在vb.net中裁剪图像?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
图像可以是任何东西.它可以是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
原文链接:https://www.f2er.com/vb/255238.html

猜你在找的VB相关文章