int LoadBackgd()
{
RECT fill_area;
RECT source_rect;
DDBLTFX ddbltfx;
//DD_Create_Surface(SCREEN_WIDTH, SCREEN_HEIGHT, DDSCAPS_SYSTEMMEMORY);
Load_Bitmap_File(&bitmap8bit, "glassbg.bmp");
// set the palette to background image palette
Set_Palette(bitmap8bit.palette);
/*
Create_Bitmap(&background_bmp, 0, 0, 640, 480);
Load_Image_Bitmap(&background_bmp,&bitmap8bit,0,0,BITMAP_EXTRACT_MODE_ABS);
*/
memset(&ddsd,0,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
DD_Lock_Back_Surface();
memcpy(back_buffer, bitmap8bit.buffer, SCREEN_WIDTH*SCREEN_HEIGHT);
DD_Unlock_Back_Surface();
/*
Draw_Bitmap(&background_bmp, back_buffer, back_lpitch, 1);
*/
source_rect.top = 0;
source_rect.left = 0;
source_rect.bottom = SCREEN_HEIGHT;
source_rect.right = SCREEN_WIDTH;
// fill in the destination rectangle data (your data)
fill_area.top = 0;
fill_area.left = 0;
fill_area.bottom = SCREEN_HEIGHT;
fill_area.right = SCREEN_WIDTH;
// set color key to color 0
DDCOLORKEY color_key; // used to set color key
color_key.dwColorSpaceLowValue = 0;
color_key.dwColorSpaceHighValue = 0;
// now set the color key for source blitting
lpDDSBack->SetColorKey(DDCKEY_SRCBLT, &color_key);
// ready to blt to surface, in this case blt to primary
lpDDSPrimary->Blt(&fill_area, // ptr to dest rectangle
lpDDSBack, // ptr to source surface, NA
&source_rect, // ptr to source rectangle, NA
DDBLT_KEYSRC | DDBLT_WAIT, // fill and wait
&ddbltfx); // ptr to DDBLTFX structure
Unload_Bitmap_File(&bitmap8bit);
return(1);
}
loading a background bitmap
i was wondering if any of u who tried to load a bitmap as a
background image can help mi. i got some concept below but i
dunno whats wrong, the image is just a BLUE screen!
am i missing something?
i am using oso those functions u see above provided by the Dummies book.
[edited by - edwinnie on April 15, 2002 4:41:11 AM]
[edited by - edwinnie on April 15, 2002 5:02:48 AM]
[edited by - edwinnie on April 15, 2002 5:15:30 AM]
[edited by - edwinnie on April 15, 2002 7:18:28 AM]
[edited by - edwinnie on April 15, 2002 7:23:07 AM]
[edited by - edwinnie on April 15, 2002 7:42:09 AM]
the code above has some being in comment mode.
basically what i did was to try out different possible combinations of code, only using those above.
furthermore, the functions above was provided by the Dummmies book.
what i did was to 1) create an offscreen surface
2) load bitmap
3) lock , bilt, unlock
4) unload
basically what i did was to try out different possible combinations of code, only using those above.
furthermore, the functions above was provided by the Dummmies book.
what i did was to 1) create an offscreen surface
2) load bitmap
3) lock , bilt, unlock
4) unload
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement