? about SDL file functions

hiya,

…I’m still hacking together a PSD importer: in the engine that I’m
porting, there is code to do this, but the file opening functions are
Window$:

 HANDLE File =  

CreateFile(FileName,GENERIC_READ,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL
,0);
assert(File != INVALID_HANDLE_VALUE);
HANDLE FileMap = CreateFileMapping(File,0,PAGE_READONLY,0,0,0);
assert(FileMap != INVALID_HANDLE_VALUE);
void *FileData = MapViewOfFile(FileMap,FILE_MAP_READ,0,0,0);

 assert(FileData);
 uint8 *FileBytes = (uint8 *)FileData;

…I’ve been trying to use the SDL_RWops stuff, but without much luck:

 SDL_RWops *FileData = SDL_RWFromFile( FileName, "rb");
 uint8 *FileBytes = (uint8*)FileData->hidden.stdio.fp;

     if(FileBytes[0] == '8' && FileBytes[1] == 'B' &&
        FileBytes[2] == 'P' && FileBytes[3] == 'S')
     {
         // it's a Photoshop PSD file
         PSDFile *Psd = (PSDFile *)FileBytes;

         uint32 Width = SDL_SwapBE32(Psd->Columns);
         uint32 Height = SDL_SwapBE32(Psd->Rows);
         assert(SDL_SwapBE16(Psd->Version) == 1);
         assert(SDL_SwapBE16(Psd->Depth) == 8);
         assert(Channel < SDL_SwapBE16(Psd->Channels));

…anyone have some pointers on how to go about this?

thanks,
jamie
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: text/enriched
Size: 2523 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20030509/5855bb95/attachment.bin

…anyone have some pointers on how to go about this?

Take a look at the source code to SDL_image - it does what you want.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment