title: Paint.exe Style Zoom, NearestNeighbour Interpolation halfing boundary pixels
body: <p>Sorry if the title is a little cryptic. Basically I'm creating a zoom control in a c# forms app, the idea is that I can zoom an image by factors, ie. 1x, 2x, 4x, 8x. I need the image to remain pixelated, ie. nearest neighbors. The zooming works wonderfully except that when I select Interp mode to be nearest neighbors when working with the boundary pixels it defaults to the inner color. This is to say that the outer pixels appear to have half the width as the inner pixels, where the issue really comes in is when I add a tooltip to display the x,y co-ordinates of the current moused-over pixel it is thrown off. To be clear, the reason it is thrown off is because I calculate the current pixel as:</p>
  
  <pre><code>void m_pictureBox_MouseMove(object sender, MouseEventArgs e)
  {
      int x = e.Location.X / m_zoomFactor;
      int y = e.Location.Y / m_zoomFactor;
  }
  </code></pre>
  
  <p>and since the outer pixel are half the width... well you get the picture.</p>
  
  <p>The drawing code is simply:</p>
  
  <pre><code>void m_pictureBox_Paint(object sender, PaintEventArgs e)
  {
      if (m_pictureBox.Image!=null)
      {
          e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
          e.Graphics.ScaleTransform((float)m_zoomFactor, (float)m_zoomFactor);
          e.Graphics.DrawImage(m_pictureBox.Image, 0, 0);
      }            
  }
  </code></pre>
  
  <p>The picture control is hosted within my custom 'ZoomControl' which is itself inherited from the 'Panel' control. </p>
  
  <p>My question is basically, can any body help me resolve the boundary pixel issue and is there a better way to get zoom functionality?</p>