Subscribe Now: freedictionary

Add to The Free Dictionary

Wednesday, 4 January 2012

Graphics in C Language


Graphics in C Language

We will restrict our discussion on Graphics in C Language to 16 bit C programming and MS DOS environment.  This is done using the initgraph method provided in graphics.h library. In the next few pages we will discuss graphics.h library in details. Important functions in graphic.h library will be discuees in details and samples programmes will be provided to show the power of C programming language.

Graphics mode Initialization

First of all we have to call the initgraph function that will intialize the graphics mode on the computer. initigraph have the following prototype.
 void initgraph(int far *graphdriver, int far *graphmode, char far *pathtodriver);

*graphdriver

Integer that specifies the graphics driver to be used. You can give graphdriver a value using a constant of the graphics_drivers enumeration type.

*graphmode

Integer that specifies the initial graphics mode (unless *graphdriver = DETECT). If *graphdriver = DETECT, initgraph sets *graphmode to the highest resolution available for the detected driver. You can give *graphmode a value using a constant of the graphics_modes enumeration type.

*pathtodriver

Specifies the directory path where initgraph looks for graphics drivers (*.BGI) first.
  1. If they’re not there, initgraph looks in the current directory.
  2. If pathtodriver is null, the driver files must be in the current directory.
*graphdriver and *graphmode must be set to valid graphics_drivers and graphics_mode values or you’ll get unpredictable results. (The exception is graphdriver = DETECT.)
Here is a sample program that initializes the graphics mode in C Language.






No comments:

Post a Comment

comment.........

Engineering -Thinks of Words

Subscribe Now: google

Add to Google Reader or Homepage