📄 fg.htm
字号:
<BR>用 法: void far getfillsettings(struct fillsettingstype far *fillinfo);<BR>程序例:<P>#include <graphics.h><BR>#include <stdlib.h><BR>#include <stdio.h><BR>#include <conio.h><P>/ the names of the fill styles supported */<BR>char *fname[] = { "EMPTY_FILL",<BR> "SOLID_FILL",<BR> "LINE_FILL",<BR> "LTSLASH_FILL",<BR> "SLASH_FILL",<BR> "BKSLASH_FILL",<BR> "LTBKSLASH_FILL",<BR> "HATCH_FILL",<BR> "XHATCH_FILL",<BR> "INTERLEAVE_FILL",<BR> "WIDE_DOT_FILL",<BR> "CLOSE_DOT_FILL",<BR> "USER_FILL"<BR> };<P>int main(void)<BR>{<BR> /* request auto detection */<BR> int gdriver = DETECT, gmode, errorcode;<BR> struct fillsettingstype fillinfo;<BR> int midx, midy;<BR> char patstr[40], colstr[40];<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 errorcode */<BR> }<P> midx = getmaxx() / 2;<BR> midy = getmaxy() / 2;<P> /* get information about current fill pattern and color*/<BR> getfillsettings(&fillinfo);<P> /* convert fill information into strings */<BR> sprintf(patstr, "%s is the fill style.", fname[fillinfo.pattern]);<BR> sprintf(colstr, "%d is the fill color.", fillinfo.color);<P> /* display the information */<BR> settextjustify(CENTER_TEXT, CENTER_TEXT);<BR> outtextxy(midx, midy, patstr);<BR> outtextxy(midx, midy+2*textheight("W"), colstr);<P> /* clean up */<BR> getch();<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <BR> <P>函数名: getftime<BR>功 能: 取文件日期和时间<BR>用 法: int getftime(int handle, struct ftime *ftimep);<BR>程序例:<P>#include <stdio.h><BR>#include <io.h><P>int main(void)<BR>{<BR> FILE *stream;<BR> struct ftime ft;<P> if ((stream = fopen("TEST.$$$",<BR> "wt")) == NULL)<BR> {<BR> fprintf(stderr,<BR> "Cannot open output file.\n");<BR> return 1;<BR> }<BR> getftime(fileno(stream), &ft);<BR> printf("File time: %u:%u:%u\n",<BR> ft.ft_hour,ft.ft_min,<BR> ft.ft_tsec *2);<BR> printf("File date: %u/%u/%u\n",<BR> ft.ft_month, ft.ft_day,<BR> ft.ft_year+1980);<BR> fclose(stream);<BR> return 0;<BR>}<BR> <BR> <BR> <P>函数名: getgraphmode<BR>功 能: 返回当前图形模式<BR>用 法: int far getgraphmode(void);<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;<BR> int midx, midy, mode;<BR> char numname[80], modename[80];<P>/* initialize graphics and local variables */<BR> initgraph(&gdriver, &gmode, "");<P>/* read result of initialization */<BR> errorcode = graphresult();<BR>/* an error occurred */<BR> if (errorcode != grOk)<BR> {<BR> printf("Graphics error: %s\n",<BR> grapherrormsg(errorcode));<BR> printf("Press any key to halt:");<BR> getch();<BR>/* terminate with an error code */<BR> exit(1);<BR> }<P> midx = getmaxx() / 2;<BR> midy = getmaxy() / 2;<P>/* get mode number and name strings */<BR> mode = getgraphmode();<BR> sprintf(numname,<BR> "%d isthe current mode number.",<BR> mode);<BR> sprintf(modename,<BR> "%s isthe current graphics mode",<BR> getmodename(mode));<P>/* display the information */<BR> settextjustify(CENTER_TEXT, CENTER_TEXT);<BR> outtextxy(midx, midy, numname);<BR> outtextxy(midx, midy+2*textheight("W"),<BR> modename);<P>/* clean up */<BR> getch();<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <P>函数名: getftime<BR>功 能: 取文件日期和时间<BR>用 法: int getftime(int handle, struct ftime *ftimep);<BR>程序例:<P>#include <stdio.h><BR>#include <io.h><P>int main(void)<BR>{<BR> FILE *stream;<BR> struct ftime ft;<P> if ((stream = fopen("TEST.$$$",<BR> "wt")) == NULL)<BR> {<BR> fprintf(stderr,<BR> "Cannot open output file.\n");<BR> return 1;<BR> }<BR> getftime(fileno(stream), &ft);<BR> printf("File time: %u:%u:%u\n",<BR> ft.ft_hour,ft.ft_min,<BR> ft.ft_tsec *2);<BR> printf("File date: %u/%u/%u\n",<BR> ft.ft_month, ft.ft_day,<BR> ft.ft_year+1980);<BR> fclose(stream);<BR> return 0;<BR>}<BR> <BR> <BR> <P>函数名: getgraphmode<BR>功 能: 返回当前图形模式<BR>用 法: int far getgraphmode(void);<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;<BR> int midx, midy, mode;<BR> char numname[80], modename[80];<P>/* initialize graphics and local variables */<BR> initgraph(&gdriver, &gmode, "");<P>/* read result of initialization */<BR> errorcode = graphresult();<BR>/* an error occurred */<BR> if (errorcode != grOk)<BR> {<BR> printf("Graphics error: %s\n",<BR> grapherrormsg(errorcode));<BR> printf("Press any key to halt:");<BR> getch();<BR>/* terminate with an error code */<BR> exit(1);<BR> }<P> midx = getmaxx() / 2;<BR> midy = getmaxy() / 2;<P>/* get mode number and name strings */<BR> mode = getgraphmode();<BR> sprintf(numname,<BR> "%d isthe current mode number.",<BR> mode);<BR> sprintf(modename,<BR> "%s isthe current graphics mode",<BR> getmodename(mode));<P>/* display the information */<BR> settextjustify(CENTER_TEXT, CENTER_TEXT);<BR> outtextxy(midx, midy, numname);<BR> outtextxy(midx, midy+2*textheight("W"),<BR> modename);<P>/* clean up */<BR> getch();<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <P>函数名: getimage<BR>功 能: 将指定区域的一个位图存到主存中<BR>用 法: void far getimage(int left, int top, int right, int bottom,<BR> void far *bitmap);<BR>程序例:<P>#include <graphics.h><BR>#include <stdlib.h><BR>#include <stdio.h><BR>#include <conio.h><BR>#include <alloc.h><P>void save_screen(void far *buf[4]);<BR>void restore_screen(void far *buf[4]);<P>int maxx, maxy;<P>int main(void)<BR>{<BR> int gdriver=DETECT, gmode, errorcode;<BR> void far *ptr[4];<P> /* auto-detect the graphics driver and mode */<BR> initgraph(&gdriver, &gmode, "");<BR> errorcode = graphresult(); /* check for any errors */<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> maxx = getmaxx();<BR> maxy = getmaxy();<P> /* draw an image on the screen */<BR> rectangle(0, 0, maxx, maxy);<BR> line(0, 0, maxx, maxy);<BR> line(0, maxy, maxx, 0);<P> save_screen(ptr); /* save the currentscreen */<BR> getch(); /* pause screen */<BR> cleardevice(); /*clear screen */<BR> restore_screen(ptr); /* restore the screen */<BR> getch(); /* pause screen */<P> closegraph();<BR> return 0;<BR>}<P>void save_screen(void far *buf[4])<BR>{<BR> unsigned size;<BR> int ystart=0, yend, yincr, block;<P> yincr = (maxy+1) / 4;<BR> yend = yincr;<BR> size = imagesize(0, ystart, maxx, yend); /* get byte sizeof image */<P> for (block=0; block<=3; block++)<BR> {<BR> if ((buf[block] = farmalloc(size)) ==NULL)<BR> {<BR> closegraph();<BR> printf("Error: notenough heap space in save_screen().\n");<BR> exit(1);<BR> }<P> getimage(0, ystart, maxx, yend, buf[block]);<BR> ystart = yend + 1;<BR> yend += yincr + 1;<BR> }<BR>}<P>void save_screen(void far *buf[4])<BR>{<BR> unsigned size;<BR> int ystart=0, yend, yincr, block;<P> yincr = (maxy+1) / 4;<BR> yend = yincr;<BR> size = imagesize(0, ystart, maxx, yend); /* get byte sizeof image */<P> for (block=0; block<=3; block++)<BR> {<BR> if ((buf[block] = farmalloc(size)) ==NULL)<BR> {<BR> closegraph();<BR> printf("Error: notenough heap space in save_screen().\n");<BR> exit(1);<BR> }<P> getimage(0, ystart, maxx, yend, buf[block]);<BR> ystart = yend + 1;<BR> yend += yincr + 1;<BR> }<BR>}<P>void restore_screen(void far *buf[4])<BR>{<BR> int ystart=0, yend, yincr, block;<P> yincr = (maxy+1) / 4;<BR> yend = yincr;<P> for (block=0; block<=3; block++)<BR> {<BR> putimage(0, ystart, buf[block], COPY_PUT);<BR> farfree(buf[block]);<BR> ystart = yend + 1;<BR> yend += yincr + 1;<BR> }<BR>}<BR> <BR> <P>函数名: getlinesettings<BR>功 能: 取当前线型、模式和宽度<BR>用 法: void far getlinesettings(struct linesettingstype far *lininfo):<BR>程序例:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -