The resource will not have a file name as such as it is included in your exe (and makes it bigger).
If you have a lot of image/sound resources becareful not to make your exe too big (and hard to distribute).
You could always write the resource data to a temp file and send to your image loader as required. Remembering that file I/O is _much_ slower than memory I/O.
>>I'm using image loading functions from SDL,
Why? Why not use LoadImage()
//load a bitmap
hImage=LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_IMAGE1), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
If you have to use PGN try GDI+
Look here,
http://msdn.microsoft.com/library/de...nddecoders.asp
This is some code I have hacked together from MSDN examples, don't expect it to WORK....
Code:
#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;
int WriteResourceAsPGN(int iResourceID,char *szFullFileName)
{
// Initialize GDI+.
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
//load image from resource
HBITMAP hImage=LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(iResourceID), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
CLSID encoderClsid;
Status stat;
Image* image = new Image(hImage);
// Get the CLSID of the PNG encoder.
GetEncoderClsid(L"image/png", &encoderClsid);
stat = image->Save(szFullFileName, &encoderClsid, NULL);
if(stat == Ok)
//success
else
//Failure
//Clean UP
delete image;
GdiplusShutdown(gdiplusToken);
return 0;
}
int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
{
UINT num = 0; // number of image encoders
UINT size = 0; // size of the image encoder array in bytes
ImageCodecInfo* pImageCodecInfo = NULL;
GetImageEncodersSize(&num, &size);
if(size == 0)
return -1; // Failure
pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
if(pImageCodecInfo == NULL)
return -1; // Failure
GetImageEncoders(num, size, pImageCodecInfo);
for(UINT j = 0; j < num; ++j)
{
if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
{
*pClsid = pImageCodecInfo[j].Clsid;
free(pImageCodecInfo);
return j; // Success
}
}
free(pImageCodecInfo);
return -1; // Failure
}