title: Crop image in c#
body: <p>I have a image that I want to crop it when I press a button on the form. I have the following code that is run when the button is pressed, but it doesn't do anything to the image:</p>
  
  <pre><code>try
  {
    Image image = Image.FromFile("test.jpg");
    Bitmap bmp = new Bitmap(200, 200, PixelFormat.Format24bppRgb);
    bmp.SetResolution(80, 60);
  
    Graphics gfx = Graphics.FromImage(bmp);
    gfx.SmoothingMode = SmoothingMode.AntiAlias;
    gfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
    gfx.PixelOffsetMode = PixelOffsetMode.HighQuality;
    gfx.DrawImage(image, new Rectangle(0, 0, 200, 200), 10, 10, 200, 200, GraphicsUnit.Pixel);
    // Dispose to free up resources
    image.Dispose();
    bmp.Dispose();
    gfx.Dispose();
  }
  catch (Exception ex)
  {
    MessageBox.Show(ex.Message);
  }     
  </code></pre>
  
  <p>My image is actually a screenshot of the active window of the form with the following code:</p>
  
  <pre><code>Rectangle bounds = this.Bounds;
  using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
  {
    using (Graphics g = Graphics.FromImage(bitmap))
    {
      g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
    }
    bitmap.Save("test.jpg", ImageFormat.Jpeg);
  }
  </code></pre>
  
  <p>To finish this, at the press of the same button, first I want to take the screenshot of the form, then crop that image, but cropping doesn't work. Why is that?</p>