Code:
Public Function CaptureRectangle(ByVal bmp As Bitmap, ByVal CapRect As Rectangle, ByVal CapRectWidth As Integer, ByVal CapRectHeight As Integer) As Bitmap
Dim bmpImage As Bitmap = bmp
Dim bmpCrop As New Bitmap(CapRectWidth, CapRectHeight)
Dim recCrop As New Rectangle(CapRect.X, CapRect.Y, CapRectWidth, CapRectHeight)
Dim gphCrop As Graphics = Graphics.FromImage(bmpCrop)
Dim recDest As New Rectangle(0, 0, CapRectWidth, CapRectHeight)
Dim attr As New System.Drawing.Imaging.ImageAttributes
gphCrop.DrawImage(bmpImage, recDest, recCrop.X, recCrop.Y, recCrop.Width, recCrop.Height, GraphicsUnit.Pixel, attr)
gphCrop.Dispose()
Return bmpCrop
End Function
That will return a bitmap cropped out of the original image at the start position and width/height specified. Usage is like...
'Define these to the section you want to crop out of the picture
Dim startX, startY, cWidth, cHeight as Integer
Dim oldbmp as Bitmap = new Bitmap("C:\MyPicture.jpg")
Dim newbmp as Bitmap = captureRectangle(oldbmp, new Rectangle(startX,StartY,cWidth,cHeight), cWidth, cHeight)