Using images from executable resources


I’m using SDL 1.2 and Windows.
I’m searching for the way to build images in my game into executable. Sadly, I haven’t found how to use this images in the SDL functions.
Inded, I found a part of the solution, but it involved monstrouos code with low-level copying of image data from HBITMAP structure to SDLSurface.
So, is there some elegant way t do this, perhaps using any library or undocumented functions?


What I do is that I save the resource as a RC data instead of a bitmap, as doing so will remove the bitmap header, which causes Load_RW to read nothing but garbage. Adding it as a RC data resource instead of a bitmap fixes this problem. I then use the window library to recieve the data as an array of data which I then passes to Load_RW. Here’s the function I use:

TEXPTR CFilesystem::LoadTextureFromResource(LPCWSTR resname)
	SDL_Surface * bitmapSurface = NULL;

	TEXPTR rtexture = NULL;
	HRSRC resPos = NULL;
	DWORD resLenght = NULL;
	LPVOID resStream = NULL;
	SDL_RWops * memdat = NULL;

	ins = GetModuleHandle(0);
	resPos = FindResource(ins, resname, RT_RCDATA); 
	res = LoadResource(ins, resPos);
	resStream = LockResource(res); 
	resLenght = SizeofResource(ins, resPos);

	memdat = SDL_RWFromConstMem(resStream, resLenght);

	if((bitmapSurface = IMG_Load_RW(memdat, 0))==NULL)
		MessageBoxA(NULL, SDL_GetError(), "ERROR", NULL);

	rtexture = ConvertSurfaceToTexture(bitmapSurface);
	Textures[resname] = rtexture;

	return rtexture;