MGL_getAspectRatio
Returns the current device context aspect ratio.
Declaration
int MGLAPI MGL_getAspectRatio(void)
Prototype In
mgraph.h
Return Value
Current video mode aspect ratio * 1000.
Description
This function returns the aspect ratio of the currently active output device's physical pixels. This ratio is equal to:
pixel x size
------------ x 1000
pixel y size
The device context aspect ratio can be used to display circles and squares on the device by approximating them with ellipses and rectangles of the appropriate dimensions. Thus in order to determine the number of pixels in the y direction for a square with 100 pixels in the x direction, we can simply use the code:
y_pixels = ((long)x_pixels * 1000) / aspectratio
Note the cast to a long to avoid arithmetic overflow, as the aspect ratio is returned as an integer value with 1000 being a 1:1 aspect ratio.
See Also
Copyright © 2002 SciTech Software, Inc. Visit our web site at http://www.scitechsoft.com