SDL_Surface* GetBitmap(int resID)
{
SDL_Surface *image;
HMODULE ownModuleHandle = GetModuleHandle(NULL);
HRSRC hrsrc = FindResource(ownModuleHandle, MAKEINTRESOURCE(resID), RT_RCDATA);
DWORD size = SizeofResource(ownModuleHandle,hrsrc);
HGLOBAL hglob = LoadResource(ownModuleHandle,hrsrc);
void *buf = LockResource(hglob);
SDL_RWops *rw;
rw = SDL_RWFromMem(buf, size);
image = SDL_LoadBMP_RW(rw, 0);
SDL_FreeRW(rw);
return image;
}
SDL: Loading Image (bmp) from resource
I'm working with MS Visual Studio .NET 2003, and I made a new Visual Studio C++ Project (a empty win32 console project). SDL is working fine, and I'm getting my images at my screen, when I'm using the SDL_LoadBMP function.
Now I want to use Images I included in my resource-file, but it doesn't work that well.
I made this small function, to load an image out of a resource, but I still get a black screen, when I use it as a background. So it doesn't load the image, what am I doing wrong?
I did some checks after every step, and I noticed that i get the first error after
If I change the RT_RCDATA to RT_BITMAP, I only get an error after:
(It returns a NULL pointer)
Anyone got an idea?
Quote:
HRSRC hrsrc = FindResource(ownModuleHandle, MAKEINTRESOURCE(resID), RT_RCDATA);
If I change the RT_RCDATA to RT_BITMAP, I only get an error after:
Quote:
image = SDL_LoadBMP_RW(rw, 0);
(It returns a NULL pointer)
Anyone got an idea?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement