2
private void Form1_Paint(object sender, PaintEventArgs e)
{
    Pen p = new Pen(Brushes.Black, 1);
    e.Graphics.DrawRectangle(p, 3, 3, 89, 30);
}

Why does this code produce a 90px width / 31px height box? i.e one pixel bigger than requested. BTW: FillRectangle works fine.

  • 2
    That's GDI+'s infamous off-by-one bug. I gave up on it in utter frustration back in 2001 after trying to work around it for a week. Murder when you need to translate/rescale. – Hans Passant Nov 01 '11 at 00:21

1 Answers1

0

I imagine that it is because the command defines the inside size of the rectangle and draws the border around that.

NickLH
  • 2,643
  • 17
  • 28