Pixel Conversion(3W) UNIX System V Pixel Conversion(3W)
NAME
PixelConversion - a group of routines which examine the data structures
that describe the physical dimensions and the pixel resolution of a
screen
SYNOPSIS
#include <Xlib.h>
#include <OpenLook.h>
Screen *OlDefaultScreen;
Display *OlDefaultDisplay;
Axis axis;
Screen screen;
OlMMToPixel(axis, millimeters);
OlMMToPixel(axis, millimeters);
OlPointToPixel(axis, points);
OlPointToPixel(axis, points);
OlScreenMMToPixel(axis, millimeters, screen);
OlScreenMMToPixel(axis, millimeters, screen);
OlScreenPointToPixel(axis, points, screen);
OlScreenPointToPixel(axis, points, screen);
OlPixelToMM(axis, pixels);
OlPixelToMM(axis, pixels);
OlPixelToPoint(axis, pixels);
OlPixelToPoint(axis, pixels);
OlScreenPixelToPoint(axis, pixels, screen);
OlScreenPixelToPoint(axis, pixels, screen);
OlScreenPixelToMM(axis, pixels, screen);
OlScreenPixelToMM(axis, pixels, screen);
DESCRIPTION
All the X-based OPEN LOOK widgets refer to pixels in coordinates and
dimensions for compatibility with other X Window System widgets.
However, this puts the burden on the application programmer to convert
between externally useful measures, such as points or millimeters, and
pixels as applied to the screen at hand. These routines examine the data
structures that describe the physical dimensions and the pixel resolution
of a screen and convert among millimeters, points, and pixels for that
screen.
Which Screen?
The shorter forms of these routines (the ones without the word Screen in
their names) work for the default screen. This is the screen that is
10/89 Page 1
Pixel Conversion(3W) UNIX System V Pixel Conversion(3W)
active when the X Toolkit Intrinsics are started. The longer forms of
these routines take a Screen * type argument that refers to a particular
screen.
The macros OlDefaultScreen and OlDefaultDisplay identify the current
screen and display being used by the Intrinsics. Although the SYNOPSIS
above implies these are variables of type Screen * and Display *,
respectively, they are really macros that produce values of these types.
Note: Use After Toolkit Initialization
These routines make use of data structures that are initialized when the
Toolkit is initialized (see OlInitialize later in this document).
Therefore, using them before Toolkit initilization (for example, as an
initial value to a statically defined variable) will result in a run time
error.
Axis Argument
The first argument of all the routines is the direction in which the
measurement is made. This is necessary because not all screens have
equivalent resolution in the horizontal and vertical axes. The axis
argument can take one of the two values: OLHORIZONTAL or OLVERTICAL.
These routines are not directly usable in computing a diagonal measure.
(Find the diagonal with the Pythagorean Theorem: a2 + b2 = c2)
Implemented as Macros
All these routines are implemented as macros, so they can take any
reasonable type value for the millimeters, points, and pixels. The
macros cast the values into the proper type needed for the conversion.
However, only a single type value can be "returned". The routines
without an underscore in their names produce values of type int (the
values are rounded to the nearest integer). The routines with an
underscore in their names produce values of type double (these values
have not been rounded, leaving it up to the application to round up,
round down, or truncate as needed). Given the small size of the units
involved, the integer returning routines should be sufficient for many
applications.
Because these routines are implemented as macros, there are no function
addresses available.
Page 2 10/89