Click here to Skip to main content
15,868,016 members
Articles / Programming Languages / TurboC++
Tip/Trick

C++ Graphics - Splash Screen

Rate me:
Please Sign up or sign in to vote.
4.30/5 (6 votes)
3 Nov 2014CPOL3 min read 33.8K   573   2   13
How create a Splash Screen in C++ Program (TurboC) in DOS Mode..

Source Code

Introduction

Article explains how to use C++ graphics.h header file to create a stunning splash screen for your Turbo C projects. 

Image 1

Background

This was mainly written for students those who learning C/C++ program and doing mini project with Turbo C / C++  compiler.  The graphic class library called  << graphics.h >> is used for creating this splash screen.

You need to make sure that the Turboc C complier with Graphics class librar "BGI" folder is installed.. Some Turboc installation dont have seperate BGI folder, but the library files will be completly copied to the TC directory..

To run this source code you need to make the linker options to use Graphics Library for compiling and linking..

 

Also you need to make sure that the graphics library path is added to the source code before running the code..

Image 2

Need to specify the path of BGI graphics library folder location in the below initgraphics function..   

initgraph(&gd,&gm,"C:\\tc\\bgi");

Using the code

 The splash window was created with rectangle and line function... The pop up window effect was created with the idea shown below...

Image 3

The two lines drawn are reversed to make the window popup effect..

After this, the Logo was drawn with the help of putpixel,setfillstyle,fillellipse,bar,lineto,moveto,floodfill graphics functions.

Below is a basic explanation of above functions..

PutPixel : putpixel(int x, int y, int color);

putpixel function plots a pixel at location (x, y) of specified color.

Setfillstyle:  setfillstyle( int pattern, int color);

Setfillstyle function sets the current fill pattern and fill color.

Fillellipsefillellipse(int x, int y, int xradius, int yradius);

x and y are coordinates of center of the ellipse, xradius and yradius are x and y radius of ellipse respectively.

Bar  bar(int left, int top, int right, int bottom);

Bar function is used to draw a 2-dimensional, rectangular filled in bar . Coordinates of left top and right bottom corner are required to draw the bar. Left specifies the X-coordinate of top left corner, top specifies the Y-coordinate of top left corner, right specifies the X-coordinate of right bottom corner, bottom specifies the Y-coordinate of right bottom corner.  

Moveto : moveto(int x, int y);

Moveto function changes the current position (CP) to (x, y)

Lineto : lineto(int x, int y);

lineto function draws a line from current position(CP) to the point(x,y), you can get current position using getx and gety function.

Eg: 

moveto(100,100); lineto(200,200);

Draws a line from point (100,100) to point (200,200).

floodfill : void floodfill(int x, int y, int border);

Floodfill function is used to fill an enclosed area. To change fill pattern and fill color use setfillstyle. 

Program Flow

The basic steps followed by the program is explained below..

Image 4

The left side of the logo head and top part was completed and for loop was used to copy the left part of the face to right side. Below shows the code section before "For" loop.

Image 5

The left side of the face was copied to the right side by for and while loop, then we will get a shape as shown below in the picture.

Image 6

Later after drawing the face completly its the time to use the setfillstyle and floodfill function to create color with the closed section.

After filling the closed we will get a picture as shwon below...

Image 7

After this splash screen you can clear graphics device and then draw the window or application you need.

 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 1 Pin
Alexandru Lungu8-Nov-14 13:18
professionalAlexandru Lungu8-Nov-14 13:18 
GeneralRe: My vote of 1 Pin
Ullas_Krishnan10-Nov-14 3:13
Ullas_Krishnan10-Nov-14 3:13 
QuestionLove it! Wrong day though. Pin
David Myerscough5-Nov-14 5:12
David Myerscough5-Nov-14 5:12 
AnswerRe: Love it! Wrong day though. Pin
Ullas_Krishnan6-Nov-14 6:46
Ullas_Krishnan6-Nov-14 6:46 
GeneralTurbo C???? Pin
sisira5-Nov-14 2:33
sisira5-Nov-14 2:33 
GeneralRe: Turbo C???? Pin
Ullas_Krishnan7-Nov-14 9:02
Ullas_Krishnan7-Nov-14 9:02 
GeneralMessage Closed Pin
4-Nov-14 2:08
neopolitan4-Nov-14 2:08 
GeneralRe: My vote of 1 Pin
Dave Cross4-Nov-14 3:33
professionalDave Cross4-Nov-14 3:33 
GeneralRe: My vote of 1 Pin
Ullas_Krishnan4-Nov-14 15:38
Ullas_Krishnan4-Nov-14 15:38 
GeneralRe: My vote of 1 Pin
Bartlomiej Filipek5-Nov-14 21:59
Bartlomiej Filipek5-Nov-14 21:59 
GeneralRe: My vote of 1 Pin
Ullas_Krishnan6-Nov-14 6:38
Ullas_Krishnan6-Nov-14 6:38 
GeneralRe: My vote of 1 Pin
Ullas_Krishnan6-Nov-14 6:48
Ullas_Krishnan6-Nov-14 6:48 
GeneralRe: My vote of 1 Pin
Ullas_Krishnan6-Nov-14 6:52
Ullas_Krishnan6-Nov-14 6:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.