zoukankan      html  css  js  c++  java
  • vc下找不到#include <graphics.h>

    如果头文件有这个,#include <graphics.h>,编译时会显示
     Cannot open include file: 'graphics.h': No such file or directory

    原因是graphics.h是Tc中专有的,<graphics.h>这个头文件不是标准C的头文件,vc下没有这个头文件,画图用控件来。还是有办法在vc下用的,就是把这个头文件和相关文件放在相应的lib和include目录下,有人制作了一个软件包, EasyX_2011惊蛰版http://www.easyx.cn,里面有头文件和安装方法,我只是把文件放在对应目录的,找不到easyx的安装文件,下了几个都是没有的,但是软件说是有的,不知为什么,可能缺少安装吧,运行还是一大堆错误。

     

    网友文章:

    VC 绘图库(下载graphics.h):可以在 VC 下像 Turbo C 的 BGI 一样简单的绘图

    为什么要写这个库? 
    让初学者从 Turbo C 2.0(以下简称 TC) 或 Borland C++ 3.1 开始学编程是个不错的建议,只是 TC 的环境实在太老了,复制粘贴都很不方便。有一个 Win-TC,简单用了一下,实在是个害人的东西,还不如 TC 好呢,因为它简化了所有调试的部分(或许是我没看到?),而调试是写程序相当重要的一部分。 
    不少老师直接拿 VC6 来讲 C 语言的,因为 VC6 的编辑和调试环境都很优秀。只可惜在 VC6 下只能做一些文字性的练习题,想画条直线画个圆都很难,还要注册窗口类、建消息循环等等,初学者会受严重打击的。许多老师让学生在 TC 下绘图,因为这的确会让人有兴趣。 
    所以,我想给初学者一个更好的学习环境,就是 VC6 的平台 + TC 的绘图功能,于是就有了这个库。如果您刚开始学 C 语言,或者您是一位教 C 语言的老师,那么这个东西一定会让您兴奋的。 
    额外说明 
    这个库并不适合做产品,只建议用来入门学习。如果您想做简单的绘图产品,那么 SDL 库或许更适合您。或者,直接介入 DirectX 编程吧。 
    安装 
    下载的压缩包里除了说明,只有两个主要文件,将 graphics.lib 拷贝到 VC6 文件夹下的 Lib 文件夹内,将 graphics.h 拷贝到 Include 文件夹内,仅此而已,所以我就偷懒没有做安装程序了。 
    使用说明 
    目前只模拟了极少数 Borland C++ 3.1 的绘图库,只是把我个人理解中的初学者常用的图形函数模拟了一下。 
    使用上,基本和 TC 没什么区别。看一个画圆的例子吧: 
    #include <graphics.h> // 就是需要引用这个图形库 
    #include <conio.h> 
    void main() 

    initgraph(640, 480); // 这里和 TC 略有区别 
    circle(200, 200, 100); // 画圆,圆心(200, 200),半径 100 
    getch();              // 按任意键继续 
    closegraph();    // 关闭图形界面 

    呵呵,很简单吧。

    以下是这个库所支持的函数列表。恩,仅仅是列表,详细的使用说明在下载包内。 
    void initgraph(int Width, int Height); // 初始化图形环境 
    void initgraph(int Width, int Height, int Flag); 
    void closegraph(); // 关闭图形环境 
    void cleardevice(); // 清屏 
    COLORREF getcolor(); // 获取当前绘图前景色 
    void setcolor(COLORREF color); // 设置当前绘图前景色 
    COLORREF getbkcolor(); // 获取当前绘图背景色 
    void setbkcolor(COLORREF color); // 设置当前绘图背景色 
    void getviewsettings(struct viewporttype *viewport); // 获取视图信息 
    void setviewport(int left, int top, int right, int bottom, int clip); // 设置视图 
    void clearviewport(); // 清空视图 
    void getlinesettings(struct linesettingstype *lineinfo); // 获取当前线形 
    void setlinestyle(int linestyle, unsigned int upattern, int thickness); // 设置当前线形 
    void getfillsettings(struct fillsettingstype *fillinfo); // 获取填充类型 
    void setfillstyle(int pattern, int color); // 设置填充类型 
    void getfillpattern(char *pattern); // 获取自定义填充类型 
    void setfillpattern(const char *upattern, int color); // 设置自定义填充类型 
    void getaspectratio(int *xasp, int *yasp); // 获取当前缩放因子 
    void setaspectratio(int xasp, int yasp); // 设置当前缩放因子 
    void setwritemode(int mode); // 设置绘图位操作模式 
    void graphdefaults(); // 重置所有绘图设置为默认值 
    COLORREF getpixel(int x, int y); // 获取点的颜色 
    void putpixel(int x, int y, COLORREF color); // 画点 
    void moveto(int x, int y); // 移动当前点(绝对坐标) 
    void moverel(int dx, int dy); // 移动当前点(相对坐标) 
    void line(int x1, int y1, int x2, int y2); // 画线 
    void linerel(int dx, int dy); // 画线(至相对坐标) 
    void lineto(int x, int y); // 画线(至绝对坐标) 
    void rectangle(int left, int top, int right, int bottom); // 画矩形 
    void getarccoords(struct arccoordstype *arccoords); // 获取圆弧坐标信息 
    void arc(int x, int y, int stangle, int endangle, int radius); // 画圆弧 
    void circle(int x, int y, int radius); // 画圆 
    void pieslice(int x, int y, int stangle, int endangle, int radius); // 画填充圆扇形 
    void ellipse(int x, int y, int stangle, int endangle, int xradius, int yradius);// 画椭圆弧线 
    void fillellipse(int x, int y, int xradius, int yradius); // 画填充椭圆 
    void sector(int x, int y, int stangle, int endangle, int xradius, int yradius); // 画填充椭圆扇形 
    void bar(int left, int top, int right, int bottom); // 画无边框填充矩形 
    void bar3d(int left, int top, int right, int bottom, int depth, int topflag); // 画有边框三维填充矩形 
    void drawpoly(int numpoints, const int *polypoints); // 画多边形 
    void fillpoly(int numpoints, const int *polypoints); // 画填充的多边形 
    void floodfill(int x, int y, int border); // 填充区域 
    void outtext(LPCTSTR textstring); // 在当前位置输出文字 
    void outtextxy(int x, int y, LPCTSTR textstring); // 在指定位置输出文字 
    int textwidth(LPCTSTR textstring); // 获取字符串占用的像素宽 
    int textheight(LPCTSTR textstring); // 获取字符串占用的像素高 
    void SetFont(int nHeight,int nWidth,int nEscapement,int nOrientation,int fnWeight,BYTE fdwItalic,BYTE fdwUnderline,BYTE fdwStrikeOut,LPCTSTR lpszFace); // 设置当前字体样式 
    void SetFont(const LOGFONT *font); // 设置当前字体样式 
    void GetFont(LOGFONT *font); // 获取当前字体样式 
    void getimage(int left, int top, int right, int bottom, IMAGE *imgdst); // 从屏幕获取图像 
    void getimage(const char *imagefile, IMAGE *imgdst); // 从 BMP 文件获取图像 
    void getimage(const IMAGE *imgsrc, int left, int top, int right, int bottom, IMAGE *imgdst); // 从 IMAGE 对象获取图像 
    void putimage(int left, int top, IMAGE *img, int op); // 绘制图像 
    int getmaxcolor(); // 获取最大颜色值 
    int getmaxx(); // 获取最大 x 坐标 
    int getmaxy(); // 获取最大 y 坐标 
    int getx(); // 获取当前 x 坐标 
    int gety(); // 获取当前 y 坐标 
    int GetVer(); // 获取当前版本

    http://student.csdn.net/link.php?url=http://hi.baidu.com%2Fyangw80%2Fblog%2Fitem%2F63ff598072a9f9d09023d97f.html

    http://student.csdn.net/space.php?uid=52781&do=blog&id=4228

     

  • 相关阅读:
    随便 构思 一个 计算 解析积分 的 简单 的 数学软件
    为什么要 拿 光 的 干涉条纹 宽度 变化 作为 判断 光速 变化 的 依据 ?
    相对论 的 几个问题
    设计 逻辑电路 的 开关元件 (2)
    设计 逻辑电路 的 开关元件
    用 逻辑电路 实现一个 开平方 算法
    小梦 在 民科吧 发了一个 用 四则运算 开平方 的 帖
    物理学 的 基本原理
    和 小梦 探讨 一个 经典力学 问题
    二分法 比 跨越步进法 快
  • 原文地址:https://www.cnblogs.com/youxin/p/2400828.html
Copyright © 2011-2022 走看看