title: How do I paint a pictureboxes 'centered' background image to panel?
body: <p>I was nicely supplied a code from Alex M, for painting the background image to a panel but realized that if a <code>PictureBox</code>'s <code>BackgroundImage</code> has its Center image property set, the drawn image becomes stretched but not centered. I so far have this code:</p>
  
  <pre><code>private void panel1_Paint(object sender, PaintEventArgs e)
  {
      e.Graphics.DrawImage(pictureBox1.BackgroundImage, 
          new Rectangle(pictureBox1.Location, pictureBox1.Size));
  }
  </code></pre>
  
  <p>This draws the background image to the panel but if <code>pictureBox1</code>'s background image property is set to CENTER, it does not paint the image in the Center of the Rectangle, but instead stretches the image to fit the rectangle. </p>
  
  <p>The only possible solution I've found is <a href="http://www.java2s.com/Code/CSharp/2D-Graphics/CenteranImageVerticalResolutionHorizontalResolution.htm" rel="nofollow">here</a> but I can't make any sense of it.</p>