How to input Png into application

Is there any way to input a picture into an application? I want to make the console of my C++ program display an image across it for a short while. The picture in mind is a gif. If there is no way to make it display in the console, is there a way to make only the image and not the webpage pop up on the screen?

If you're wondering what I'm trying to do, I am trying to replicate the Skyfall "M gets hacked" scene. But this would be useful for other purposes as well.

BTW: I am not familiar with using header files or any other files other than the .cpp file and I only use one .cpp file for all my programs.
closed account (Dy7SLyTq)
just write a terminal emulator
I can see multiple ways of doing this.

1) Make the console start the image file with the default image viewer by running an ms-dos command using the system() function. Horrible idea.

2) Make a program using a graphics library such as SDL or SFML which simply loads the picture. You can also make it show stuff in the console, or use a batch file to write to console and start this picture display. But since you're beginning C++, that's most likely out of the question.

3) Make a program which writes in colors inside the console using the windows API and read the picture pixel per pixel to draw it out of characters in the console. You'dd either need to look at image encoding and how gif or bmp works, or use a graphics library. And the image would look horrible, it's not what you want.

Since I've been of no help, let me teach you about files in c++ and how to use more than one.

The first file which is compiled is the one containing the main() function. The name of the file doesn't matter. People often call it main.cpp, while others prefer giving it the name of the program/project. When you write #include "file.h", the compiler reads all the content of file.h, then looks for file.cpp and if it exists, reads the the content of file.cpp before returning to the main file.

To avoid problems if a file gets included by multiple files, you should always surround your .h files with this

1
2
3
4
5
6
7
#pragma once
#ifndef NAME_OF_THE_FILE_H
#define NAME_OF_THE_FILE_H

// code goes here

#endif // NAME_OF_THE_FILE_H 


and the cpp files should include only one h file
#include "file.h"
you could also enclose the .cpp content with what I gave for the .h file but replacing the H at the end with CPP. You can search online to figure out how it works, but basically it prevents a file from being included twice.
There's a very lightweight loader called libPNG as well.
DTSCode: I don't know what a terminal emulator is.

Pivottt: Now that I know how to use header files and .cpp files, how do I use that knowledge to input a gif into a program?

Duoas: Most of those links on the link you offered are stale or deleted and have no info about what I'm trying to learn.

I still don't know how to attach a .gif into my program and have it display either in the console or appear on my screen without being attached to a window like chrome or firefox.
closed account (N36fSL3A)
Pivottt: Now that I know how to use header files and .cpp files, how do I use that knowledge to input a gif into a program?
Well it really has close to nothing to do with it.

That being said, I highly recommend you to stop using .gif files and to use a .bmp file since you're new to binary files.

http://www.cplusplus.com/articles/GwvU7k9E/ is a nice article I wrote.

After that you'll need some way to display it. That's up to you. There, I use OpenGL to generate a texture.
Sorry, didn't know Daniweb would do that. Here's the link you need.
http://www.daniweb.com/software-development/c/code/216431/put-a-bitmap-image-on-your-console-c

Draws a picture directly to the console DC.
Topic archived. No new replies allowed.