Archived

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

hats off to anyone who can get my fade to work

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

Recommended Posts

Why will my fade to black not work correctly? Here is my fade Function: void fade() { PALETTEENTRY pe[COLORS]; lpPrimaryPalette->GetEntries(NULL, 0, COLORS, pe); for(int n = 0; n < 256; n++) { for(int i = 0; i < COLORS; i++) { if(pe.peRed > 0) pe[i].peRed--; if(pe[i].peGreen > 0) pe[i].peGreen--; if(pe[i].peBlue > 0) pe[i].peBlue--; } Sleep(1); lpPrimaryPalette->SetEntries(NULL, 0, COLORS, pe); } } Here is my palette initialization: LPDIRECTDRAWPALETTE CreatePalette(LPDIRECTDRAWSURFACE surface){ //create surface palette PALETTEENTRY pe[COLORS]; //new palette LPDIRECTDRAWPALETTE lpDDPalette; //direct draw palette //construct pe[], set to black for(int i=0; i CreatePalette(DDPCAPS_8BIT,pe,&lpDDPalette,NULL))) return NULL; //load direct draw palette to surface surface->SetPalette(lpDDPalette); return lpDDPalette; } //CreatePalette Every thing fades to black as it is supposed to, accept for white! I have tried everything, and can''t figure it out. It wont fade the 265th color in the palette. download this image if you want, and notice how the white line wont fade with this code. Hats off to anyone who can figure out why, it has taken 2 months and no solution yet. http://members.tripod.com/ctrl_alt_del1/picture.bmp

Share on other sites
Have you tried with inserting to the first if(pe.peRed > 0) ?

Share on other sites
  if(pe[i].peRed > 0)

Share on other sites
Yes, I have tried doing that, it looks like the forum took it as some sort of HTMl tag and turned the rest of my post to italics.

Share on other sites
First, make sure you''ve got the number of colors correct. If you''re using a 256 color pallete... I think you want colors to be 256. Also, try to find exactly where in the array white is, then start doing value testing. Put in some break points and step through, checking values.

Though I doubt it, white may be unsigned {255, 255, 255} which might translate to signed { -1, -1, -1 } depending on what type of variables the pallete entry are, and whether everything is being compared correctly. Anyway, hope this helps.

Share on other sites
Thanks warden, I took your suggestions, and this is what I found out. If a paint a fusha(sp?) line in my bitmap, which is in slot #265 in the array, it will show up white on the computer screen. All of the other colors are right. This white line will than not fade. (even though it is not white, it is fusha). I don''t if this will give anyone any ideas, but it might help. I appreciate the responses.

Share on other sites
And it does help.

I don''t remember the actual call flags, but when initializing the palette with Direct Draw, there is a flag you have to specify to use ALL 256 colors. If its not specified, Direct Draw will reserved spots for black and white colors.

I only have the SDK v8 so I don''t know the flags, but I ran into this problem before..

Share on other sites
Thanks Sphet, that did the trick. It now works correctly!! In case anyone wants to know the correct flag is DDPCAPS_ALLOW256.
Later,
CTRL_ALT_DELETE

• 34
• 12
• 10
• 9
• 9
• Forum Statistics

• Total Topics
631355
• Total Posts
2999520
×