是TC的針對DOS下的一個C語言圖形庫,如果要用的話應該用TC的編譯器來編譯,VC++環境有其它的針對windows的圖形庫。分為:像素函式、直線和線型函式、多邊形函式、填充函式等。如果您需要在vc及vs環境中使用graphics.h的功能 您可以下載EasyX圖形庫(注意:這是一個C++的圖形庫 如果您一定要在C語言環境下使用 graphics.h 您可以使用windows gdi)
基本介紹
- 中文名:graphics.h
- 外文名:graphics.h
- getaspectr:獲取縱橫比函式
- 優點:是一個簡單 高效的繪圖函式館
像素函式
線型函式
多邊形函式
曲線函式
填充函式
圖像函式
像素函式
畫像素點函式
返回像素函式
線型函式
畫線函式
相對畫線函式
設定線型函式
名稱 | 取值 | 含義 |
SOLID_LINE | 0 | 實線 |
DOTTED_LINE | 1 | 點線 |
CENTER_LINE | 2 | 中心線 |
DASHED_LINE | 3 | 虛線 |
USERBIT_LINE | 4 | 用戶自定義線型 |
名 稱 | 取 值 | 說 明 |
NORM_WIDTH(常寬) | 1 | 一個像素寬(預設值) |
THICK_WIDTH(加寬) | 3 | 三個像素寬 |
獲取線型設定
設定畫線模式
多邊形
畫矩形函式
畫條函式
畫條塊函式
多邊形函式
曲線函式
縱橫比函式
畫圓函式
畫圓弧函式
檔案內容
/*graphics.hDefinitionsforGraphicsPackage.Copyright(c)BorlandInternational1987,1988AllRightsReserved.*/#if__STDC__#define_Cdecl#else#define_Cdeclcdecl#endif#if!defined(__GRAPHX_DEF_)#define__GRAPHX_DEF_enumgraphics_errors{/*graphresulterrorreturncodes*/grOk=0,grNoInitGraph=-1,grNotDetected=-2,grFileNotFound=-3,grInvalidDriver=-4,grNoLoadMem=-5,grNoScanMem=-6,grNoFloodMem=-7,grFontNotFound=-8,grNoFontMem=-9,grInvalidMode=-10,grError=-11,/*genericerror*/grIOerror=-12,grInvalidFont=-13,grInvalidFontNum=-14,grInvalidVersion=-18};enumgraphics_drivers{/*definegraphicsdrivers*/DETECT,/*requestsautodetection*/CGA,MCGA,EGA,EGA64,EGAMONO,IBM8514,/*1-6*/HERCMONO,ATT400,VGA,PC3270,/*7-10*/CURRENT_DRIVER=-1};enumgraphics_modes{/*graphicsmodesforeachdriver*/CGAC0=0,/*320x200palette0;1page*/CGAC1=1,/*320x200palette1;1page*/CGAC2=2,/*320x200palette2:1page*/CGAC3=3,/*320x200palette3;1page*/CGAHI=4,/*640x2001page*/MCGAC0=0,/*320x200palette0;1page*/MCGAC1=1,/*320x200palette1;1page*/MCGAC2=2,/*320x200palette2;1page*/MCGAC3=3,/*320x200palette3;1page*/MCGAMED=4,/*640x2001page*/MCGAHI=5,/*640x4801page*/EGALO=0,/*640x20016color4pages*/EGAHI=1,/*640x35016color2pages*/EGA64LO=0,/*640x20016color1page*/EGA64HI=1,/*640x3504color1page*/EGAMONOHI=0,/*640x35064Koncard,1page-256Koncard,4pages*/HERCMONOHI=0,/*720x3482pages*/ATT400C0=0,/*320x200palette0;1page*/ATT400C1=1,/*320x200palette1;1page*/ATT400C2=2,/*320x200palette2;1page*/ATT400C3=3,/*320x200palette3;1page*/ATT400MED=4,/*640x2001page*/ATT400HI=5,/*640x4001page*/VGALO=0,/*640x20016color4pages*/VGAMED=1,/*640x35016color2pages*/VGAHI=2,/*640x48016color1page*/PC3270HI=0,/*720x3501page*/IBM8514LO=0,/*640x480256colors*/IBM8514HI=1/*1024x768256colors*/};/*Colorsforsetpaletteandsetallpalette*/#if!defined(__COLORS)#define__COLORSenumCOLORS{BLACK,/*darkcolors*/BLUE,GREEN,CYAN,RED,MAGENTA,BROWN,LIGHTGRAY,DARKGRAY,/*lightcolors*/LIGHTBLUE,LIGHTGREEN,LIGHTCYAN,LIGHTRED,LIGHTMAGENTA,YELLOW,WHITE};#endifenumCGA_COLORS{CGA_LIGHTGREEN=1,/*PaletteC0ColorNames*/CGA_LIGHTRED=2,CGA_YELLOW=3,CGA_LIGHTCYAN=1,/*PaletteC1ColorNames*/CGA_LIGHTMAGENTA=2,CGA_WHITE=3,CGA_GREEN=1,/*PaletteC2ColorNames*/CGA_RED=2,CGA_BROWN=3,CGA_CYAN=1,/*PaletteC3ColorNames*/CGA_MAGENTA=2,CGA_LIGHTGRAY=3};enumEGA_COLORS{EGA_BLACK=0,/*darkcolors*/EGA_BLUE=1,EGA_GREEN=2,EGA_CYAN=3,EGA_RED=4,EGA_MAGENTA=5,EGA_BROWN=20,EGA_LIGHTGRAY=7,EGA_DARKGRAY=56,/*lightcolors*/EGA_LIGHTBLUE=57,EGA_LIGHTGREEN=58,EGA_LIGHTCYAN=59,EGA_LIGHTRED=60,EGA_LIGHTMAGENTA=61,EGA_YELLOW=62,EGA_WHITE=63};enumline_styles{/*Linestylesforget/setlinestyle*/SOLID_LINE=0,DOTTED_LINE=1,CENTER_LINE=2,DASHED_LINE=3,USERBIT_LINE=4,/*Userdefinedlinestyle*/};enumline_widths{/*Linewidthsforget/setlinestyle*/NORM_WIDTH=1,THICK_WIDTH=3,};enumfont_names{DEFAULT_FONT=0,/*8x8bitmappedfont*/TRIPLEX_FONT=1,/*"Stroked"fonts*/SMALL_FONT=2,SANS_SERIF_FONT=3,GOTHIC_FONT=4};#defineHORIZ_DIR0/*lefttoright*/#defineVERT_DIR1/*bottomtotop*/#defineUSER_CHAR_SIZE0/*user-definedcharsize*/enumfill_patterns{/*Fillpatternsforget/setfillstyle*/EMPTY_FILL,/*fillsareainbackgroundcolor*/SOLID_FILL,/*fillsareainsolidfillcolor*/LINE_FILL,/*---fill*/LTSLASH_FILL,/*///fill*/SLASH_FILL,/*///fillwiththicklines*/BKSLASH_FILL,/*\\\fillwiththicklines*/LTBKSLASH_FILL,/*\\\fill*/HATCH_FILL,/*lighthatchfill*/XHATCH_FILL,/*heavycrosshatchfill*/INTERLEAVE_FILL,/*interleavinglinefill*/WIDE_DOT_FILL,/*Widelyspaceddotfill*/CLOSE_DOT_FILL,/*Closelyspaceddotfill*/USER_FILL/*userdefinedfill*/};enumputimage_ops{/*BitBltoperatorsforputimage*/COPY_PUT,/*MOV*/XOR_PUT,/*XOR*/OR_PUT,/*OR*/AND_PUT,/*AND*/NOT_PUT/*NOT*/};enumtext_just{/*Horizontalandverticaljustificationforsettextjustify*/LEFT_TEXT=0,CENTER_TEXT=1,RIGHT_TEXT=2,BOTTOM_TEXT=0,/*CENTER_TEXT=1,alreadydefinedabove*/TOP_TEXT=2};#defineMAXCOLORS15structpalettetype{unsignedcharsize;signedcharcolors[MAXCOLORS+1];};structlinesettingstype{intlinestyle;unsignedupattern;intthickness;};structtextsettingstype{intfont;intdirection;intcharsize;inthoriz;intvert;};structfillsettingstype{intpattern;intcolor;};structpointtype{intx,y;};structviewporttype{intleft,top,right,bottom;intclip;};structarccoordstype{intx,y;intxstart,ystart,xend,yend;};voidfar_Cdeclarc(intx,inty,intstangle,intendangle,intradius);voidfar_Cdeclbar(intleft,inttop,intright,intbottom);voidfar_Cdeclbar3d(intleft,inttop,intright,intbottom,intdepth,inttopflag);voidfar_Cdeclcircle(intx,inty,intradius);voidfar_Cdeclcleardevice(void);voidfar_Cdeclclearviewport(void);voidfar_Cdeclclosegraph(void);voidfar_Cdecldetectgraph(intfar*graphdriver,intfar*graphmode);voidfar_Cdecldrawpoly(intnumpoints,intfar*polypoints);voidfar_Cdeclellipse(intx,inty,intstangle,intendangle,intxradius,intyradius);voidfar_Cdeclfillellipse(intx,inty,intxradius,intyradius);voidfar_Cdeclfillpoly(intnumpoints,intfar*polypoints);voidfar_Cdeclfloodfill(intx,inty,intborder);voidfar_Cdeclgetarccoords(structarccoordstypefar*arccoords);voidfar_Cdeclgetaspectratio(intfar*xasp,intfar*yasp);intfar_Cdeclgetbkcolor(void);intfar_Cdeclgetcolor(void);structpalettetype*far_Cdeclgetdefaultpalette(void);char*far_Cdeclgetdrivername(void);voidfar_Cdeclgetfillpattern(charfar*pattern);voidfar_Cdeclgetfillsettings(structfillsettingstypefar*fillinfo);intfar_Cdeclgetgraphmode(void);voidfar_Cdeclgetimage(intleft,inttop,intright,intbottom,voidfar*bitmap);voidfar_Cdeclgetlinesettings(structlinesettingstypefar*lineinfo);intfar_Cdeclgetmaxcolor(void);intfar_Cdeclgetmaxmode(void);intfar_Cdeclgetmaxx(void);intfar_Cdeclgetmaxy(void);char*far_Cdeclgetmodename(intmode_number);voidfar_Cdeclgetmoderange(intgraphdriver,intfar*lomode,intfar*himode);unsignedfar_Cdeclgetpixel(intx,inty);voidfar_Cdeclgetpalette(structpalettetypefar*palette);intfar_Cdeclgetpalettesize(void);voidfar_Cdeclgettextsettings(structtextsettingstypefar*texttypeinfo);voidfar_Cdeclgetviewsettings(structviewporttypefar*viewport);intfar_Cdeclgetx(void);intfar_Cdeclgety(void);voidfar_Cdeclgraphdefaults(void);char*far_Cdeclgrapherrormsg(interrorcode);voidfar_Cdecl_graphfreemem(voidfar*ptr,unsignedsize);voidfar*far_Cdecl_graphgetmem(unsignedsize);intfar_Cdeclgraphresult(void);unsignedfar_Cdeclimagesize(intleft,inttop,intright,intbottom);voidfar_Cdeclinitgraph(intfar*graphdriver,intfar*graphmode,charfar*pathtodriver);intfar_Cdeclinstalluserdriver(charfar*name,inthuge(*detect)(void));intfar_Cdeclinstalluserfont(charfar*name);voidfar_Cdeclline(intx1,inty1,intx2,inty2);voidfar_Cdecllinerel(intdx,intdy);voidfar_Cdecllineto(intx,inty);voidfar_Cdeclmoverel(intdx,intdy);voidfar_Cdeclmoveto(intx,inty);voidfar_Cdeclouttext(charfar*textstring);voidfar_Cdeclouttextxy(intx,inty,charfar*textstring);voidfar_Cdeclpieslice(intx,inty,intstangle,intendangle,intradius);voidfar_Cdeclputimage(intleft,inttop,voidfar*bitmap,intop);voidfar_Cdeclputpixel(intx,inty,intcolor);voidfar_Cdeclrectangle(intleft,inttop,intright,intbottom);voidfar_Cdeclrestorecrtmode(void);voidfar_Cdeclsector(intX,intY,intStAngle,intEndAngle,intXRadius,intYRadius);voidfar_Cdeclsetactivepage(intpage);voidfar_Cdeclsetallpalette(structpalettetypefar*palette);voidfar_Cdeclsetaspectratio(intxasp,intyasp);voidfar_Cdeclsetbkcolor(intcolor);voidfar_Cdeclsetcolor(intcolor);voidfar_Cdeclsetfillpattern(charfar*upattern,intcolor);voidfar_Cdeclsetfillstyle(intpattern,intcolor);unsignedfar_Cdeclsetgraphbufsize(unsignedbufsize);voidfar_Cdeclsetgraphmode(intmode);voidfar_Cdeclsetlinestyle(intlinestyle,unsignedupattern,intthickness);voidfar_Cdeclsetpalette(intcolornum,intcolor);voidfar_Cdeclsetrgbpalette(intcolornum,intred,intgreen,intblue);voidfar_Cdeclsettextjustify(inthoriz,intvert);voidfar_Cdeclsettextstyle(intfont,intdirection,intcharsize);voidfar_Cdeclsetusercharsize(intmultx,intdivx,intmulty,intdivy);voidfar_Cdeclsetviewport(intleft,inttop,intright,intbottom,intclip);voidfar_Cdeclsetvisualpage(intpage);voidfar_Cdeclsetwritemode(intmode);intfar_Cdecltextheight(charfar*textstring);intfar_Cdecltextwidth(charfar*textstring);/*****graphicsdrivers*****/int_Cdeclregisterbgidriver(void(*driver)(void));intfar_Cdeclregisterfarbgidriver(voidfar*driver);/*!!These"functions"areNOTuser-callable!!*//*!!Theyaretherejustsoyoucanlinkingraphicsdrivers!!*/void_CdeclCGA_driver(void);void_CdeclEGAVGA_driver(void);void_CdeclIBM8514_driver(void);void_CdeclHerc_driver(void);void_CdeclATT_driver(void);void_CdeclPC3270_driver(void);externintfar_CdeclCGA_driver_far[];externintfar_CdeclEGAVGA_driver_far[];externintfar_CdeclIBM8514_driver_far[];externintfar_CdeclHerc_driver_far[];externintfar_CdeclATT_driver_far[];externintfar_CdeclPC3270_driver_far[];/*****graphicsfonts*****/int_Cdeclregisterbgifont(void(*font)(void));intfar_Cdeclregisterfarbgifont(voidfar*font);/*!!These"functions"areNOTuser-callable,!!*//*!!theyaretherejustsoyoucanlinkinfonts!!*/void_Cdecltriplex_font(void);void_Cdeclsmall_font(void);void_Cdeclsansserif_font(void);void_Cdeclgothic_font(void);externintfar_Cdecltriplex_font_far[];externintfar_Cdeclsmall_font_far[];externintfar_Cdeclsansserif_font_far[];externintfar_Cdeclgothic_font_far[];#endif