ColorResList Example for Visual J++

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.

// Save the current transparent color.
Color clrTransparent = LEAD1.getBitmapTransparentColor();

// Avoid repaints while we modify the bitmaps.
LEAD1.setAutoRepaint( false );

// Change the hue of each bitmap in the list,
// and restore the transparent color as the last color in the palette.
short sCount = LEAD1.getBitmapListCount();
for( short i = 0 ; i < sCount ; i ++ )
{
   LEAD1.setBitmapListIndex( i );
   LEAD1.Hue( (short) ( i * 10 ) );
   LEAD1.setBitmapPalette( (short) 255, clrTransparent );
}

// Get an optimized palette for the whole list.
LEAD1.ColorResList( (short) 8, (short) LTOCXU.ColorResPaletteConstants.CRP_OPTIMIZEDPALETTE, (short) LTOCXU.ColorResDitherConstants.CRD_NODITHERING, (short) 0 );

// Update the palette that is used for playback.
for( short i = 0 ; i < 256 ; i ++ )
   LEAD1.setAnimationPalette( i, LEAD1.getBitmapPalette( i ) );

// Start the animation.
LEAD1.setAutoRepaint( true );
LEAD1.setAnimationEnable( true );