⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fi.htm

📁 turbo c
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<HTML><HEAD>   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">   <META NAME="Author" CONTENT="wdg">   <META NAME="GENERATOR" CONTENT="Mozilla/4.03 [en] (Win95; I) [Netscape]">   <TITLE>fi</TITLE></HEAD><BODY>&nbsp;<BR>&nbsp;<P>函数名: imagesize<BR>功&nbsp; 能: 返回保存位图像所需的字节数<BR>用&nbsp; 法: unsigned far imagesize(int left, int top, int right, intbottom);<BR>程序例:<P>#include &lt;graphics.h><BR>#include &lt;stdlib.h><BR>#include &lt;stdio.h><BR>#include &lt;conio.h><P>#define ARROW_SIZE 10<P>void draw_arrow(int x, int y);<P>int main(void)<BR>{<BR>&nbsp;&nbsp; /* request autodetection */<BR>&nbsp;&nbsp; int gdriver = DETECT, gmode, errorcode;<BR>&nbsp;&nbsp; void *arrow;<BR>&nbsp;&nbsp; int x, y, maxx;<BR>&nbsp;&nbsp; unsigned int size;<P>&nbsp;&nbsp; /* initialize graphics and local variables */<BR>&nbsp;&nbsp; initgraph(&amp;gdriver, &amp;gmode, "");<P>&nbsp;&nbsp; /* read result of initialization */<BR>&nbsp;&nbsp; errorcode = graphresult();<BR>&nbsp;&nbsp; if (errorcode != grOk)&nbsp; /* an error occurred */<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Graphics error: %s\n", grapherrormsg(errorcode));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Press any key to halt:");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1); /* terminate with an errorcode */<BR>&nbsp;&nbsp; }<P>&nbsp;&nbsp; maxx = getmaxx();<BR>&nbsp;&nbsp; x = 0;<BR>&nbsp;&nbsp; y = getmaxy() / 2;<P>&nbsp;&nbsp; /* draw the image to be grabbed */<BR>&nbsp;&nbsp; draw_arrow(x, y);<P>&nbsp;&nbsp; /* calculate the size of the image */<BR>&nbsp;&nbsp; size = imagesize(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE);<P>&nbsp;&nbsp; /* allocate memory to hold the image */<BR>&nbsp;&nbsp; arrow = malloc(size);<P>&nbsp;&nbsp; /* grab the image */<BR>&nbsp;&nbsp; getimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE,arrow);<P>&nbsp;&nbsp; /* repeat until a key is pressed */<BR>&nbsp;&nbsp; while (!kbhit())<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* erase old image */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; putimage(x, y-ARROW_SIZE, arrow, XOR_PUT);<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x += ARROW_SIZE;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (x >= maxx)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x = 0;<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* plot new image */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; putimage(x, y-ARROW_SIZE, arrow, XOR_PUT);<BR>&nbsp;&nbsp; }<P>&nbsp;&nbsp; /* clean up */<BR>&nbsp;&nbsp; free(arrow);<BR>&nbsp;&nbsp; closegraph();<BR>&nbsp;&nbsp; return 0;<BR>}<P>void draw_arrow(int x, int y)<BR>{<BR>&nbsp;&nbsp; /* draw an arrow on the screen */<BR>&nbsp;&nbsp; moveto(x, y);<BR>&nbsp;&nbsp; linerel(4*ARROW_SIZE, 0);<BR>&nbsp;&nbsp; linerel(-2*ARROW_SIZE, -1*ARROW_SIZE);<BR>&nbsp;&nbsp; linerel(0, 2*ARROW_SIZE);<BR>&nbsp;&nbsp; linerel(2*ARROW_SIZE, -1*ARROW_SIZE);<BR>}<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<P>函数名: initgraph<BR>功&nbsp; 能: 初始化图形系统<BR>用&nbsp; 法: void far initgraph(int far *graphdriver, int far *graphmode,<BR>&nbsp;&nbsp;&nbsp; char far *pathtodriver);<BR>程序例:<P>#include &lt;graphics.h><BR>#include &lt;stdlib.h><BR>#include &lt;stdio.h><BR>#include &lt;conio.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; /* request auto detection */<BR>&nbsp;&nbsp; int gdriver = DETECT, gmode, errorcode;<P>&nbsp;&nbsp; /* initialize graphics mode */<BR>&nbsp;&nbsp; initgraph(&amp;gdriver, &amp;gmode, "");<P>&nbsp;&nbsp; /* read result of initialization */<BR>&nbsp;&nbsp; errorcode = graphresult();<P>&nbsp;&nbsp; if (errorcode != grOk)&nbsp; /* an error occurred */<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Graphics error: %s\n", grapherrormsg(errorcode));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Press any key to halt:");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* return with error code */<BR>&nbsp;&nbsp; }<P>&nbsp;&nbsp; /* draw a line */<BR>&nbsp;&nbsp; line(0, 0, getmaxx(), getmaxy());<P>&nbsp;&nbsp; /* clean up */<BR>&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; closegraph();<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: inport<BR>功&nbsp; 能: 从硬件端口中输入<BR>用&nbsp; 法: int inp(int protid);<BR>程序例:<P>#include &lt;stdio.h><BR>#include &lt;dos.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; int result;<BR>&nbsp;&nbsp; int port = 0;&nbsp; /* serial port 0 */<P>&nbsp;&nbsp; result = inport(port);<BR>&nbsp;&nbsp; printf("Word read from port %d = 0x%X\n", port, result);<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<P>函数名: insline<BR>功&nbsp; 能: 在文本窗口中插入一个空行<BR>用&nbsp; 法: void insline(void);<BR>程序例:<P>#include &lt;conio.h><P>int main(void)<BR>{<BR>&nbsp;&nbsp; clrscr();<BR>&nbsp;&nbsp; cprintf("INSLINE inserts an empty line in the text window\r\n");<BR>&nbsp;&nbsp; cprintf("at the cursor position using the current text\r\n");<BR>&nbsp;&nbsp; cprintf("background color.&nbsp; All lines below the emptyone\r\n");<BR>&nbsp;&nbsp; cprintf("move down one line and the bottom line scrolls\r\n");<BR>&nbsp;&nbsp; cprintf("off the bottom of the window.\r\n");<BR>&nbsp;&nbsp; cprintf("\r\nPress any key to continue:");<BR>&nbsp;&nbsp; gotoxy(1, 3);<BR>&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; insline();<BR>&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; return 0;<BR>}<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<P>函数名: installuserdriver<BR>功&nbsp; 能: 安装设备驱动程序到BGI设备驱动程序表中<BR>用&nbsp; 法: int far installuserdriver(char far *name, int (*detect)(void));<BR>程序例:<P>#include &lt;graphics.h><BR>#include &lt;stdlib.h><BR>#include &lt;stdio.h><BR>#include &lt;conio.h><P>/* function prototypes */<BR>int huge detectEGA(void);<BR>void checkerrors(void);<P>int main(void)<BR>{<BR>&nbsp;&nbsp; int gdriver, gmode;<P>&nbsp;&nbsp; /* install a user written device driver */<BR>&nbsp;&nbsp; gdriver = installuserdriver("EGA", detectEGA);<P>&nbsp;&nbsp; /* must force use of detection routine */<BR>&nbsp;&nbsp; gdriver = DETECT;<P>&nbsp;&nbsp; /* check for any installation errors */<BR>&nbsp;&nbsp; checkerrors();<P>&nbsp;&nbsp; /* initialize graphics and local variables */<BR>&nbsp;&nbsp; initgraph(&amp;gdriver, &amp;gmode, "");<P>&nbsp;&nbsp; /* check for any initialization errors */<BR>&nbsp;&nbsp; checkerrors();<P>&nbsp;&nbsp; /* draw a line */<BR>&nbsp;&nbsp; line(0, 0, getmaxx(), getmaxy());<P>&nbsp;&nbsp; /* clean up */<BR>&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; closegraph();<BR>&nbsp;&nbsp; return 0;<BR>}<P>/* detects EGA or VGA cards */<BR>int huge detectEGA(void)<BR>{<BR>&nbsp;&nbsp; int driver, mode, sugmode = 0;<P>&nbsp;&nbsp; detectgraph(&amp;driver, &amp;mode);<BR>&nbsp;&nbsp; if ((driver == EGA) || (driver == VGA))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* return suggested video mode number*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return sugmode;<BR>&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* return an error code */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return grError;<BR>}<P>/* check for and report any graphics errors */<BR>void checkerrors(void)<BR>{<BR>&nbsp;&nbsp; int errorcode;<P>&nbsp;&nbsp; /* read result of last graphics operation */<BR>&nbsp;&nbsp; errorcode = graphresult();<BR>&nbsp;&nbsp; if (errorcode != grOk)<BR>&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Graphics error: %s\n", grapherrormsg(errorcode));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Press any key to halt:");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1);<BR>&nbsp;&nbsp; }<BR>}<P>函数名: installuserfont<BR>功&nbsp; 能: 安装未嵌入BGI系统的字体文件(CHR)<BR>用&nbsp; 法: int far installuserfont(char far *name);<BR>程序例:<P>#include &lt;graphics.h><BR>#include &lt;stdlib.h><BR>#include &lt;stdio.h><BR>#include &lt;conio.h><P>/* function prototype */<BR>void checkerrors(void);<P>int main(void)<BR>{<BR>&nbsp;&nbsp; /* request auto detection */<BR>&nbsp;&nbsp; int gdriver = DETECT, gmode;<BR>&nbsp;&nbsp; int userfont;<BR>&nbsp;&nbsp; int midx, midy;<P>&nbsp;&nbsp; /* initialize graphics and local variables */<BR>&nbsp;&nbsp; initgraph(&amp;gdriver, &amp;gmode, "");<P>&nbsp;&nbsp; midx = getmaxx() / 2;<BR>&nbsp;&nbsp; midy = getmaxy() / 2;<P>&nbsp;&nbsp; /* check for any initialization errors */<BR>&nbsp;&nbsp; checkerrors();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -