?? fi.htm
字號:
<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>
<BR>
<P>函數名: imagesize
<BR>功 能: 返回保存位圖像所需的字節數
<BR>用 法: unsigned far imagesize(int left, int top, int right, int
bottom);
<BR>程序例:
<P>#include <graphics.h>
<BR>#include <stdlib.h>
<BR>#include <stdio.h>
<BR>#include <conio.h>
<P>#define ARROW_SIZE 10
<P>void draw_arrow(int x, int y);
<P>int main(void)
<BR>{
<BR> /* request autodetection */
<BR> int gdriver = DETECT, gmode, errorcode;
<BR> void *arrow;
<BR> int x, y, maxx;
<BR> unsigned int size;
<P> /* initialize graphics and local variables */
<BR> initgraph(&gdriver, &gmode, "");
<P> /* read result of initialization */
<BR> errorcode = graphresult();
<BR> if (errorcode != grOk) /* an error occurred */
<BR> {
<BR> printf("Graphics error: %s\n", grapherrormsg(errorcode));
<BR> printf("Press any key to halt:");
<BR> getch();
<BR> exit(1); /* terminate with an error
code */
<BR> }
<P> maxx = getmaxx();
<BR> x = 0;
<BR> y = getmaxy() / 2;
<P> /* draw the image to be grabbed */
<BR> draw_arrow(x, y);
<P> /* calculate the size of the image */
<BR> size = imagesize(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE);
<P> /* allocate memory to hold the image */
<BR> arrow = malloc(size);
<P> /* grab the image */
<BR> getimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE,
arrow);
<P> /* repeat until a key is pressed */
<BR> while (!kbhit())
<BR> {
<BR> /* erase old image */
<BR> putimage(x, y-ARROW_SIZE, arrow, XOR_PUT);
<P> x += ARROW_SIZE;
<BR> if (x >= maxx)
<BR> x = 0;
<P> /* plot new image */
<BR> putimage(x, y-ARROW_SIZE, arrow, XOR_PUT);
<BR> }
<P> /* clean up */
<BR> free(arrow);
<BR> closegraph();
<BR> return 0;
<BR>}
<P>void draw_arrow(int x, int y)
<BR>{
<BR> /* draw an arrow on the screen */
<BR> moveto(x, y);
<BR> linerel(4*ARROW_SIZE, 0);
<BR> linerel(-2*ARROW_SIZE, -1*ARROW_SIZE);
<BR> linerel(0, 2*ARROW_SIZE);
<BR> linerel(2*ARROW_SIZE, -1*ARROW_SIZE);
<BR>}
<BR>
<BR>
<BR>
<P>函數名: initgraph
<BR>功 能: 初始化圖形系統
<BR>用 法: void far initgraph(int far *graphdriver, int far *graphmode,
<BR> char far *pathtodriver);
<BR>程序例:
<P>#include <graphics.h>
<BR>#include <stdlib.h>
<BR>#include <stdio.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR> /* request auto detection */
<BR> int gdriver = DETECT, gmode, errorcode;
<P> /* initialize graphics mode */
<BR> initgraph(&gdriver, &gmode, "");
<P> /* read result of initialization */
<BR> errorcode = graphresult();
<P> if (errorcode != grOk) /* an error occurred */
<BR> {
<BR> printf("Graphics error: %s\n", grapherrormsg(errorcode));
<BR> printf("Press any key to halt:");
<BR> getch();
<BR> exit(1);
/* return with error code */
<BR> }
<P> /* draw a line */
<BR> line(0, 0, getmaxx(), getmaxy());
<P> /* clean up */
<BR> getch();
<BR> closegraph();
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數名: inport
<BR>功 能: 從硬件端口中輸入
<BR>用 法: int inp(int protid);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <dos.h>
<P>int main(void)
<BR>{
<BR> int result;
<BR> int port = 0; /* serial port 0 */
<P> result = inport(port);
<BR> printf("Word read from port %d = 0x%X\n", port, result);
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數名: insline
<BR>功 能: 在文本窗口中插入一個空行
<BR>用 法: void insline(void);
<BR>程序例:
<P>#include <conio.h>
<P>int main(void)
<BR>{
<BR> clrscr();
<BR> cprintf("INSLINE inserts an empty line in the text window\r\n");
<BR> cprintf("at the cursor position using the current text\r\n");
<BR> cprintf("background color. All lines below the empty
one\r\n");
<BR> cprintf("move down one line and the bottom line scrolls\r\n");
<BR> cprintf("off the bottom of the window.\r\n");
<BR> cprintf("\r\nPress any key to continue:");
<BR> gotoxy(1, 3);
<BR> getch();
<BR> insline();
<BR> getch();
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數名: installuserdriver
<BR>功 能: 安裝設備驅動程序到BGI設備驅動程序表中
<BR>用 法: int far installuserdriver(char far *name, int (*detect)(void));
<BR>程序例:
<P>#include <graphics.h>
<BR>#include <stdlib.h>
<BR>#include <stdio.h>
<BR>#include <conio.h>
<P>/* function prototypes */
<BR>int huge detectEGA(void);
<BR>void checkerrors(void);
<P>int main(void)
<BR>{
<BR> int gdriver, gmode;
<P> /* install a user written device driver */
<BR> gdriver = installuserdriver("EGA", detectEGA);
<P> /* must force use of detection routine */
<BR> gdriver = DETECT;
<P> /* check for any installation errors */
<BR> checkerrors();
<P> /* initialize graphics and local variables */
<BR> initgraph(&gdriver, &gmode, "");
<P> /* check for any initialization errors */
<BR> checkerrors();
<P> /* draw a line */
<BR> line(0, 0, getmaxx(), getmaxy());
<P> /* clean up */
<BR> getch();
<BR> closegraph();
<BR> return 0;
<BR>}
<P>/* detects EGA or VGA cards */
<BR>int huge detectEGA(void)
<BR>{
<BR> int driver, mode, sugmode = 0;
<P> detectgraph(&driver, &mode);
<BR> if ((driver == EGA) || (driver == VGA))
<BR> /* return suggested video mode number
*/
<BR> return sugmode;
<BR> else
<BR> /* return an error code */
<BR> return grError;
<BR>}
<P>/* check for and report any graphics errors */
<BR>void checkerrors(void)
<BR>{
<BR> int errorcode;
<P> /* read result of last graphics operation */
<BR> errorcode = graphresult();
<BR> if (errorcode != grOk)
<BR> {
<BR> printf("Graphics error: %s\n", grapherrormsg(errorcode));
<BR> printf("Press any key to halt:");
<BR> getch();
<BR> exit(1);
<BR> }
<BR>}
<P>函數名: installuserfont
<BR>功 能: 安裝未嵌入BGI系統的字體文件(CHR)
<BR>用 法: int far installuserfont(char far *name);
<BR>程序例:
<P>#include <graphics.h>
<BR>#include <stdlib.h>
<BR>#include <stdio.h>
<BR>#include <conio.h>
<P>/* function prototype */
<BR>void checkerrors(void);
<P>int main(void)
<BR>{
<BR> /* request auto detection */
<BR> int gdriver = DETECT, gmode;
<BR> int userfont;
<BR> int midx, midy;
<P> /* initialize graphics and local variables */
<BR> initgraph(&gdriver, &gmode, "");
<P> midx = getmaxx() / 2;
<BR> midy = getmaxy() / 2;
<P> /* check for any initialization errors */
<BR> checkerrors();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -