Hello friends today we will learn how to insert images in C++ language very easily using graphics. The things that are required for this work are listed here .....
1.Code blocks compiler installed on your system:
Code::Blocks is a free, open-source cross-platform IDE that supports multiple compilers including GCC, Clang and Visual C++. It is developed in C++ using wxWidgets as the GUI toolkit. Using a plugin architecture, its capabilities and features are defined by the provided plugins. Currently, Code::Blocks is oriented towards C, C++, and Fortran. It has a custom build system and optional Make support.(by wikipedia).
2.Graphics libraries should set up with code blocks:
When we install code blocks then there is no library and header file of graphics are given by the developers with it, so we have to configure these things manually.I come across a lots of videos on youtube to configure graphics in codeblocks and i found all the videos are just waste of time except one video and i learnt from that video .It was a bit difficult for me to configure graphics in codeblocks.
This is why because i was getting the libraries and header file with bug.
If you did these two things then you can use this program or concept to insert images in C++ language using graphics in Codeblocks.
Here we go:
#include<iostream>
#include<graphics.h>
int main()
{
initwindow(600,400,"Images");
readimagefile("image_name.jpg",0,0,600,400);
getch();
readimagefile("image_name.jpg",0,0,600,400);
getch();
return 0;
}
Description of the program:
If you are using code blocks to make programs in graphics mode then we can make the programs in only C++ because in the graphics.h header file there is reference to iostream and if we work in C language then it will not link and then we get error in header file graphics.h. Download File
here we have used the two important predefinded functions of graphics they are....
- initwindow():this function is used to initialise a new window or you can say a new window
- readimagefile():this is the function that is used to set images in our program.
readimagefile() takes five parameters the first parameter is the name of the image with extension of the image and the rest are the co-ordinates of the screen where to set.
Thanks for visiting ...we will come with new typical programs so stay connected.