Show the same picture on all computers.

Hello,

Im trying to figure out how to code a program, that shows a picture. The only problem I have at the moment, is that the picture will only show on my computer, but not on others. Do you guys have any idea on how to fix that?
You'll have to give a little more information than that.
A program that opens a picture. But the only problem is that the program can only open the picture on my computer, because I already have the picture in some folder. I want it to open the picture on all computers even the ones that dont have the picture in a folder.

So I somehow want to know how to code the .jpeg inside the .exe, so when you open the .exe file it opens the same picture on all computers.
Have you considered putting the picture someplace where they all might see it, on an internet server for example? One computer might upload the image, and the others just download and display it.
the dumb way to do it (its horrible, but it will work without an image file of any sort anywhere) is to write a program that dumps the raw bytes of the image file into a legal constant vector of bytes that you can then display (or if jpeg, decode and then display). The image just becomes a very large constant data item in your program. Some types of images can be generated via an algorithm, like a background.

there are many other ways... you can store them in resources or dlls in windows, for example, or on a server, or you can install the image with the program in a folder in a relative path that the executable can find, for a few quick examples. Most games use a relative path to a known folder full of images or a 'wadfile' that has a bunch of images in one big file. Ever installed a game for 30 min?? Its copying video/images/sounds mostly. THe actual code part is usually relatively small.




Last edited on
Under windows you can embed files as resources.
http://www.winprog.org/tutorial/resources.html

Why don't you just distribute the pic together with the app ?
Windows is not special: you can embed data into binary elsewhere too.
One implementation: http://doc.qt.io/qt-5/resources.html

In order to render an image to display, its data must be accessible. You must transfer the image data to the computer somehow.
* Copy both image file and executable to destination
* Embed image data into the executable and copy executable to destination
* Copy executable to destination and let it copy image data during runtime from network accessible source
Windows is not special: you can embed data into binary elsewhere too.
One implementation: http://doc.qt.io/qt-5/resources.html


You refer to a rather huge framework.
Windows has this built in, not sure if Mac or Linux have it.
Thanks for all the answers :D
I will look into

* Embed image data into the executable and copy executable to destination.

* Copy executable to destination and let it copy image data during runtime from network accessible source.
your performance and user friendlyness will be improved if you use option 2 by
1) is the file there? if yes, use it, if not
2) get file from network.

if the file can change on the network, that becomes
1) can I connect? if no, use current if any, else fail nicely
2) if yes, does checksum match
3) if no, download latest, if yes, skip download

or something like that that avoids downloading all the time, handles the server or network being down if possible, etc.

option 1 is self contained, of course, but it makes a bloated executable ... too much of that leads to performance aggravations (page faults etc). One or two modest sized images won't hurt anything.
Last edited on
Topic archived. No new replies allowed.