Thursday 24, April 2014
Welcome Guest, Register | Login  
      Home    |    Tutorials    |    Free Ebooks    |    Free Scripts    |    Articles    |    Blog     |    About Us    |    Contact Us

Graphics

In a C Program first of all you need to initialize the graphics drivers on the computer. This is done using the initgraph method provided in graphics.h library.

Graphics mode Initialization:
initgraph() function is used to load the graphics drivers and initialize the graphics system. For every function, that uses graphics mode, graphics mode must be initialized before using that function.
 
void far initgraph(int far *driver, int far *mode, char far *path)
 
Function detectgraph:
Detectgraph function determines the graphics hardware in the system, if the function finds a graphics adapter then it returns the highest graphics mode that the adapter supports.

void far detectgraph(int far *driver, int far *mode)
 
Integer that specifies the graphics driver to be used. You can give graphdriver a value using a constant of the graphics_drivers enumeration type.
 
Graphic Mode:
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.

 
Function closegraph:
This function shutdown the graphics mode and returns to the position it was before the initgraph function was called.
void far closegraph(void)

 
Example 1:

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

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

    initgraph(&gd, &gm, "c:\\turboc\\bgi");
    circle(200,100,150);

    getch();
    closegraph();
}

 
Example 2:

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


void main()
{
    int gd=DETECT, gm;
    initgraph(&gd, &gm, " c:\\turboc\\bgi");
     
    circle(100,100,50);
    outtextxy(75,170, "Circle");
    rectangle(200,50,350,150);
    outtextxy(240, 170, "Rectangle");
    ellipse(500, 100,0,360, 100,50);
    outtextxy(480, 170, "Ellipse");
    line(100,250,540,250);
    outtextxy(300,260,"Line");

getch();
closegraph();
}

 
Some Useful Graphics.h Functions:

int getdisplaycolor( int color );
int converttorgb( int color );
void delay( int msec );
void getarccoords( arccoordstype *arccoords );
int getbkcolor( );
int getcolor( );
int getmaxcolor( );
int getmaxheight( );
int getmaxwidth( );
int getmaxx( );
int getmaxy( );
void getfillpattern( char *pattern );
void getfillsettings( fillsettingstype *fillinfo );
void getlinesettings( linesettingstype *lineinfo );
bool getrefreshingbgi( );
int getwindowheight( );
int getwindowwidth( );
int getpixel( int x, int y );
void getviewsettings( viewporttype *viewport );
int getx( );
int gety( );
void setcolor( int color );
void setfillpattern( char *upattern, int color );
void setfillstyle( int pattern, int color );
void setlinestyle( int linestyle, unsigned upattern, int thickness );
void setrefreshingbgi(bool value);
void setviewport( int left, int top, int right, int bottom, int clip );
void setwritemode( int mode );
void moverel( int dx, int dy );
void moveto( int x, int y );
void refreshbgi(int left, int top, int right, int bottom);
void refreshallbgi( );   
void setbkcolor( int color );
 
     
   
C Language Tutorial
 
  Introduction
Introduction
  First Program
First Program
  Constants and Variables
Constants and Variables
  Loops
Loops
  Control Structure
Control Structure
  Functions
Functions
  Pointers
Pointers
  Arrays
Arrays
  Strings
Strings
  Structures and Unions
Structures and Unions
  File Handling
File Handling
  Graphics
Graphics
 
 
 
Web Designing Tutorials
  HTML Tutorial
HTML Tutorial
  DHTML Tutorial
DHTML  Tutorial
  CSS Tutorial
CSS Tutorial
  XHTML Tutorial
XHTML Tutorial
 
Programming Languages Tutorials
  C Language Tutorial
C Language Tutorial
  C++ Tutorial
C++ Tutorial
  Java Language Tutorial
Java Language Tutorial
  Data Structure Theory Tutorial
Data Structure Theory Tutorial
 
Server Side Scripting Tutorials
  PHP Tutorial
PHP Tutorial
  SQL Tutorial
SQL Tutorial
  ASP Tutorial
ASP Tutorial
 
Client Side Scripting Tutorials
  JavaScript Tutorial
JavaScript Tutorial
  VBScript Tutorial
VBScript Tutorial
 
 
 
POPULAR E-BOOKS
 
Download 5 Easy Tips To Website Traffic Ebook 5 Easy Tips To Website Traffic
   
Download Powerful Webmaster Resources Ebook Powerful Webmaster Resources
   
Download Passions to Profits Ebook Passions to Profits
   
Download The Downline Code  Guru Secrets For Explosive MLM Growth  Ebook The Downline Code Guru Secrets For Explosive MLM Growth
   
Download PPC  Pay Per Click Google AdWords Made Easy  Ebook PPC Pay Per Click Google AdWords Made Easy
   
     
Studiesinn.com 2014 All Rights Reserved.
 
Website Designed & Developed by TechXprtz