Advertisement

Need help with palettes

Started by March 04, 2000 02:23 PM
-1 comments, last by Bleakcabal 24 years, 6 months ago
I am currently writing a 8bpp DirectDraw engine. Altough I am able to load and blit Bitmaps on the screen, the palette is always wrong. The problem is in the change palette function because calls to it don''t seem to work. Im pretty sure my load bitmap funcitons works. Here is the code in question, I woul appreciate any help or comments you may have. PALETTEENTRY palette[256]; LPDIRECTDRAWPALETTE lpddpal = NULL; LPDIRECTDRAW lpdd = NULL; LPDIRECTDRAWSURFACE lpddsprimary = NULL; LPDIRECTDRAWSURFACE lpddsback = NULL; LPDIRECTDRAWSURFACE lpddsbitmap = NULL; bool DD_ReplacePalette(LPPALETTEENTRY set_palette) { memcpy(palette, set_palette,256*sizeof(PALETTEENTRY)); if ((lpddpal->SetEntries(0,0,256,set_palette)) != DD_OK) return FALSE; return (TRUE); } Here is how I load the bitmap palette in my LoadBmp function fBitmapIN = fopen(BitmapName, "r"); fread(&bitmap->bitmapfileheader, sizeof(BITMAPFILEHEADER), 1, fBitmapIN); fread(&bitmap->bitmapinfoheader, sizeof(BITMAPINFOHEADER), 1, fBitmapIN); if (bitmap->bitmapinfoheader.biBitCount == 8) // 8 bpp, 256 couleurs { fread(&bitmap->palette, 256*sizeof(PALETTEENTRY), 1, fBitmapIN); for (int index = 0; index < 256; index++) { int temp_color = bitmap->palette[index].peRed; bitmap->palette[index].peRed = bitmap->palette[index].peBlue; bitmap->palette[index].peBlue = temp_color; bitmap->palette[index].peFlags = PC_NOCOLLAPSE; } } //if ((DD_ReplacePalette(bitmap->palette)) != TRUE) // return (9); lpdd->CreatePalette(DDPCAPS_8BIT, bitmap->palette, &lpddpal, NULL); lpddsbitmap->SetPalette(lpddpal); lpddsprimary->SetPalette(lpddpal); lpddsback->SetPalette(lpddpal); To make sure this part of my funciton wasnt the problem I also tried using the function in ddutils.cpp ( as someone on this board suggested me ) to load the palette and the result was the same. Calls to change the palette alone weren''t succesful, altough no errors were reported.
WHO DO THEYTHINK THEY'REFOOLING : YOU ?

This topic is closed to new replies.

Advertisement