turbo c填充图形_C / C ++中的图形:Turbo C编译器中的图形模式

turbo c填充图形

In C / C ++ Advance learning Tutorial, today we are introducing Graphics Mode.

在C / C ++高级学习教程中,今天我们介绍图形模式。

Graphics Mode: To create a program in Graphics Mode, the first step would be to include the header file graphics.h. This file is required for Graphics programming. After this, the graphics have to be initialized.

图形模式:要在图形模式下创建程序,第一步将包括头文件graphics.h 。 图形编程需要此文件。 此后,必须初始化图形。

C Language supports 16 Bit's MS-DOS environment. Initializing the Graphics mode is to call various functions, one such is called initgraph. Here, we will explain how to use the initgraph function. Have a look the prototype of the function.

C语言支持16位的MS-DOS环境。 初始化Graphics模式是调用各种函数,其中一种称为initgraph 。 在这里,我们将解释如何使用initgraph函数。 看一下函数原型。

    void initgraph (int *graphdriver, int *graphmode, char *pathtodriver);

This function takes 3 parameters,

此函数有3个参数,

  1. graphdriver: This is an integer that indicates that the graphics driver has been used.

    graphdriver:这是一个整数,表明已使用图形驱动程序。

  2. graphmode: It is also an integer value that detects the available graphics driver and initializes the graphics mode according to its highest resolution.

    graphmode:它也是一个整数值,它检测可用的图形驱动程序并根据其最高分辨率初始化图形模式。

  3. pathtodriver: This is the path of the directory that first searches the initgraph function graphics driver. If the graphics driver is not available then the system searches it in the current directory.

    pathtodriver:这是首先搜索initgraph函数图形驱动程序的目录的路径。 如果图形驱动程序不可用,则系统在当前目录中搜索它。

It is necessary to pass the correct value of the three parameters in the initgraph function or else an unpredictable output is obtained.

必须在initgraph函数中传递三个参数的正确值,否则将获得不可预测的输出。

    intgd = DETECT, gm;
    initgraph (&gd, &gm, " ");

To initialize Graphics mode, you only have to write two lines. Here, we have taken two integer variables 'd' and 'm'.

要初始化图形模式,只需写两行。 在这里,我们采用了两个整数变量d和m 。

Here, DETECT is an enumeration type that identifies and identifies the proper graphics driver. The initgraph function has to pass the address of both the variables.

在此, DETECT是一种枚举类型,用于标识和标识正确的图形驱动程序。 initgraph函数必须传递两个变量的地址。

You can see in the example that we have given a space at the position of the third variable. This means that if you do not know the driver's path then you can leave it blank. The compiler will auto-detect the path.

您可以在示例中看到,我们在第三个变量的位置给了一个空格。 这意味着,如果您不知道驱动程序的路径,则可以将其留为空白。 编译器将自动检测路径。

Here is the complete program for the same...

这是相同的完整程序...

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

int main()
{
	int gd = DETECT, gm;

	initgraph(&gd, &gm, "C:\\TC\\BGI");

	getch();
	closegraph();
	return 0;
}


翻译自: https://www.includehelp.com/c/graphics-in-c-cpp-graphics-modes-in-turbo-c-compiler.aspx

turbo c填充图形

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值