Re: DrawRectangle positioning




"Kevin Spencer" <spam@xxxxxxx> wrote in message
news:OVhx$NP%23GHA.1200@xxxxxxxxxxxxxxxxxxxxxxx
Hi Jon,

I'm not surprised that you've had difficulty with this issue, as it is not
well-documented in the .Net SDK. The crux of the matter is this: When you
draw a rectangle with a pen, the width of the pen must be taken into
account with regards to the size of the target rectangle. There are 3
basic logical possibilities:

1. The entire line is drawn *inside* the rectangle.
2. The width of the line is split, so that the edge of the rectangle is
centered in the line.
3. The entire line is drawn *outside* the rectangle.

It turns out that number *2* is the method employed with GDI+.

The following is an excellent and detailed article on the subject:

http://www.bobpowell.net/beginnersgdi.htm


Thanks. I figured it was 2 because the other 2 I tried didn't work. At first
I thought it was a mixture of 1 and 2(the left and top being on the inside
and the bottom and right being on the outside) but none of my calculations
worked and I couldn't find any info regarding it.

Thanks again,
Jon


.



Relevant Pages

  • Re: Printing the whole whole printable area
    ... your rectangle are being drawn just outside of the printable area. ... need to inset the right and bottom by a pixel to get the line into the ... But at the very least, you need to understand that if you try to draw a rectangle that is the same exact width and height as what you believe to be the valid area for drawing, the right and bottom edges will not be drawn. ... For the record, the following code, when I use it with the Office Document Image Writer print driver, it prints a frame exactly the way you want: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Draw a path with a Pen which has a width of 2?
    ... For a circle or rectangle, your drawn area will be larger than the geometry ... > The border can also have different shapes such as Round, Circle, ... When I use a width of 2, the path is not drawn correctly. ...
    (microsoft.public.dotnet.framework.drawing)
  • vertical text not drawn at correct location
    ... the center of the display. ... Text is suppose to be drawn at a 270 degree ... angle and centered in the middle of the rectangle. ... CRect oCR; ...
    (microsoft.public.vc.mfc)
  • Re: vertical text not drawn at correct location
    ... Your suggestions works in the sample code but not my ... Ian ... Text is suppose to be drawn at a 270 degree ... >> angle and centered in the middle of the rectangle. ...
    (microsoft.public.vc.mfc)
  • Re: How to Drawstring with a character drawn "partially"?
    ... Regarding drawing text character partially, I'm not too sure how to use the ... > You could draw the text without setting a layout rectangle, ... >> But I find that if a character cannot fit into the rectangle, ... >> character will not be drawn unless the size of the rectange increase, ...
    (microsoft.public.dotnet.framework.drawing)

Loading