13_f09_Transformations1 - .NET Graphics Units and...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
.NET Graphics Units and Transformations The Windows Clipboard Device Independent Drawing and Changing Coordinate System •Want to be able to control how the output of our programs looks on different devices –Printers and video devices use different units •Also want to be able to use different coordinate systems –Different units (inches, centimeters, device units) –Change direction of coordinate axes –Rotate, translate, scale what is displayed
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Video and Printer Coordinates •Device coordinates: x-axis to the right, y-axis down •Video uses pixel units –Resolution of most video display modes is about 100 dpi (dots per inch) •For printer, printer dot units, but under the GDI+ … –Coordinates passed to its Graphics drawing functions are interpreted as 0.01 inch units, regardless of printer •So for most applications we’ll get about the same results when we use the same coordinates to draw on a video Graphics object and a printer Graphics object Manual Coordinate System Conversions •Use the DpiX and DpiY properties of the Graphics object to adjust coordinates passed to drawing functions –Horizontal and vertical resolution of device in dots per inch •Example: want to use floating-point coordinates to draw in millimeter units –A helper function to convert a point from millimeters to dots (pixels or printer dots): PointF MMConv(Graphics g, PointF pointf) // returns a PointF object which is the conversion of pointf parameter to dots { pointf.X *= g.DpiX/25.4f; // divide by 25.4 mm/inch to convert to inches pointf.Y *= g.DpiY/25.4f; // and multiply by Dpi to convert to dots Return pointf; }
Background image of page 2
•Graphics class has two properties that do unit conversions (scalings) for us, so we don’t have to write our own function to do them: GraphicsUnit PageUnit // units used, an enumeration •Members –Display Same as device (pixels or printer dots) –Pixel –Point units of 1/72 inch –Inch
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 8

13_f09_Transformations1 - .NET Graphics Units and...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online