一、图形操作基本简介 1. 必要的头文件 #include #include #include #include #include 2. 必须的系统变量 int GraphDriver; int GraphMode; double AspectRatio; int MaxX, MaxY; int MaxColors; int ErrorCode; struct palettetype palette; 3. 初始化图形界面初始化出错处理关闭图形界面 GraphDriver = DETECT; initgraph( &GraphDriver, &GraphMode, " " ); initgraph( &GraphDriver, &GraphMode, “d:\\tc" ); ErrorCode = graphresult(); if( ErrorCode != grOk ){ printf(" Graphics System Error: %s\n", grapherrormsg( ErrorCode ) ); exit( 1 ); } closegraph(); /* Return the system to text mode */ 4. 取得必须的信息 getpalette( &palette ); MaxColors = getmaxcolor() + 1; MaxX = getmaxx(); MaxY = getmaxy(); AspectRatio = (double)xasp / (double)yasp; 5. 一些常用的画图函数 outtext( buffer ),outtextxy(x,y,buffer) line(x0,y0,x1,y1);linerel( );lineto( ) circle(int x, int y, int radius); arc( ) bar(int l, int t, int r, int b);bar3d( ); moveto(int x, int y);moverel(dx,dy);getx( ) putpixel(x,y,color); getpixel(x,y) setcolor( );setbkcolor( );getcolor( );getbkcolor outtext( buffer ),outtextxy(x,y,buffer) line(x0,y0,x1,y1);linerel( );lineto( ) circle(int x, int y, int radius); arc( ) bar(int l, int t, int r, int b);bar3d( ); moveto(int x, int y);moverel(dx,dy);getx( ) putpixel(x,y,color); getpixel(x,y) setcolor( );setbkcolor( );getcolor( );getbkcolor( ); 看联机帮助,或参见下面的部分文字 显示器是个人计算机的重要组成部分。随着计算机硬件的发展,现在有不同的显示器及其适配器用在个人计算机系统中。常用的显示器有 CGA,Herclus,EGA,VGA,SVGA,TVGA等等。显示模式有两种,文本模式和图象模式,DOS操作系统中默认的是文本模式。在图形模式中,整个屏幕按显示器的分辨率分成点阵,EGA可以是643*350或640*200的点阵,CGA可以是640*200或320*200的点阵,VGA则可以 640*200*16色,或640*480*16色,本程序中用的就是后一种(VGAHI)。...