Opening Image Files

I'm in my first year of programming so i'm not really that familiar with the whole c++ genre yet but i was wondering...

for my term project is it possible to have the user input a variable or something along those lines, and for an image to appear

so like would it be possible to have it in a different folder and for the user to input a variable and it would open it up or something.....like around those lines...hell i'm not sure thats why in asking :P

if so can someone post the code on how to do it, or give me a hint of some sort...

Much appreciated

pong
Last edited on
That's probably way over your head.

If you are using the console, you can do one of the following:

1. Open it in an external program (like MSPaint or Irfanview) using system() or the Win32 CreateProcess() or ShellExecute().

2. Draw it directly to the console window
http://www.daniweb.com/code/snippet217.html

3. You can cheat by creating a new window:
http://www.daniweb.com/code/snippet174.html
(this last one has the added advantage in that the example shows how to load a BMP file)

If you are using a GUI application builder of some sort, like C++Builder, Visual C++, Dev-C++, etc., then drop an image component on the form and load from file or resource.

Playing with image files is not easy (even for easy formats like BMP and TGA). I recommend you stick with BMP files as in the example under #3 above.

Hope this helps.
Topic archived. No new replies allowed.