|
Animating a Palette
The following example animates a palette by using the DrawDibRealize, DrawDibChangePalette, and DrawDibDraw functions.
You can change the colors of a bitmap by using the DrawDibBegin function in combination with DrawDibChangePalette. First, to allow palette changes, specify the DDF_ANIMATE flag in the call to DrawDibBegin. Second, set the color table values from the palette entries by using DrawDibChangePalette.
For example, if lppe is an address of the PALETTEENTRY array containing the new colors, and lpbi is the LPBITMAPINFOHEADER structure used in DrawDibBegin or DrawDibDraw, the following fragment updates the DIB color table.
hdc = GetDC(hwnd);
DrawDibBegin(hdd, ....., DDF_ANIMATE);
DrawDibRealize(hdd, hdc, fBackground);
DrawDibDraw(hdd, hdc, ...., DDF_SAME_DRAW|DDF_SAME_HDC);
// Call to change color.
DrawDibChangePalette(hDD, iStart, iLen, lppe);
.
.
.
ReleaseDC(hwnd, hdc);
Related Links
Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET
More Online Helps
Win32 Programmer's Reference (win32.hlp)
OLE Programmer's Reference (ole.hlp)
Microsoft Windows Pen API Programmer's Reference (penapi.hlp)
Microsoft Windows Sockets 2 Reference (sock2.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (tapi.hlp)
Unix Manual Pages
|