C language Graphics functions (1)

Source: Internet
Author: User
Tags constant numeric value

Turbo C provides a very rich graphical function, and all graphics function prototypes are graphics. H, this section mainly introduces the initialization of graphics mode, the establishment of independent graphics program, basic graphics function, graphics window and graphics mode of the text output functions. In addition, use graphical functions to ensure that you have a display graphics driver *bgi, and that you select the graphics Lib in the integrated development environment Options/linker as on to ensure proper use of graphics functions.

1. Initialization of graphics mode

Different display adapters have different graphics resolutions. That is, the same monitor adapter, with different resolutions in different modes. Therefore, before the screen is plotted, the monitor must be set to a graphics mode based on the type of display adapter, and before the graphics mode is set, the default screen for the microcomputer system is text mode (80 column, 25 line character mode), at which point all graphics functions are not working. To set the screen to graphical mode, you can use the following graphics initialization functions:

void far initgraph (int far *gdriver,int far *gmode,char);

where Gdriver and Gmode represent graphics drives and patterns, path refers to the directory path where the graphics driver resides. The symbolic constants and corresponding resolutions for graphics drives, graphics patterns are shown in table 2.

The graphics driver is provided by the Turbo C Publisher with the file name extension. BGI. Different graphics drivers are available depending on the graphics adapter. For example, the driver egavga.bgi is invoked for a EGA, VGA graphics adapter.

Table 2. Symbolic constants and numerical values of graphics drivers and patterns
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Graphics Drive (Gdriver) graphics mode (Gmode)
────────────────────── Tonal resolution
Symbolic constant numeric value symbol constant
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
CGA 1 CGAC0 0 C0 320*200
CGAC1 1 C1 320*200
CGAC2 2 C2 320*200
CGAC3 3 C3 320*200
Cgahi 4 2 Color 640*200
───────────────────────────────────
MCGA 2 MCGAC0 0 C0 320*200
MCGAC1 1 C1 320*200
MCGAC2 2 C2 320*200
MCGAC3 3 C3 320*200
Mcgamed 4 2 Color 640*200
Mcgahi 5 2 Color 640*480
───────────────────────────────────
EGA 3 Egalo 0 16 Color 640*200
Egahi 1 16 Color 640*350
───────────────────────────────────
EGA64 4 Ega64lo 0 16 Color 640*200
Ega64hi 1 4 Color 640*350
───────────────────────────────────
Egamon 5 egamonhi 0 2 color 640*350
───────────────────────────────────
IBM8514 6 Ibm8514lo 0 256 color 640*480
Ibm8514hi 1 256 Color 1024*768
───────────────────────────────────
Herc 7 Hercmonohi 0 2 color 720*348
───────────────────────────────────
ATT400 8 att400c0 0 C0 320*200
ATT400C1 1 C1 320*200
ATT400C2 2 C2 320*200
ATT400C3 3 C3 320*200
Att400med 4 2 Color 320*200
Att400hi 5 2 Color 320*200
───────────────────────────────────
VGA 9 Vgalo 0 16 Color 640*200
Vgamed 1 16 Color 640*350
Vgahi 2 16 Color 640*480
───────────────────────────────────
PC3270 Pc3270hi 0 2 Color 720*350
───────────────────────────────────
Detect 0 for hardware testing
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.