Archived

This topic is now archived and is closed to further replies.

Sir_Spritely

TOTWGPG loading bitmaps with library modules

Recommended Posts

Hey, Does anyone have some example code or know exactly which functions to include so you can load up a bitmap 8bit using the library modules created in the above book? I can create then as a stand alone but when I come to use the graphics library created I can''t suss out how to do it Any help appreciated! Pk

Share this post


Link to post
Share on other sites
I can''t really be of much help cos i''ve misplaced my cd for the book but i''d guess that all you have to do is include the header file for the library that contains the bitmap function and tell Visual Studio to use the .lib file.

If you could create the functions alone i''m not sure what the problem is when they''re burried in a library file.

zipless

/* Ignorance is bliss, then you go and spoil it by learning stuff */

Share this post


Link to post
Share on other sites
Hi, if you don't want to write your own loader routines (or copy Lamothe's), use windows gdi-functions (I know they're supposed to be slow, but you won't be reading from files in your inner loops, will you?)

    
LPDIRECTDRAWSURFACE7 create_surface(int width, int height, int trans_col, DWORD memflags) {
LPDIRECTDRAWSURFACE7 temp;
DDRAW_INIT_STRUCT(ddsd); //macro from TOTWGPG

ddsd.dwFlags=DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT;
ddsd.dwWidth=width;
ddsd.dwHeight=height;
ddsd.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN|memflags;
lpdd->CreateSurface(&ddsd, &temp, 0); //LPDIRECTDRAW7

DDCOLORKEY color;
color.dwColorSpaceHighValue=trans_col;
color.dwColorSpaceLowValue=trans_col;
temp->SetColorKey(DDCKEY_SRCBLT, &color);
return temp;
}

LPDIRECTDRAWSURFACE7 load_bmp(char *name, LPRECT area, int trans_col, DWORD memflags) {

LPDIRECTDRAWSURFACE7 temp;
HBITMAP hBMP;
BITMAP bmp;
HDC xdc, hdc=0;
hBMP = (HBITMAP)LoadImage( 0, name, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE );
hdc=CreateCompatibleDC(0);
SelectObject(hdc, hBMP);
GetObject( hBMP, sizeof(bmp), &bmp );
if (area!=0) {
area->top=0;
area->left=0;
area->bottom=bmp.bmHeight-1;
area->right=bmp.bmWidth-1;
}
temp=create_surface(bmp.bmWidth, bmp.bmHeight, trans_col, memflags);
temp->GetDC(&xdc);
BitBlt(xdc, 0, 0, bmp.bmWidth, bmp.bmHeight, hdc, 0, 0, SRCCOPY);
temp->ReleaseDC(xdc);
ReleaseDC(0, hdc);
return temp;
}


Like this...

------------------------------------------------------------
"To a computer, chaos is just another kind of order."

Edited by - Profus on January 30, 2002 11:48:31 AM

Share this post


Link to post
Share on other sites
hi, u can include t3dlib1.cpp | .h this with ddraw functions
and other tools O.K , and if u want to load a BOB "sprite"
DO this
BOB ahmed;
Ok and in GAME_INIT()
init the bob
by load a file LOOK in THE BOOK on this page 528
ok this page help u to make a sprite and draw it and animate it ok.
and See the Examples
bye bye
Ahmed Saleh


Share this post


Link to post
Share on other sites