ebyard wrote:
Hi Folks
Does anyone know of a way to include texture/image data in a program, so
that you don’t have to load from a file? I’d like to be able to display
an image on screen as soon as the SDL windows are created, without
having to load my (large) texture file in first?
Thanks
Ed_______________________________________________
SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
This is expressly what the image format “xpm” is for.
Basically you can edit your image however you like, save it in XPM format,
and in your sourcefile, you can #include it like any other file and use
it.
Example,
#include “Play.xpm”
If you look in Play.xpm (The saved result varies by editor, and can be
modified easily):
/* XPM */
static char *play_xpm[] = {
“15 15 256 3”,
“000 c black”,
“001 c #040404”,
“002 c Gray3”,
“003 c #0C0C0C”,
“004 c #101010”,
“005 c Gray8”,
“006 c #181818”,
“007 c #202020”,
“008 c Gray14”,
“009 c #282828”,
“010 c Gray19”,
“011 c #484848”,
“012 c #505050”,
“013 c #585858”,
“014 c #606060”,
“015 c #646464”,
“016 c Gray47”,
“017 c #909090”,
“018 c #989898”,
“019 c Gray61”,
“020 c #A0A0A0”,
“021 c #A4A4A4”,
“022 c #C0C0C0”,
“023 c Gray80”,
“024 c #E4E4E4”,
“025 c Gray94”,
“026 c #F8F8F8”,
“027 c None”,
“027027027027027027027027027027027027027027027”,
“027019023027027027027027027027027027027027027”,
“027017001014024027027027027027027027027027027”,
“027024000000002016025027027027027027027027027”,
“027027011001000000004017026027027027027027027”,
“027027019012002000000000008021027027027027027”,
“027027024015013010005003001000010022027027027”,
“027027027018011009007004001000000006020027027”,
“027027024015013010005003000000010022027027027”,
“027027019012002000000000008021027027027027027”,
“027027011001000000004017026027027027027027027”,
“027024000000002016025027027027027027027027027”,
“027017001014024027027027027027027027027027027”,
“027019023027027027027027027027027027027027027”,
“027027027027027027027027027027027027027027027”
};
A useful link:
http://www.libsdl.org/projects/SDL_image/docs/SDL_image_28.html#SEC28