Board index » cppbuilder » DirectDraw Palette error
Choykw
![]() CBuilder Developer |
DirectDraw Palette error2005-08-09 06:09:10 PM cppbuilder70 Hi all, I'm writing a direct draw app, using 256 color mode, since I needed some color animation. however, when I used the following code to get the palette: lpddpal = DDLoadPalette(lpdd, "Houses.bmp"); lpddsfront->SetPalette(lpddpal); The palette will be wrong - the color became all purple-ish. It used to work correctly back when I first created the code (on the same machine) a year ago (it had been put aside due to work schedule, and I now have time to resume the app). The color animation effect is working correctly. (with wrong coloring though) So I changed to the following code to get the correct palette. The graphics look exactly how it should - with the correct palette. BMP *pal = new BMP; pal->LoadFromFile("Houses.bmp"); lpdd->CreatePalette(DDPCAPS_8BIT, (PALET{*word*249}TRY *)pal->Palette, &lpddpal, NULL); lpddsfront->SetPalette(lpddpal); delete pal; but I'm having problem with this palette when I try to access the palette entries via lpddpal->GetEntries() and SetEntries(). It generated some sort of Exceptions when executed. The Set/GetEntries are not giving any problem if I used the first method (DDLoadPalette()) which is from the ddutil.c in the samples come with C++Builder 6. I've checked, the flags used to create the palette is exactly the same. I've also tried to include the DDPCAPS_ALLOW256 | DDPCAPS_INITIALIZE flags and they are not helping. I have no idea what exception was generated, since I'm running in full screen, exclusive mode. It is pointless to convert the app to windowed mode since it have to be 256 color mode, or I'll have to chang quite a bit of the code - and eliminating 256 color mode along the change. Can anyone help me here? Why is the palette color suddenly changed? it used to be perfectly okay one year ago when I used the same hardware (but I may be using C++Builder 3 back then, I can't remember quite clear). Thanks in advance. Regards. |