FILE: Animate.exe Palette Animation in WindowsID: Q74799
|
"Animation" of the Windows palette is the replacement of one set of colors in the palette by another set of colors. This article discusses animation and how it is used in a Windows-based application. Animate.exe is a sample application that enables you to draw a color wheel and "spin" it using animation can be found in the Microsoft Software Library.
The following file is available for download from the Microsoft Software Library:
~ Animate.exeFor more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:
Q119591 How to Obtain Microsoft Support Files from Online Services
+------+ +------+ +------+ +------+ +------+ +------+
| | | | | | | | | | | |
|idx 20| |idx 21| |idx 22| |idx 20| |idx 21| |idx 22| ...
| | | | | | | | | | | |
+------+ +------+ +------+ +------+ +------+ +------+
If index 20 is mapped to the color green in the palette, index 21 is
mapped to red, and index 22 is mapped to blue, a "Broadway Lights"
effect can be achieved by remapping the three colors to the different
indexes. For example, mapping red to 20, blue to 21, and green to 22,
the "lights" appears to move to the left.
pLogPal->palPalEntry[PaletteIndex].peFlags = PC_RESERVED;
PALETTEENTRY palentries[210]; /* The animation palette */
...
palentry.peRed = palentries[209].peRed;
palentry.peGreen = palentries[209].peGreen;
palentry.peBlue = palentries[209].peBlue;
for (i = 209; i > 0; i--)
{
palentries[i].peRed = palentries[i-1].peRed;
palentries[i].peGreen = palentries[i-1].peGreen;
palentries[i].peBlue = palentries[i-1].peBlue;
}
palentries[0].peRed = palentry.peRed;
palentries[0].peGreen = palentry.peGreen;
palentries[0].peBlue = palentry.peBlue;
hDC = GetDC(hWnd);
hOldPal = SelectPalette(hDC, hPal, FALSE);
// Call Animate Palette, and realize the colors
AnimatePalette(hPal, 20, 210, (LPPALETTEENTRY)palentries);
RealizePalette(hDC);
// Housekeep
SelectPalette(hDC, hOldPal, TRUE);
ReleaseDC(hWnd, hDC);
Additional query words:
Keywords : kbfile kbsample kb16bitonly kbGDI kbPalettes kbSDKWin16
Version : WINDOWS:3.1
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: July 13, 1999