Beispiel #1
0
void NxLabel::ColourChanged()
{
	mBaseRectangle->SetColour( FindColour( backgroundColourId ) );
	mText->SetColour( FindColour( labeltextColourId ) );
}
Beispiel #2
0
BOOL Anim_CommonPalette( anim a )
{
    unsigned int colours[256];
    unsigned int nColours = 0;
    unsigned int nThisFrame;
    pixel *image, *mask;
    pixel map[256];
    unsigned char used[256];
    unsigned char dstused[256];
    unsigned int i, j;
    unsigned int len = a->nWidth * a->nHeight;
    BOOL result = TRUE;
    BOOL compatible;
    frame f;
    unsigned int mincolours = 0;
    unsigned int nUsedOnFrame;

    image = Anim_Allocate( len );
    mask  = Anim_Allocate( len );
    if ( !image || !mask )
    {
        Anim_NoMemory( "commonpal" );
        result = FALSE;
    }
    else
    {
        Workspace_Claim( gifcompress_WORKSIZE );

        for ( i=0; i < a->nFrames; i++ )
        {
            f = a->pFrames + i;

            if ( !Anim_Decompress( f->pImageData, f->nImageSize, len, image ) )
            {
                result = FALSE;
                break;
            }

            if ( f->pMaskData )
            {
                if ( !Anim_Decompress( f->pMaskData, f->nMaskSize, len, mask ) )
                {
                    result = FALSE;
                    break;
                }
            }
            else
                memset( mask, 1, len );     /* all solid */

            memset( used, 0, 256 );

            for ( j=0; j<len; j++ )
                if ( mask[j] )
                    used[ image[j] ] = 1;

            compatible = TRUE;

            nThisFrame = nColours;

            memset( dstused, 0, 256 );

            for ( j=0; j<256; j++ )
            {
                if ( used[j] )
                {
                    int n = FindColour( colours, &nColours,
                                        f->pal->pColours[j] );

                    if ( n<0 )
                    {
                        compatible = FALSE;
                        break;
                    }
                    map[j] = (pixel) n;
                    dstused[n] = 1;
                }
            }

            if ( compatible )
            {
                debugf( "commonpal: frame %d compatible\n", i );

#if DEBUG
                debugf( "map" );
                for ( j=0; j<f->pal->nColours; j++ )
                {
                    if ( used[j] )
                        debugf( " %d", map[j] );
                    else
                        debugf( " -" );
                }
                debugf( "\n" );
#endif

                Palette_Destroy( &f->pal );     /* sets to NULL */

                /* Remap the frame to the new palette */
                for ( j=0; j<len; j++ )
                    image[j] = map[image[j]];
                Anim_Free( &f->pImageData );

                f->pImageData = Anim_Compress( image, len, &f->nImageSize );

                if ( !f->pImageData )
                {
                    result = FALSE;
                    break;
                }

                nUsedOnFrame = 0;

                for ( j=0; j<256; j++ )
                    if ( dstused[j] )
                        nUsedOnFrame++;

                if ( nUsedOnFrame >= mincolours && (i || f->pMaskData) )
                {
                    mincolours = nUsedOnFrame + 1;
                }
            }
            else
            {
                debugf( "commonpal: frame %d INcompatible!\n", i );

                nColours = nThisFrame;
            }
        }

        Workspace_Release();
    }

    Anim_Free( &image );
    Anim_Free( &mask );

    if ( result )
    {
        /* Allow an extra colour for transparency if possible */
        if ( mincolours > nColours && nColours < 256 )
        {
            /* And make it black, to avoid BUGS in the Microsoft Java VM */
            colours[nColours] = 0;
            nColours++;
        }

        debugf( "mincolours=%d nColours=%d\n", mincolours, nColours );

        for ( i=0; i < a->nFrames; i++ )
        {
            f = a->pFrames+i;

            if ( !f->pal )
            {
                f->pal = Palette_Create( colours, nColours );
                if ( !f->pal )
                {
                    result = FALSE;
                    break;
                }
            }
        }
    }
    return result;
}