title: Easiest way of saving wpf Image control to a file
body: <p>I have a Image control inside my wpf application, which has a large image inside of it, but the control itself is only 60x150, this means it only shows a certain portion of this image. 
  What is the easiest way of saving the visible portion to a file?</p>
  
  <p>Thank you for your help.</p>
  
  <p>[EDIT] 
  I ended up using code found <a href="http://nuigroup.com/forums/viewthread/13035/#66981">here</a> (which I've not been able to locate before posting here)...</p>
  
  <pre><code>Grid r = new Grid();
          r.Background = new ImageBrush(image2.Source);
  
  
      System.Windows.Size sz = new System.Windows.Size(image2.Source.Width, image2.Source.Height);
      r.Measure(sz);
      r.Arrange(new Rect(sz));
  
      RenderTargetBitmap rtb = new RenderTargetBitmap((int)image2.Source.Width, (int)image2.Source.Height, 96d, 96d, PixelFormats.Default);
      rtb.Render(r);
  
      BmpBitmapEncoder encoder = new BmpBitmapEncoder();
      encoder.Frames.Add(BitmapFrame.Create(rtb));
  
      FileStream fs = File.Open(@"C:\lol.png", FileMode.Create);
      encoder.Save(fs);
      fs.Close();
  </code></pre>