Graphics.h File For C
Hi pals,
I am a Newbie in C++ Programming field. I plan to add graphics.h header class in
Dev -C++ Version 4.9.9.2 from Bloodshed which is come along with Borland Compiler.
I follow the Steps in URL : http://www.uniqueness-template.com/devcpp/#step2
- Graphics.h File In C
- Graphics.h File For Code Blocks
- Graphics.h File For Codeblocks
- Graphics.h File For Dev C++
- Download Graphics.h Header File For Turbo C++
Main Page Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members File Members Related Pages #include #include. Graphics.h> is a pre define header file in C. Which allows you to use graphics function in your C program.you just need to use graphics.h header file into your C program. You can draw geometrical shapes, design simple animation etc. After that, you will get a compiled libbgi.a and a graphics.h which is ready for use in the same folder. Copy paste the libbgi.a in C: TDM-GCC-64 lib folder and graphics.h in C: TDM-GCC-64 include. Open your IDE and link libbgi.a from the linker option in compiler setting and copy paste -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32 in the other linker option.
H> is very old library. It's better to use something that is new. Here are some 2D libraries (platform independent) for C/C++. Also there is a free very powerful 3D open source graphics library for C++. C - Header Files. A header file is a file with extension.h which contains C function declarations and macro definitions to be shared between several source files. There are two types of header files: the files that the programmer writes and the files that comes with your compiler. You request to use a header file in your program.
But I Got Error in the Sample code which test the Working , Please Help me
to get away from this problem . I am waiting to hear from you.
While trying c graphic programming on Ubuntu, I figured out that graphic.h is not a standard C library and it is not supported by gcc compiler. So I am writing this article to explain the process. If you want to use graphics.h on Ubuntu platform you need to compile and install libgraph. C graphics programming tutorials fou beginners using graphics.h header files. It contains lots of samle graphics programs in C like moving car, jumping ball animation etc. C Graphics Programming Tutorial.
Regards
Anes P.A:'(
- 13 Contributors
- forum14 Replies
- 11,592 Views
- 5 Years Discussion Span
- commentLatest Postby leonesa
You can't. graphics.h is not compatible with Dev-C++
- HubPages»
- Technology»
- Computers & Software»
Borland C Graphics
If 70% of C programming isinheritance,structure,classes and othertheoretical subjects the rest 40% is related with C graphics programming.It isthe fun side of programming actually.I was Ignorant about graphics programmingin c ,c++ since the day I learned #include<iostream.h> the portion is not usually covered inusual C programming tutorials , thereare special books for C graphicsprogramming alone.Nobody will speak about graphics if you go and search for'learn C' in google.I still believe its necessary to teach about graphics programming withthe basic lesson itself.There was nobody there to teach me about about thistopic , finally I dug up some c graphics programming books from my collegelibrary and mastered the concepts in few days.Its simple than the rest ofthe OOPS concepts actually.So let's move into work.
Borland C graphics.h tutorial
Themost basic thing you have to learn before stepping in the C shore of graphicsis about the monitor.
Themonitor you are staring at right now contains lots of small dots called pixels, when each pixels glow in different colours you see an image.You can imagineit as minute bricks which can change to any colour used in building up thescreen you see.
Whenwe initialize a programming for using C graphics.h it converts the whole screeninto a matrix, if you don’t know what a matrix in mathematics means ,justunderstand that your screens top leftcorner is taken as origin the x-axis increases by width from left to right andthe y-axis increases by length from top to bottom.The co-ordinates we enter ineach function is mapped according to this order.Now I don’t want to confuse youwith further complicated theory.If you need to get indepth technichal knowledge about this topic you can go for C grapics book from amazon i've linked somewhere in the bottom of this page.We will hover straight into the application now.Fordeveloping graphics using C we need todo it in three simple steps.
Graphics.h File In C
- Loading the header file of C graphics.h
- Initializing 'graphics driver' and 'grahpics mode'
- Using the functions where ever necessary
Loading The Header File
Loading the header file of C graphics.h
The C graphics.h is the header file which should be included to initalize your computer to start using grahipcs methods and also to initialize the monitor.These kinds of statements before the main program are called preprocessor dierctives.Its very simple as coded below.
Initializing Graphics Form Borland C graphics library
This initialization is done inside the main program.The method initgraph() is used for this purpose there are three parameters for this , the first two are of integer type and the next is the path which you can leave blank in quoutes to take the default path.The integer parameters are initalized in this method for all the C graphics programs so you just need to memorize it and apply it for all C graphics programming from now on.
Initializing 'Graphics Driver' and 'Graphics Mode' from Borland C graphics library
Methods In Borland C Graphics programming
Some Common C Graphics Programming Methods
Well, these are some of the most popular C Graphics Methods used in while graphics programming soon after you learn these you can think of developing small games , puzzles and so on.I'll just give only a small overview on each methods.x,y,x1,y1,x2,y2 etc are all variables you'll have to substitute with numeric values to get working programs.Further clear-cut reference can be obtained from any of the C graphics book available from amazon or your local library(those books would be pretty old and dusty by now). If you find it difficult to view the long C graphics library functions code in the window because the code is too lengthy, then click on the 'view plain' written in small fonts at the top left of the codes box on the left side of this text.
Cleardevice()
Clears all previous graphical outputs generated by the previous programs.It's a good practice to include this method at the starting of each program.
gotoxy()
This will initialize the graphics cusor to the specified co-ordiante.In C gotoxy function is used very frequently to locate the cursor at different locations whenever as necessary.
putpixex()
It will colour the pixel specified by the co-ordinates.
outtextxy()
Magazine. This method is used to display a text in any position on the screen.The numeric coordinates are substituted for x and y.
rectangle()
Draws a rectangle according to the given parameter x and y are the top-left corner co-ordinates.
circle()
Draws a circle with x,y as the center .
Graphics.h File For Code Blocks
line()
Draws a line as per the given co-ordinates.
moveto()
Cursor is moved from the current location to the specified location dx,dy.These parameters can also be used as incremental values.
lineto()
Draws a line from its current location to the co-ordinate(x,y)
ellipse()
Graphics.h File For Codeblocks
Draws the ellipse with the specified angles and coordinates.
drawpoly()
Draws a polygon with (num_of_points +1) edges.The array 'points'
int points[ ]=(x1,y1,x2,y2,x3,y3..)
settextstyle()
The fonts available are :TRIPLEX_FONT, SMALL_FONT, SANS_SERIE_FONT, GOTHIC_FONT
The direction can be changed as HORIZ_DIR or VERT_DIR
The character size increases from 1 to 10
setfillstyle()
The fill styles available are SOLID_FILL, LINE_FILL, HATCH_FILL, SLASH_FILL etc.
setcolor()
Sets the color
floodfill()
The function fills the enclosed area about x,y with the highest value of the color returned by the getmaxcolor().
setviewport()
This marks a rectangle starting from (10,10) having widht 630 pixels height 470 pixels.The integer specifies this identified area may be clipped. clearviewport() reverse this function.
itoa()
Converts the integer x1into an alphabet, and puts it in st1, which is an array to hold 10 characters.10 is the buffer size.
delay()
Cause a pause in execution of the program 1000ms= 1 second
closegraph()
Terminates all graphics operations and revert the hardware back to the normal mode.
Helpful C/C++ Graphics Books
C Graphics Book
If you are really into mastering the C/C++ Graphics I would suggest you to go for only two books:
- Graphics Programming in C++: Writing Graphics Applications for Windows 98
This is a very well written book on designing your own graphics applications for Windows, no matter what type of application you are wanting to do. Mark Walmsley goes into good detail about designing many different types of applications from simple display program to advanced subjects such as 3D modeling. Mr. Walmsley address many common errors and pitfalls with the included examples.I would recommend this book to anyone who is interested in writing a graphics application.
Advanced Graphics Programming Using C/C++
A book is a good source for advanced PC graphics topics currently being used in a wide variety of fields. Stresses a hands-on approach, providing numerous program examples written in C and applicable to any C compiler with correct, ready-to-use and well-described code. Covers ray tracing, used to create realistic 3-D graphics. Includes information on graphical file formats and manipulating digital images. Also focuses on printing screens and images.
More Basic Programming Articles
- How to learn asp.net C# from Java and C++
Learning C# is not easier than any other modern programming language. But if you have already learned either C++ or Java then, learning C# would be bliss. What is C Sharp? What's the difference between c#, Java and c++ ? - Learn HTML 5.0 HTML5 Tutorials HTML5 Examples HTML5 Browser Supports
Learn all about HTML 5.0, with links to the best HTML5 tutorials and examples available on the internet.How to enable HTML5 in my browser? How To Get Started with HTML5? How do I code webpages in HTM5 ? Html5 tag, canvas, offline mode and more.. - How To Use HTML5 Video Tags HTML5 Video Tutorial
The tag is one of the most exciting and awaited feature of HTML5, there is no doubt that this video tag would make adding and viewing much easier. When we visit Youtube we can find that there are links by..
Bonus Three Debugging C Tips
Graphics.h File For Dev C++
This is a small bonus tip from me about debugging C.When you start programming , first few times you would find that debugging is a nasty job but once you learn understand the heart of C everything will be so easy.These are the three most common error which a programmer (mostly novice) come across but yet the get confused in correcting it.
Download Graphics.h Header File For Turbo C++
- I always have aconfusion while using the special characters for new line(n) , tab space(t) etc whether its /n orn.To easily remember that keep '%'- this symbol in mind.Just type the slashin the opposite direction.
- The most commonerrors while for a novice programmer is that he forgets to put thesemicolon ';' at the end of a statement.
- Another tricky errorwhich frequently occurs is that you forget to put the'&' symbol while taking an input with scanf in 'C'.This wontgenerate any error messagesbut the you will get strange results as output. This is because all the arguments pointers pointing to the memory.The scanf function will not perform correctly because it will be attempting to overwrite the wrong sections of memory, rather than pointing to the memory location of the variable you are attempting to get input for.

