when i run my program it displays about the top half of the image and the bottom half is garbage. it also displays the wrong colors course and i dont know why?also when i save my image as 256 color the program crashes but when i save it as 24bit it just does what i said above.

typedef struct BITMAP_FILE_TAG { BITMAPFILEHEADER bitmapfileheader; // this contains the bitmapfile header BITMAPINFOHEADER bitmapinfoheader; // this is all the info including the palette PALETTEENTRY palette[256]; // we will store the palette here UCHAR *buffer; // this is a pointer to the data

LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam){// this is the main message handler of the systemPAINTSTRUCT ps; // used in WM_PAINTHDC hdc; // handle to a device context

// save the window handle in a globalmain_window_handle = hwnd;ginit();// enter main event loopwhile(1) { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { // test if this is a quit if (msg.message == WM_QUIT) break;

// translate any accelerator keys TranslateMessage(&msg);

// send the message to the window proc DispatchMessage(&msg); } // end if gmain(); // main game processing goes here

} // end whilegshutdown();// return to Windows like thisreturn(msg.wParam);}

int ginit(void *parms){

// this function is where you do all the initialization // for your game