c - setbkcolor() 在 Dev-C++ 4.9.9.2 中无效

标签 c graphics bgi

我最近开始使用 Dev C++ 4.9.9.2 来试验 C 中的图形程序(感谢这个 tutorial)。但出于某种原因setbkcolor()什么都不做。这是代码...

#include <stdio.h>
#include <graphics.h>
#include <conio.h>

int main()
{
    initwindow(800,600);
    setbkcolor(GREEN);   //FAILED. also tried "setbkcolor(2);"
    while ( !kbhit() ){}
    return 0;
}

这是输出:black colored screen still

我正在使用 Windows 7 Professional。这与操作系统有关吗?

最佳答案

documentation Windows notes 部分说:

Also, only future drawing will use the new background color (anything currently drawn in the old background color will stay in the old color). Calling setbkcolor(0) will change the background color to the current color at index [0] of the palette (rather than always changing the background to black).

你误解了函数的目标。

关于c - setbkcolor() 在 Dev-C++ 4.9.9.2 中无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32184011/

相关文章:

c# - 使用 Graphics 类在 C# 中精确定位文本渲染

c++ - 使用graphics.h时 undefined reference ?

c - 关于C语言中的字符串拼接

c - 这段代码中的 fgets 有什么错误?

c - 3d 网格中的转发(绘图)线

c++ - 无法打开包含文件 : 'graphics.h' : No such file or directory

c - 如何从 Windows 内核模式驱动程序设置键盘指示灯?

c - float 随机化后程序崩溃

assembly - 调色板不适用于 VGA 中的某些颜色