使用
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