title: Clipping images
body: <p>I have the following code to work with images from a stream. My intention is to pick a subregion of it and resize it to 100x100. I do not know the format of the image beforehand.</p>
  
  <pre><code>var image = new Bitmap(stream);
  
  var destArea = new Rectangle(0, 0, 100, 100);
  var srcArea = new Rectangle(x, y, width, height);
  
  var gfx = Graphics.FromImage(image);
  gfx.DrawImage(image, destArea, srcArea, GraphicsUnit.Pixel);
  
  var ms = new MemoryStream();
  image.Save(ms, image.RawFormat);
  </code></pre>
  
  <p>For some reason, this is taking the subregion I want, resizing it and putting it on top of the original image, so that the result is a mixture of the original and my desired result.</p>
  
  <p>I have been through several guides, posts on image processing but I still don't know for sure where am I wrong. Would you mind to help me out?</p>
  
  <p>Also, I would really appreciate if you also explained to me what is it that I'm missing (a little bit of theory behind the code).</p>
  
  <p>Thanks!</p>