Using FreeImage library for loading image in memory

In this article I am going to discuss how to use FreeImage on Ubuntu. FreeImage provides the convenient way to load various graphics image formats like PNG, BMP, JPEG, TIFF and others as needed by multimedia applications. Free Image can be used on various platforms like Linux, NetBSD, Windows, Mac OS X, Symbian etc. FreeImage is easy to use, fast, multithreading safe. FreeImage can be used in an image editor, visual tool, games or anywhere you need a bitmap.
You can install this utility libary on you Ubuntu by just giving a simple command while you are connected to the Internet. This command would install the Freeimage and its all dependencies. You need to just type following on terminal window.

sudo apt-get install libfreeimage3

If you are not on the Ubuntu. You can get the FreeImage install by compiling the source. You can the source from FreeImage offical website You can compile the source by following the following steps:

1. Extract the archive file on your desired location.
2. Open the terminal and change the present working directory to the the extracted source directory.
3. Now type following commands:

make install

After getting FreeImage installed let’s created HelloWorld program. Create a new HelloWorld.c as follows:


int main(void){

	printf("FreeImage Version : %sn",FreeImage_GetVersion());
	printf("Copyright Message : %sn",FreeImage_GetCopyrightMessage());

	FIBITMAP *bitmap = FreeImage_Load(FIF_JPEG,"img.jpg",JPEG_DEFAULT);

		printf("Bitmap loaded successfully.n");
		printf("Bitmap could't be loaded.n");

return 0;

You can compile the above source using gcc compiler by giving the following command on terminal:

gcc -o HelloWorld HelloWorld.c -lfreeimage