複製鏈接
請複製以下鏈接發送給好友

getaspectratio

鎖定
getaspectratio的功能是返回當前圖形模式的縱橫比。
外文名
getaspectratio
釋    義
函數名

目錄

getaspectratio基本信息

函數名: getaspectratio
用 法: void far getaspectratio(int far *xasp, int far *yasp);

getaspectratio例子

程序例:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int xasp, yasp, midx, midy;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
/* an error occurred */
if (errorcode != grOk)
{
printf("Graphics error: %s\n",
grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
/* terminate with an error code */
exit(1);
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor());
/* get current aspect ratio settings */
getaspectratio(&xasp, &yasp);
/* draw normal circle */
circle(midx, midy, 100);
getch();
/* draw wide circle */
cleardevice();
setaspectratio(xasp/2, yasp);
circle(midx, midy, 100);
getch();
/* draw narrow circle */
cleardevice();
setaspectratio(xasp, yasp/2);
circle(midx, midy, 100);
/* clean up */
getch();
closegraph();
return 0;
}