This is from working code I wrote a few years ago:
private Bitmap CreateCroppedBitmap(Bitmap sourceBmp, Point sourcePoint, Rectangle cropRect)
{
GraphicsUnit gu = GraphicsUnit.Point;
RectangleF sourceRect = sourceBmp.GetBounds(ref gu);
sourceRect.X += sourcePoint.X;
sourceRect.Y += sourcePoint.Y;
sourceRect.Height = cropRect.Height;
sourceRect.Width = cropRect.Width;
PointF[] pointFAry = new PointF[]
{
new PointF(0, 0),
new PointF(cropRect.Width, 0),
new PointF(0, cropRect.Height)
};
Bitmap imageCrop = new Bitmap(cropRect.Width,cropRect.Height);
Graphics gr = Graphics.FromImage(imageCrop);
gr.DrawImage(sourceBmp, pointFAry, sourceRect, gu);
return imageCrop;
}
Here's a sample of using it to get the BackGroundImage in a PictureBox, and create a cropped image that is then set to be the BackGroundImage of a second PictureBox: (this was re-tested today using .NET 4.5 in Visual Studio 2013)
private void PerformCrop(object sender, EventArgs e)
{
Bitmap croppedImage = CreateCroppedBitmap(
(Bitmap) pbxSource.Image,
new Point(200,200),
pbxDestination.DisplayRectangle);
pbxDestination.BackgroundImage = croppedImage;
}
Note that this code is hard-coded to use 'Point as the GraphicsUnit. In this example the crop is the same size as the PictureBox that the cropped bitmap is inserted into, and the crop upper-left is located at 200,200 in the source bitmap.