You could look at some existing code in libraries that read BMP files. The source for SDL_LoadBMP() comes to mind. SDL_LoadBMP() is #defined as a call to SDL_LoadBMP_RW(). The source for it is available here: http://www.google.com/codesearch?hl=...DL_bmp.c#first
Of course, I'm not sure how portable the SDL BMP loading code is, though I should imagine it's pretty good.

