i couldnt crop and save an image.Here is my codes.
Rect is my drawed rectangle.
any help please?
Rect is my drawed rectangle.
Code:
Dim save As SaveFileDialog = New SaveFileDialog
save.Filter = "Jpeg File(*.jpg)|*.jpg"
If save.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim source As Bitmap = New Bitmap(PictureBox1.ImageLocation)
Dim DestRect As New Rectangle(0, 0, Rect.Width, Rect.Height)
Dim DestBmp As New Bitmap(Rect.Width, Rect.Height)
Dim g As Graphics = Graphics.FromImage(DestBmp)
g.DrawImage(source, DestRect, Rect, GraphicsUnit.Pixel)
g.Dispose()
DestBmp.Save(save.FileName, System.Drawing.Imaging.ImageFormat.Jpeg)
DestBmp.Dispose()
End If