hi, below is some code i wrote to load a TGA file stored as a windows resource. Note that the resource name has to be called using the MAKEINTRESOURCE macro and that this only works for 16bit non-compressed targa files stored using a custom resource type called "TGA".
- Code:
//
// FUNCTION: moveGetRawResourcePointer()
//
// PURPOSE: Returns a pointer to a TGA file in the resource file.
//
// COMMENTS:
//
// Returns a pointer to a TGA file in the resource file. Note that the memory
// taken by the LoadResource function has to be freed by the calling function.
//
unsigned short * moveGetRawResourcePointer( LPCTSTR lpResourceName )
{
// Find the resource in this module.
HRSRC hRsrc = FindResource( GetModuleHandle(NULL), lpResourceName, TEXT("TGA") );
if( hRsrc == NULL )
return NULL;
// Load the resource into memory and get a pointer to the memory location.
HGLOBAL hGlobal = LoadResource( GetModuleHandle(NULL), hRsrc );
if( hGlobal == NULL )
return NULL;
// Now skip the header bytes.
return (unsigned short *)hGlobal+9;
}
cryo