title: Graphics.DrawImage not changing size of image
body: <p>I have a function which takes in an image and resizes it to fit a canvas while maintaining its aspect ratio. This code is only a minorly modified version of the code from this answer:  <a href="https://stackoverflow.com/questions/1940581/c-sharp-image-resizing-to-different-size-while-preserving-aspect-ratio">c# Image resizing to different size while preserving aspect ratio</a></p>
  
  <p>For this example, my canvas height is 642, my canvas width is 823.</p>
  
  <p>When I run the below function, the line</p>
  
  <pre><code>graphic.DrawImage(image, posX, posY, newWidth, newHeight);
  </code></pre>
  
  <p>seemingly does nothing to the image size. Going in:</p>
  
  <pre><code>Image.Height == 800, 
  Image.Width == 1280.
  newHeight = 514,
  newWidth == 823
  </code></pre>
  
  <p>AFTER running graphic.DrawImage</p>
  
  <pre><code>Image.Height == 800, 
  Image.Width == 1280.
  </code></pre>
  
  <p>As you can see, Image's height and width are unchanged. </p>
  
  <p>Does anyone see a gapingly obvious error that would cause this to happen? Thank you!</p>
  
  <pre><code>    private Bitmap resizeImage(Bitmap workingImage,
                           int canvasWidth, int canvasHeight)
      {
          Image image = (Bitmap)workingImage.Clone();
  
          System.Drawing.Image thumbnail =
              new Bitmap(canvasWidth, canvasHeight); 
  
          double ratioX = (double)canvasWidth / (double)workingImage.Width;
          double ratioY = (double)canvasHeight / (double)workingImage.Height;
  
          double ratio = ratioX &lt; ratioY ? ratioX : ratioY;
  
          int newHeight = Convert.ToInt32((double)workingImage.Height * ratio);
          int newWidth = Convert.ToInt32((double)workingImage.Width * ratio);
  
          int posX = Convert.ToInt32((canvasWidth - ((double)workingImage.Width * ratio)) / 2);
          int posY = Convert.ToInt32((canvasHeight - ((double)workingImage.Height * ratio)) / 2);
  
          using (Graphics graphic = Graphics.FromImage(thumbnail))
          {
              graphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
              graphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
              graphic.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
              graphic.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
  
              graphic.Clear(SystemColors.Control); 
              graphic.DrawImage(image, posX, posY, newWidth, newHeight); //&lt;--- HERE
          }
  
          System.Drawing.Imaging.ImageCodecInfo[] info =
                           System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders();
          System.Drawing.Imaging.EncoderParameters encoderParameters;
          encoderParameters = new System.Drawing.Imaging.EncoderParameters(1);
          encoderParameters.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality,
                           100L);
  
          return workingImage;
      }
  </code></pre>