<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6288478901670625691</id><updated>2011-09-21T13:15:30.997+05:30</updated><category term='initgraph'/><category term='firstblog'/><category term='C graphics'/><category term='C++ graphics'/><category term='intro'/><title type='text'>|&lt;-- KP --|&gt;</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://karthikprashanth.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288478901670625691/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://karthikprashanth.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>G.R.Karthik Prashanth</name><uri>http://www.blogger.com/profile/12821844544981037047</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6288478901670625691.post-4892723228170135121</id><published>2009-10-18T14:00:00.000+05:30</published><updated>2009-10-18T14:00:59.722+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='C graphics'/><category scheme='http://www.blogger.com/atom/ns#' term='initgraph'/><category scheme='http://www.blogger.com/atom/ns#' term='C++ graphics'/><title type='text'>C/C++ Graphics</title><content type='html'>Hey guys,&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I'm going to give a outline on DOS based graphics in C/C++ with graphics.h which can be implemented in Turbo C/CPP.DOS screen can be of 2 types. Command based or Graphics based. When we are using printf() in C&amp;nbsp; or cout in CPP , we are mainly using the command console available to us. To use graphics ,we need to call a few functions.we'll now see how to use basic graphics in Turbo C/CPP.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Any device in computer requires a driver ( a program ) to have communication between device and us ( operating system/ other programs ) . In this case to initiate graphics, we need a graphics driver ( just a file ) called EGAVGA.BGI . BGI stands for Borland Graphics Interface which provided this file to be used in Turbo/Borland  editions of C/C++. Let's take an example...&lt;br /&gt;&lt;br /&gt;#include &lt;graphics.h&gt;"graphics.h"&lt;br /&gt;#include "conio.h"&lt;conio.h&gt;&lt;br /&gt;void main()&lt;br /&gt;{&lt;br /&gt;int gdriver=DETECT,gmode;&lt;br /&gt;initgraph(&amp;amp;gdriver,&amp;amp;gmode,"");&amp;nbsp;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;setbkcolor(1);&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt; line(0,0,639,479);&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;getch();&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;closegraph();&lt;br /&gt;}&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;Like any in-built (library ) functions require a header file, this also requires one "graphics.h".This file have&amp;nbsp;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; initgraph()&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; setbkcolor() &lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; line()&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;initgraph() - It takes 3 parameters. &lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1) gdriver = DETECT &lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Driver to be used.In this case we are using DETECT ( or 0 ) so that the program takes care of the best available driver. TCPP will use VGA graphics driver.( For this to work we need EGAVGA.BGI )&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt; &lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2) gmode&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; When the driver gets detected, it selects the the graphics mode. This is nothing but the number of colors used and the screen resolution. By default , it'll have&amp;nbsp; 16 colors and 640X480 px. This is maximum possible with VGA graphics.&lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt; &lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Both the variable's addresses are passed as the address fetches the necessary data.&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3) ""&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This argument is the location of the driver file ( in our case EGAVGA.BGI ). Empty quotes is used if the file is located in the current directory. This is best because even when the program( EXE ) is transferred , the program will work as far as the BGI file is present in the same directory of the program.&lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;Now the graphics is initialized and is ready to be used.&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;setbkcolor(). It takes color as the parameter ranging from 0 to 15.This sets the background color.&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;Note : If setcolor(0) is used , its set the color to back color (set in setbkcolor ) and NOT BLACK.&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Now the screen is set and background color is also changed.The screen is in 4th quadrant i.e. (0,0) is on the left top of the screen (unlike windows ) and (639,479) is the right bottom of the screen.&lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;line() - It takes 2 sets of coordinates as the parmeter and draw a line between them i.e. line (x1,y1,x2,y2)&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;Similarly there are other functions to draw various shapes which is available in Turbo C/CPP help inside "graphics.h"&amp;nbsp;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;closegraph()- This is used to close the graphics connection.This frees the allocated memory for graphics and graphics functions cannot be used after this unless initgraph() is called again.&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt; &lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;br /&gt;&lt;graphics.h&gt;&lt;conio.h&gt;&lt;br /&gt;&lt;/conio.h&gt;&lt;/graphics.h&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6288478901670625691-4892723228170135121?l=karthikprashanth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://karthikprashanth.blogspot.com/feeds/4892723228170135121/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://karthikprashanth.blogspot.com/2009/10/cc-graphics.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288478901670625691/posts/default/4892723228170135121'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288478901670625691/posts/default/4892723228170135121'/><link rel='alternate' type='text/html' href='http://karthikprashanth.blogspot.com/2009/10/cc-graphics.html' title='C/C++ Graphics'/><author><name>G.R.Karthik Prashanth</name><uri>http://www.blogger.com/profile/12821844544981037047</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288478901670625691.post-4227896202571971244</id><published>2009-09-20T20:06:00.000+05:30</published><updated>2009-09-20T20:10:19.485+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='firstblog'/><category scheme='http://www.blogger.com/atom/ns#' term='intro'/><title type='text'>Hello Web!!!</title><content type='html'>I am G. R . Karthik Prashanth , II yr CSE Sastra University,Tanjore . I was asked to create a blog since I came to this college,but I was too lazy :-) .&lt;br /&gt;But , now I'm starting it at 20:09 20/09/2009...&lt;br /&gt;I'm going to keep this blog updated as much as possible.&lt;br /&gt;&lt;br /&gt;P.S.&lt;br /&gt;&lt;br /&gt;I'm not so good at writing ( in English ). Plz do correct me if I go wrong....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6288478901670625691-4227896202571971244?l=karthikprashanth.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://karthikprashanth.blogspot.com/feeds/4227896202571971244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://karthikprashanth.blogspot.com/2009/09/hello-web.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288478901670625691/posts/default/4227896202571971244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288478901670625691/posts/default/4227896202571971244'/><link rel='alternate' type='text/html' href='http://karthikprashanth.blogspot.com/2009/09/hello-web.html' title='Hello Web!!!'/><author><name>G.R.Karthik Prashanth</name><uri>http://www.blogger.com/profile/12821844544981037047</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
