If it is only Windows, use a special resource. If you want something cross-platform, then do what I did for a recent project - create an application that will encode JPEG as a char* buffer in the header file, and then include these headers in your main project. You will also need to save the size of the buffer, as it will necessarily contain NUL.
For example, I have an application that you can transfer file downloads for encoding, and for each file you get a header file that looks something like this:
#ifndef RESOURCE_SOMEFILE_JPG_HPP #define RESOURCE_SOMEFILE_JPG_HPP namespace resource { const char* SOMEFILE_JPG[] = { ...raw jpeg data... }; const int SOMEFILE_JPG_LEN = 1234; }
An application should avoid special characters that cannot be printed in the \x format, but this is pretty simple. The application uses the boost::program_options library, so the list of encoding files can be saved in the configuration file. Each file has its own header, similar to the one above.
However, be warned - this only works for small files, as some compilers have a limit on the maximum size, which can be a static char buffer. I'm sure there are other ways to do this, but this scheme works for me (a C ++ web application that stores HTML, CSS, JavaScript and image files this way).
Rob
source share