Reputation: 41
I want to know that System.Drawing.Rectangle has its width and height in pixels or not ? My printer paper width is more than the rectangle area width, still the paper does not accomodate the rectangle area. The printer paper width is in pixels, so I think If I can convert rectangle width to pixels than I can exactly find out that rectangle width is more than paper or not and can adjust rectangle according to that.
Upvotes: 1
Views: 7359
Reputation: 343
The website http://bytes.com/topic/c-sharp/answers/715228-system-drawing-size-unit has this to say about the unit of measurement used in system.drawing
Peter Duniho Gidi wrote: what is the unit of System.Drawing.Size?
when i'm writing Size = (1024,784), is it pixel? or something else? It depends on the context. For Control properties (Size, Bounds, ClientRectangle, etc), it's pixels. But for drawing, when the Size is passed to something operating on a Graphics object, the Size is interpreted according to the PageUnit property of that Graphics object. So it could be any of the units found in the GraphicsUnit enumeration except World, in that case.
Note of course also that a Graphics can have a transformation applied to it, so any drawing using a Size is also affected by that. If the PageUnit is Pixels, but you've got a 50% scaling factor applied, then any Size you pass to a Graphics object winds up being in half-pixels rather than whole pixels.
All the above is true for the Point struct too.
Secondly, you mentioned that you want to convert pixels. This website convert-me.com
has any unit you can imagine to convert to. The link I put will take you to the distance and length section where you can convert to and from pixels.
Upvotes: 4
Reputation: 15158
The Width and Height properties for System.Drawing.Rectangle
are both in pixels. Here is the documentation for Height and Width:
The default unit is pixels.
Upvotes: 3