Skip to main content
gamedev.net
🔒 Locked

bitmaps

Started by BlackHwk4 3 replies 700+ views
Original Post
BlackHwk4
BlackHwk4
When I load in a 640x480 bitmap using the load bitmap functions that came with Windows Game Programming for Dummies it looks messed up. The 16 bit bitmap has mostly green colors all over and the 8 bit one has black spots all over it when I run the program. When I learn how to blit will it fix this or is it just something wrong with LaMothe''s load bitmap function? Thanks.
BlackHwk4
BlackHwk4
For the 8 bit picture here is what the palette looks like:

// these are up at the top as globals
LPDIRECTDRAWPALETTE lpddpal = NULL;
PALETTEENTRY palette[256];
// this is something that is used with the load bitmap function
BITMAP_FILE bitmap;

memset(palette,0,256*sizeof(PALETTEENTRY));

// create a R,G,B,GR gradient palette
for (int index=0; index<256; index++)
{
// set flags
palette[index].peFlags = PC_NOCOLLAPSE;
} // end for index

// now create the palette object
if (lpdd->CreatePalette(DDPCAPS_8BIT | DDPCAPS_INITIALIZE | DDPCAPS_ALLOW256,
palette,&lpddpal,NULL)!=DD_OK)
return(0);

// attach the palette to the primary
if (lpddsprimary->SetPalette(lpddpal)!=DD_OK)
return(0);

// now load the 8 bit color bitmap
// Load_Bitmap_File is the bitmap loader function that came with the book
Load_Bitmap_File(&bitmap, "ANDRE8.BMP");

// now load the palette into the directdraw
lpddpal->SetEntries(0,0,256,bitmap.palette);

And for the color keying I have this:

DDCOLORKEY col_key;
col_key.dwColorSpaceLowValue = 0;
col_key.dwColorSpaceHighValue = 0;

Can you tell if it's the palette that's messed up from this code? Also the black spots on the image go to different places everytime I run the program. Thanks for any help.

Edited by - BlackHwk4 on April 11, 2001 4:07:06 PM
patrickselley
patrickselley
Maybe you haven''t created the palette correctly. Look on page 183. It looks like you''re only setting the flags, but not actually creating the colors for the palette. I dunno, since I''m not much further than you are Actually, if you wanna nit pick, I''m not as far as you are. But I think I have an idea of what I"m talking about. I think ^_^

NULL
BlackHwk4
BlackHwk4
Thanks it worked! I copied and pasted the code from .cpp file on the CD and I guess LaMothe forgot to put those in and I didn''t notice.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.