ColorResList Example for C++ 5.0 and later
This example changes the hue of bitmaps in a list, then plays the list as an animation. When changing the hue, it preserves the transparent color.
short i; // Loop counter
short uCount; // Number of bitmaps in the list
ILEADRasterProcess *pRasterProc=NULL;
CoCreateInstance(CLSID_LEADRasterProcess, NULL, CLSCTX_ALL,
IID_ILEADRasterProcess, (void**)&pRasterProc);
OLE_COLOR TransparentColor; // Color used for transparency
// Save the current transparent color.
TransparentColor = m_LEADRasterView1.GetRaster().GetBitmapTransparentColor();
// Avoid repaints while we modify the bitmaps.
m_LEADRasterView1.SetAutoRepaint(FALSE);
// Change the hue of each bitmap in the list,
// and restore the transparent color as the last color in the palette.
uCount = m_LEADRasterView1.GetRaster().GetBitmapListCount();
for (i = 0; i < uCount; ++i)
{
m_LEADRasterView1.GetRaster().SetBitmapListIndex(i);
pRasterProc->Hue(m_LEADRasterView1.GetRaster(), i * 10);
m_LEADRasterView1.GetRaster().SetBitmapPalette(255, TransparentColor);
}
// Get an optimized palette for the whole list.
pRasterProc->ColorResList(m_LEADRasterView1.GetRaster(),
8, CRP_OPTIMIZEDPALETTE,
CRD_NODITHERING, 0);
// Update the palette that is used for playback.
for (i = 0; i < 256; ++ i)
m_LEADRasterView1.SetAnimationPalette(i,
m_LEADRasterView1.GetRaster().GetBitmapPalette(i));
// Start the animation.
m_LEADRasterView1.SetAutoRepaint(TRUE);
m_LEADRasterView1.SetAnimationEnable(TRUE);
pRasterProc->Release();