title: VB.NET resize and crop images
body: <p>i have a VSTO for powerpoint and want to resize images so they are the same size as the slide. a sample image i have is 1000x300 and the slide is 960x540. so this is the code i have: </p>
  
  <pre><code>_W=960
  _H=540
  
  Dim img As Image = System.Drawing.Bitmap.FromFile(file1)
  OldRect = New RectangleF(233, 0, 533, 300) ' calculated values to crop left and right 
  NewRect = New RectangleF(0, 0, _W, _H)
  
  Dim bmp As Bitmap = New Bitmap(img, _W, _H)
  Dim g As Graphics = Graphics.FromImage(bmp)
  g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
  g.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
  g.CompositingQuality = Drawing2D.CompositingQuality.HighQuality
  g.DrawImage(img, NewRect, OldRect, GraphicsUnit.Pixel) 
  img.Save(file2, Imaging.ImageFormat.Png)
  </code></pre>
  
  <p>but when i look at file2 it's the same 1000x300 file as the original. what am i missing here?</p>