There is a code:

Pen pen1 = new Pen(Color.Black, 8); Bitmap bb = new Bitmap(100, 100); Graphics g = Graphics.FromImage(bb); g.DrawPolygon(pen1, new PointF[]{ new PointF(0,0), new PointF(100, 0), new PointF(100,100), new PointF(0, 100), new PointF(0, 0) }); bb.Save("test1.bmp"); 

So, in test1.bmp, I expect to see an image with an inscribed rectangle, whose face width will be == pen1.Width, but the width of the face is usually equal to pen1.Width / 2. Why it happens? And how to set the correct drawing coordinates? Thank you in advance.

  • Probably because half of the face is outside the drawing area. - MSDN.WhiteKnight
  • @VadimTagil Why? I can not see this point. I draw differently, everything is in order, but I want to deal with it - Range
  • and how do you want to see something beyond the visible? thickness of the visible line> 0, respectively, to see the entire thickness of the line along the border, the axis of the line must be shifted from the border by half its thickness, as @VadimTagil - Akubik said
  • 3
    See the manual . It may be appropriate to set the Alignment parameter. - Alexander Petrov
  • one
    You set the size of Bitmap 100x100, and draw a rectangle 101x101. the length of the face is considered to be (x2-x1) +1 = (100 - 0) + 1 = 101. Replace the coordinates of the points 100 by 99, and get exactly inscribed rectangle + comment above from Alexander Petrov - rdorn

0