Is it possible to have a piece of C++ code display a picture and how? I want to display something for my Uncle's employees at a conference were holding with them and I don't know how to display pictures, if there is a way.

Recommended Answers

All 7 Replies

Are you talking about just displaying a picture any way that works, or actually rendering the picture using C++? The former is vastly simpler; you can just start the process of a picture viewer and pass in the location of the picture to open it. The latter is quite a bit harder and not recommended.

@deceptikon Ok, thank you. That is all I needed to know.

Though, one extra question. How would I display a picture that is located on my, for example, desktop? Is it using the cout object by putting the root source of the file?

Do you want to change the wallpaper on the computer? Here is a code snippet. that works for Windows os.

One way of doing this is using the function system from the header windows.h if you're using Windows.

#include <windows.h>
#include <string>
using namespace std;

int main(){
    string pathOfWindowsPhotoViewer="%SystemRoot%\\System32\\rundll32.exe \"%ProgramFiles%\\Windows Photo Viewer\\PhotoViewer.dll\", ImageView_Fullscreen ";
    string pathOfPicture="C:\\Users\\Public\\Pictures\\Sample Pictures\\Koala.jpg";
    system(string("start "+pathOfWindowsPhotoViewer+pathOfPicture).c_str());
    return 0;
}

i need computer programming code picture for my work

i need computer programming code picture for my work

Do you regularly ask other people to do your work? If so, I'm greatly relieved that you're not one of my coworkers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.