Was This Article Helpful?
If this article was helpful for you, vote it up by clicking thebeautiful green oval a few paragraph below. Your experience may be a lesson for others also. Do shareyour incredible insights about More Graphics Tutorials, Tips & Tricks For C on the commentbox below.
If I am correct, bcc5.5 does not have 'graphics.h' header file unlike from tc3.0, then what is the alternative of 'graphic.h' in bcc5.*?
Highly impressed by the effort for writing this hub .. excellent tutorials ... thanks for such a wonderful hub .. keep the good work up ... thanks ...
Really, appreciable efforts and a very handy material for the beginners for CG..
Thnaks!
how to change the origin frm topleft corner???????
plzzzzzzz reply soon
It is also possible to link in the graphics library so that it is contained within the program itself. This can be found in the Borland C++ users guide.
Saves the program from looking for a separate graphics.lib file!
Hi,
How to get rid of BGI error. I tried running a program which shows a circle but Borland C++ 5.02 gives an error which says 'BGI graphics not supported under Windows'
Plz help
'you will get strange results as output with no reason.'
if you don't understand how reference[&] works, you shouldn't call them 'strange results'
how u display an image??
hi this help me a lot like i was waiting for this knowlage for last few months this site help me a lot i cant express my happynes through these few words
The source code for programs should be supplied in the manner that they could easily b understood by a dummy man.
is there any site for best tutorial for computer graphics programming in C++
Love your effort!
It has really encouraged me to add more graphics in to my c project.
Cheers!
Oh ok. You wanted it to say 70% and 40% I got it now. lol.
It's nice to share. Others will appreciate it.
You're welcome. :-)
Nanospeck, nice hub. In the first sentence you said 40% is graphic, but should it be 30% if the other is 70%? That would total 100%.
I don't know anything about C programming, but you should get good traffic to this hub if no one else is helping on this subject and lots of people are searching for it. That is if the search engines rank your hub well. You have everything nicely written and illustrated.
Best wishes.