A Course Based Project Report on
Understanding Graphic.h for Drawing lines in Dev CPP
Submitted to the
Department of CSE-(CyS, DS) and AI&DS
in partial fulfilment of the requirements for the completion of course
Engineering and IT workshop(22ES2ME102)
BACHELOR OF TECHNOLOGY
IN
CSE-Cyber Secuirty
Submitted by
N.VISHNU 24071A6240
V.NISCHAL 24071A6261
Y.LOHITH 24071A6264
Y.PARTHU 24071A6266
Z. K. ZENITH CHEELI 24071A6267
Under the guidance of
Dr. P. S. PRASAD
Professor
Department of CSE-(CyS, DS) and AI&DS
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING & TECHNOLOGY
An Autonomous Institute, NAAC Accredited with ‘A++’ Grade, NBA
Vignana Jyothi Nagar, Pragathi Nagar, Nizampet (S.O), Hyderabad – 500 090, TS, India
May-2025
1
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI INSTITUTE OF
ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 21001:2018& QS I-Gauge Diamond Rated Institute, Accredited by NAAC with ‘A++’ Grade
NBA Accreditation for B.Tech. CE,EEE,ME,ECE,CSE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWEProgrammes
Approved by AICTE, New Delhi, Affiliated to JNTUH, NIRF (2024) Rank band:151-200in EngineeringCategory
College with Potential for Excellence by UGC,JNTUH-Recognized Research Centres:CE,EEE,ME,ECE,CSEVignana Jyothi Nagar, Pragathi
Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
Telephone No: 040-2304 2758/59/60, Fax: 040-23042761
E-mail: [email protected], Website: www.vnrvjiet.ac.in
Department of CSE-(CyS, DS) and AI&DS
CERTIFICATE
This is to certify that the project report entitled “Understanding graphics.h for Circuit for
Drawing lines in Dev CPP” is a bonafide work done under our supervision and is being
submitted by N. Vishnu (24071A6240), V. Nischal (24071A6261), Y. Lohith (24071A6264),
Y. Parthu (24071A6266), Z. K. Zenith Cheeli (24071A6267) in partial fulfilment for the award of
the degree of Bachelor of Technology in CSE-Cyber Secuirty, of the VNRVJIET, Hyderabad
during the academic year 2024-2025.
DR.P.S.PRASAD DR. T. SUNIL KUMAR
Professor Professor & HOD
Dept of Mechanical Dept of CSE-(CyS, DS) and AI&DS
2
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI INSTITUTE OF
ENGINEERING AND TECHNOLOGY
An Autonomous Institute, NAAC Accredited with ‘A++’ Grade,
Vignana Jyothi Nagar, Pragathi Nagar, Nizampet(SO), Hyderabad-500090, TS, India
Department of CSE-(CyS, DS) and AI&DS
DECLARATION
We declare that the course based project work entitled “Understanding graphics.h for Drawing
lines in Dev CPP” submitted in the Department of CSE-(CyS, DS) and AI&DS, Vallurupalli
Nageswara Rao Vignana Jyothi Institute of Engineering and Technology, Hyderabad, in partial
fulfilment of the requirement for the award of the degree of Bachelor of Technology in CSE-Cyber
Secuirty is a bonafide record of our own work carried out under the supervision of Dr.P.S.Prasad,
Professor, Department of Mecanical, VNRVJIET. Also, we declare that the matter embodied in
this thesis has not been submitted by us in full or in any part thereof for the award of any
degree/diploma of any other institution or university previously.
Place: Hyderabad.
N. Vishnu V. Nischal Y. Lohith Y. Parthu Z. K. Zenith
(24071A6240) (24071A6261) (24071A6264) (24071A6266) (24071A6267)
3
ACKNOWLEDGEMENT
We express our deep sense of gratitude to our beloved President, Sri. D. Suresh Babu, VNR
Vignana Jyothi Institute of Engineering & Technology for the valuable guidance and for permitting
us to carry out this project.
With immense pleasure, we record our deep sense of gratitude to our beloved Principal, Dr. C. D.
Naidu, for permitting us to carry out this project.
We express our deep sense of gratitude to our beloved Professor Dr. T. Sunil Kumar Professor
and Head, Department of CSE-(CyS, DS) and AI&DS , VNR Vignana Jyothi Institute of Engineering
& Technology, Hyderabad-500090 for the valuable guidance and suggestions, keen interest and
through encouragement extended throughout the period of project work.
We take immense pleasure to express our deep sense of gratitude to our beloved Guide,
Dr.P.S.Prasad, Professor in Mechanical, VNR Vignana Jyothi Institute of Engineering &
Technology, Hyderabad, for his/her valuable suggestions and rare insights, for constant source of
encouragement and inspiration throughout my project work.
We express our thanks to all those who contributed for the successful completion of our project work.
N. VISHNU 24071A6240
V. NISCHAL 24071A6261
Y. LOHITH 24071A6264
Y. PARTHU 24071A6266
Z. K. ZENITH CHEELI 24071A6267
4
TABLE OF CONTENTS
CHAPTER PAGE NO
ABSTRACT 1
CHAPTER 1 – Introduction 2
CHAPTER 2 – Understanding Graphic.h in C 3-4
CHAPTER 3 – Installing Graphic.h & installing libraries 5
CHAPTER 4 – Code and Output 6-7
CHAPTER 5 –Results 8
REFERENCES 9
ABSTRACT
Computer graphics plays a vital role in transforming theoretical programming knowledge into
engaging, real-world visual applications. This report explores a basic yet fundamental concept
in graphics programming—drawing a line between two user-defined points using the
graphics.h library in C++, implemented via the Dev-C++ IDE. While the task itself is
elementary, it builds the foundation for understanding how graphical elements are rendered
and manipulated on screen using low-level functions. The primary objective of this project is
to allow users to input coordinate values at runtime, providing flexibility and interactive
control over the output. This departs from static, hardcoded graphical programs and makes
the experience dynamic and user-centric. The program prompts for two points on the
Cartesian plane and then visually represents the line connecting those points using the line()
function. Additionally, the report delves into the technical aspects of setting up the graphics.h
library in Dev-C++, an environment that does not natively support it. It outlines step-by-step
installation, file placement, and compiler configuration, which are critical to compiling and
executing graphics programs successfully. Overall, this simple application provides a hands-
on introduction to C++ graphics, paving the way for more advanced graphical user interfaces
(GUIs), animations, and simulations. By the end of this exercise, users not only learn how to
use basic graphics commands but also understand the setup required to enable such
capabilities in modern IDEs.
1
CHAPTER-1
INTRODUCTION
In the realm of computer science, visual representation holds immense importance. Whether
it's game development, simulation, data visualization, or educational tools, graphics
programming plays a pivotal role in enhancing user experience and conveying information
visually. C++—being a highly powerful and versatile language—supports graphical output,
though not inherently. The support comes in the form of add-on libraries like graphics.h,
which provides a basic set of functions for drawing shapes, lines, and handling simple visual
output. This report focuses on one such graphical task—drawing a straight line using user-
defined input. While the idea may seem elementary at first glance, it introduces several core
concepts in graphics programming such as coordinate systems, rendering processes, and user
interaction. The goal is to not just execute a prewritten piece of code, but to involve the user
in the rendering process by capturing their input and visually displaying the outcome. This
interaction brings clarity to how screen coordinates map to logical values and how simple
geometric shapes can be drawn programmatically. Moreover, the project uses Dev-C++ as the
development environment—a lightweight and beginner-friendly IDE for C and C++.
However, Dev-C++ doesn’t natively support the graphics.h header, requiring users to
manually configure their environment. Understanding how to enable graphics programming
in such setups is a valuable learning opportunity that deepens knowledge of compiler
behavior, library linking, and IDE configuration. By the end of this report, readers will have
not only implemented a user-interactive graphics program but also grasped the broader
context of how graphical output works in C++. They will also gain practical experience with
integrating non-standard libraries and overcoming compatibility challenges that often arise in
modern development environments.
2
CHAPTER-2
Understanding Graphics.h in Dev CPP
The graphics.h header file is part of the old Borland BGI (Borland Graphics Interface)
graphics library, which was primarily used with Turbo C++ in the DOS era. It provided
developers a set of functions to produce simple 2D graphical output like lines, circles,
rectangles, and polygons, making it a favorite among students and educators for visual
programming exercises. Although obsolete in modern professional applications, graphics.h
remains a popular choice in academic settings for teaching basic graphics due to its simplicity
and minimal learning curve.
Some of the most commonly used functions in this library include:
initgraph() – Initializes the graphics mode and detects available graphics drivers.
line(x1, y1, x2, y2) – Draws a line from point (x1, y1) to (x2, y2).
circle(x, y, radius) – Draws a circle with the center at (x, y) and given radius.
rectangle(x1, y1, x2, y2) – Draws a rectangle using two corner points.
setcolor() and setfillstyle() – Change the color and fill patterns of shapes.
One critical detail about graphics.h is that it was designed for older systems and compilers.
Today’s IDEs like Dev-C++ or Code::Blocks use modern compilers (MinGW/GCC), which
don’t support graphics.h out of the box. Therefore, an emulation library like WinBGIm
(Windows BGI emulator) is required to bridge this gap. WinBGIm is essentially a port of
graphics.h for Windows-based systems using GCC.
Using graphics.h not only teaches students the basics of computer graphics but also gives
them exposure to fundamental programming concepts such as pixel plotting, coordinate
systems, screen refreshing, and rendering logic. It’s particularly helpful in understanding how
a 2D Cartesian grid maps to the pixel-based layout of a screen, where the origin (0,0) starts at
the top-left corner.
Moreover, working with graphics.h teaches students how to configure external libraries
manually—a task that is common in real-world development environments. It provides insight
into how compilers link source files with libraries and how developers can extend a
language’s capability using third-party headers and static libraries.
3
Despite its limitations, graphics.h remains a highly educational tool, particularly suited for
beginners looking to break into graphics programming without the steep learning curve of
frameworks like OpenGL or SDL. It offers just enough visual feedback to make programming
more exciting and less abstract, serving as a gateway to more complex and modern graphical
systems in the future.
4
CHAPTER-3
Installing graphic.h and Including Libraries
To use graphics.h in Dev-C++, follow these steps:
1. Download the required files:
o Get graphics.h, winbgim.h, and libbgi.a from a trusted source (commonly
from WinBGIm).
o These are needed to enable graphics support in Dev-C++.
2. Place the files correctly:
o Copy graphics.h and winbgim.h into the include folder of Dev-C++.
Example:
C:\Program Files (x86)\Dev-Cpp\MinGW64\include
o Copy libbgi.a into the lib folder of Dev-C++.
Example:
C:\Program Files (x86)\Dev-Cpp\MinGW64\lib
3. Configure Dev-C++ to link the graphics library:
o Go to Tools > Compiler Options.
o Under the "General" tab, check "Add the following commands when
calling the compiler".
o In the textbox, add the following:
-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
5
CHAPTER-4
CODE&OUTPUT
To Draw a line using user input Co-ordinates
#include <graphics.h>
#include <conio.h>
#include <iostream>
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, (char*)"");
int x1, y1, x2, y2;
std::cout << "Enter x1 and y1 (starting point): ";
std::cin >> x1 >> y1;
std::cout << "Enter x2 and y2 (ending point): ";
std::cin >> x2 >> y2;
line(x1, y1, x2, y2);
std::cout << "Press any key to exit...";
getch();
closegraph();
return 0;
}
6
Output:
7
CHAPTER-4
RESULTS
The implementation of the project successfully demonstrated the visual representation of
series and parallel electrical circuits using the graphics.h library in C. Through the use of
basic graphic functions, the program was able to draw circuit elements such as resistors and
wires clearly on the screen, following correct electrical configurations. In the series circuit,
resistors were displayed in a single straight line, symbolizing a single path for current flow.
In contrast, the parallel circuit was illustrated by placing resistors in separate branches
connected across the same two points, accurately representing multiple paths for current.
The diagrams were labeled appropriately, making it easy to identify the type of connection
and understand the layout of components.
The output graphics appeared on a graphical window, providing a clean and structured
interface for users to view the circuits. The program execution was smooth and stable, with
each element correctly positioned according to the coordinate logic. The visual output
aligned well with theoretical expectations, making it a valuable learning tool for
understanding the basic differences between series and parallel connections. This project
proved that even with a simple graphics library like graphics.h, effective and educational
simulations can be created to support the study of electronics through computer-based
visualization.
8
REFERENCES
Code With Harry. Graphics in C Language using graphics.h - Complete Tutorial
Series. YouTube. Available at:
https://www.youtube.com/playlist?list=PLqhLgomZ_RCMEdUG_lOv8ibTJ92sLbIDx.
Accessed on: May 22, 2025.
Sagar Ganiga. graphics.h for Windows (Turbo C/C++ Replacement). GitHub.
Available at: https://github.com/SagarGaniga/Graphics-Library/blob/master/graphics.h.
Accessed on: May 22, 2025.
SDL_bgi. A Graphics Library for C, C++, WebAssembly and Python. SourceForge.
Available at: https://sourceforge.net/projects/sdl-bgi/. Accessed on: May 22, 2025.
GameSpec. How to Add Graphics in Dev C++ (graphics.h Setup Guide).
GameSpec.tech. Available at: https://gamespec.tech/how-to-add-graphics-in-dev-c/.
Accessed on: May 22, 2025.