📄 fi.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=gb_2312-80">
<meta name="Author" content="wdg">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>网上学堂 --> C语言编程宝典之一 -->函数名: i</title>
</head>
<body>
<div align="center"><center>
<table border="1" cellpadding="4" width="640"
bordercolordark="#FFFFFF" bordercolorlight="#FFFFFF">
<tr>
<td bgcolor="#FFE6B0" bordercolor="#8080FF" class="p9"><font
color="#BB0000">导航条:--></font> <a
href="../../index.html">网上学堂</a> --> <a
href="../tcindex.htm"><font face="宋体">C</font>语言编程宝典之一</a>
-->函数名: i</td>
</tr>
<tr>
<td bordercolor="#8080FF" class="p9">函数名: 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>
<p>#define ARROW_SIZE 10 </p>
<p>void draw_arrow(int x, int y); </p>
<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>
<p> /* initialize graphics and local
variables */ <br>
initgraph(&gdriver, &gmode,
""); </p>
<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>
<p> maxx = getmaxx(); <br>
x = 0; <br>
y = getmaxy() / 2; </p>
<p> /* draw the image to be grabbed */ <br>
draw_arrow(x, y); </p>
<p> /* calculate the size of the image */ <br>
size = imagesize(x, y-ARROW_SIZE,
x+(4*ARROW_SIZE), y+ARROW_SIZE); </p>
<p> /* allocate memory to hold the image */ <br>
arrow = malloc(size); </p>
<p> /* grab the image */ <br>
getimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE),
y+ARROW_SIZE, arrow); </p>
<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>
<p> x += ARROW_SIZE; <br>
if (x >= maxx) <br>
x
= 0; </p>
<p> /* plot new image */ <br>
putimage(x, y-ARROW_SIZE,
arrow, XOR_PUT); <br>
} </p>
<p> /* clean up */ <br>
free(arrow); <br>
closegraph(); <br>
return 0; <br>
} </p>
<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>
<p>函数名: initgraph <br>
功 能: 初始化图形系统 <br>
用 法: void far initgraph(int far *graphdriver,
int far *graphmode, <br>
char far *pathtodriver); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; </p>
<p> /* initialize graphics mode */ <br>
initgraph(&gdriver, &gmode,
""); </p>
<p> /* read result of initialization */ <br>
errorcode = graphresult(); </p>
<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>
<p> /* draw a line */ <br>
line(0, 0, getmaxx(), getmaxy()); </p>
<p> /* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: inport <br>
功 能: 从硬件端口中输入 <br>
用 法: int inp(int protid); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <dos.h> </p>
<p>int main(void) <br>
{ <br>
int result; <br>
int port = 0; /* serial port 0 */ </p>
<p> result = inport(port); <br>
printf("Word read from port %d =
0x%X\n", port, result); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: insline <br>
功 能: 在文本窗口中插入一个空行 <br>
用 法: void insline(void); <br>
程序例: </p>
<p>#include <conio.h> </p>
<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>
<p>函数名: installuserdriver <br>
功 能: 安装设备驱动程序到BGI设备驱动程序表中
<br>
用 法: int far installuserdriver(char far *name,
int (*detect)(void)); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>/* function prototypes */ <br>
int huge detectEGA(void); <br>
void checkerrors(void); </p>
<p>int main(void) <br>
{ <br>
int gdriver, gmode; </p>
<p> /* install a user written device driver
*/ <br>
gdriver = installuserdriver("EGA",
detectEGA); </p>
<p> /* must force use of detection routine */
<br>
gdriver = DETECT; </p>
<p> /* check for any installation errors */ <br>
checkerrors(); </p>
<p> /* initialize graphics and local
variables */ <br>
initgraph(&gdriver, &gmode,
""); </p>
<p> /* check for any initialization errors */
<br>
checkerrors(); </p>
<p> /* draw a line */ <br>
line(0, 0, getmaxx(), getmaxy()); </p>
<p> /* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} </p>
<p>/* detects EGA or VGA cards */ <br>
int huge detectEGA(void) <br>
{ <br>
int driver, mode, sugmode = 0; </p>
<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>
<p>/* check for and report any graphics errors */ <br>
void checkerrors(void) <br>
{ <br>
int errorcode; </p>
<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>
<p>函数名: installuserfont <br>
功 能: 安装未嵌入BGI系统的字体文件(CHR)
<br>
用 法: int far installuserfont(char far *name); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>/* function prototype */ <br>
void checkerrors(void); </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode; <br>
int userfont; <br>
int midx, midy; </p>
<p> /* initialize graphics and local
variables */ <br>
initgraph(&gdriver, &gmode,
""); </p>
<p> midx = getmaxx() / 2; <br>
midy = getmaxy() / 2; </p>
<p> /* check for any initialization errors */
<br>
checkerrors(); </p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -