getaspectratio
raw OCR
Retrieves the current graphics mode's aspect ratio.
Defined in header <graphics.h>
Syntax
#include <graphics.h>
void far getaspectratio (int far *xasp, int far *yasp);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ |
Remarks
The y aspect factor, *yasp, is normaUzed to 10,000. On all graphics adapters except the VGA, *xasp (the x aspect factor) is less than *yasp because the pixels are taller than tKey are wide. On the VGA, which has "square" pixels, *xasp equals *yasp. In general, the relationship between *yasp and *xasp can be stated as
*yasp = 10,000 *xasp <= 10,000 getaspectratio gets the values in *xasp and *i/asp.
Return value
None.
See also
Example
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
mainO
{
/* request autodetection */
int gdriver = DETECT, gmode, errorcode;
int xasp, yasp, midx, midy;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult {);
if (errorcode != grOk) { /* an error occurred */
printf ("Graphics error: %s\n", grapherrormsg(errorcode)
printf ("Press any key to halt:");
getchO ;
exit(l); /* terminate with an error code */
)
midx = getmaxxO / 2;
midy = getmaxyO / 2;
setcolor(getmaxcolor 0);
/* get current aspect ratio settings */
getaspectratio (&xasp, &yasp);
/* draw normal circle */
circle(midx, midy, 100);
getchO ;
/* draw wide circle */
cleardeviceO ;
setaspectratio (xasp/2, yasp);
circle(midx, midy, 100);
getchO ;
/* draw narrow circle */
cleardeviceO ;
setaspectratio(xasp, yasp/2);
circle(midx, midy, 100);
/* clean up */
getchO ;
closegraph(
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/graphics.h/getaspectratio/
· short form /3.1/getaspectratio/