Sign in to follow this  

Easy Question

This topic is 4155 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've got a game which runs in 256(DIRECTX)color mode, which is'nt quite finished yet. But when Im running windows in 32bit(true color) the bitmap's color palette loads wrong (only a few colors), however it loads sweet as when running in 16bit mode. Is there a logical explanation for this?

Share this post


Link to post
Share on other sites
AFAIK there is no such thing as a color palette in 16/24/32 bit images.
What I did when I changed my 8 bit code to 32 bit was to skip and forget about the color palette all together.

The RGB macros is able to describe any 32 bit color, so there is no need to map speciffic colors to speciffic palette indexes.

Share this post


Link to post
Share on other sites
Quote:
Original post by pulpfist
AFAIK there is no such thing as a color palette in 16/24/32 bit images.
What I did when I changed my 8 bit code to 32 bit was to skip and forget about the color palette all together.

The RGB macros is able to describe any 32 bit color, so there is no need to map speciffic colors to speciffic palette indexes.


Windows is running in 32bit mode 1024*768, and when I start my game it initializes DirectX in 8bit mode 640*480. This is when some of the palette gets loaded wrong. It does happen in 16bit mode as well, only if I've just had a paint editor running.
I just don't want it to happen when its finished, you know...

Share this post


Link to post
Share on other sites
This must be a problem with the way you are initialising your palette. I never had a problem like this running 8-bit DDraw apps with windows in 32 bit mode.

Sounds to me (throwaway theory based on pure speculation) as if you are not initialising the palette properly, and you are getting "ghost" values from whatever was in your cards palette registers from before your program ran.

Could you post your palette loading code please.

Share this post


Link to post
Share on other sites
The code I'm usingt is out of Andre Le'moths Tricks for game programming gurus.
I'm just using his T3DXENGINE with his own palette loading code.
I't just loads the palette from the bitmap file;

FILE *fp_file;
if((fp_file = fopen(filename, "r"))==NULL)
return(0);

for(int index=0; index<256; index++)
{
fscanf(fp_file, "%d %d %d %d, &palette[index].peRed,
&palette[index].peGreen,
&palette[index].peBlue,
&palette[index].peFlags);
}
fclose(fp_file);

After this the palette is just set using primary set palette function.

Share this post


Link to post
Share on other sites
That code appears to be loading from a file containing nothing but a palette. The palette data in a bitmap file is located after the BITMAPHEADER information.

Are you sure Le'Mothe's example is supposed to be loading the palette from the bitmap directly? Some art editors let you export just the palette as a file in the format that code would work with.

Share this post


Link to post
Share on other sites
The following is pretty awful code I have slung together very quickly but should give you an idea of loading a palette from a .bmp file. I haven't tested it:


bool load_palette(const char *BmpFile)
{
FILE *fp=fopen(BmpFile,"rb"); if(!fp) return false;

BITMAPFILEHEADER Fh;
BITMAPINFOHEADER Ih;

fread(&Fh,sizeof(BITMAPFILEHEADER),1,fp);
fread(&Ih,sizeof(BITMAPINFOHEADER),1,fp);

if(Ih.biBitCount!=8){ fclose(fp); return false; }

fread(palette,sizeof(RGBQUAD),256,fp);
fclose(fp);

// do whatever with palette

return true;
}




This could, of course, be much improved by using C++ fstreams and making the error checking more robust.

HTH

Share this post


Link to post
Share on other sites

This topic is 4155 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this