' Copy part of an image onto another part of the image.
Private Sub btnGo_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnGo.Click
' Get the Bitmaps and a Graphics object
' for the destination Bitmap.
Dim fr_bm As New Bitmap(picImage.Image)
Dim to_bm As New Bitmap(picImage.Image)
Dim gr As Graphics = Graphics.FromImage(to_bm)
' Get source and destination rectangles.
Dim fr_rect As New Rectangle(240, 20, 130, 100)
Dim to_rect As New Rectangle(10, 10, 130, 100)
' Draw from the source to the destination.
gr.DrawImage(fr_bm, to_rect, fr_rect, _
GraphicsUnit.Pixel)
gr.DrawRectangle(Pens.Red, to_rect)
' Display the results.
picImage.Image = to_bm
End Sub
|