Originally Posted by
redruby147
I've been using gtk and was wondering how images are put into executables so that it's self contained rather than referencing an image from a different location.
You can but it is not very advantageous for a few reasons:
1) it can drastically increase your executable size.
2) if you are going to use a compressed format, such as a jpeg, you will need to write some custom routines to both rip the jpeg data into your code, then to deal with it there.
Have a look at an .xpm file (just open it in a text editor -- xpm images are actually C code). This will give you some idea of what putting image data into your code will involve.
It is just not a worthwhile thing to do -- it is much more practical to load a file, unless for some reason you want to thoroughly hide the image from the world (which is pointless, it can be gotten with a screenshot).
Code:
/* XPM */
static char *Toaster[] = {
/* columns rows colors chars-per-pixel */
"48 48 90 1",
" c #020202",
". c #0C0C0C",
"X c #141414",
"o c #181916",
"O c #151518",
"+ c #1B1B1C",
"@ c #1F201E",
ad nauseum