【发布时间】:2018-01-06 08:24:41
【问题描述】:
我正在尝试将橙色添加到我的图形代码程序中。我正在使用 putpixel(int x, int y, int color) 函数来添加颜色。此功能不允许我这样做。这是我的代码,请帮我解决这个问题
#include<iostream>
#include<graphics.h>
int main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,NULL);
int height,width;
height=10;
width=75;
while(height!=43)
{
putpixel(width,height,12); //here i want to add orange color
width++;
if(width==225)
{
width=76;
height++;
}
}
getch();
closegraph();
}
我正在尝试建立一面印度国旗。我正在使用 GNU lib libgraph 1.0.2
【问题讨论】:
-
#include<graphics.h>不是标准的 C++,而且这个名字太笼统了,我不知道你说的是哪个第三方库。最重要的是,代码可能甚至无法编译,除非神秘的graphics.h头文件定义了两个全局变量height和width。 -
@ChristianHackl:我猜是 (web.stanford.edu/class/archive/cs/cs106b/cs106b.1126/materials/…)
-
但是现在代码已经编辑了更多信息,这个猜测是错误的。
-
看来
putpixel是(cs.colorado.edu/~main/bgi/doc/putpixel.html)。 -
@ChristianHackl 感谢您清除我,我认为 graphics.h 来自标准 c++,所以我没有发布任何有关该库的信息。对不起,再一次