All pastes #101407 Raw Edit

Anonymous

public text v1 · immutable
#101407 ·published 2006-07-26 21:25 UTC
rendered paste body
Palettefile::Palettefile(unsigned char* buf, int bufsize)
{
    printf("loading palette...\n");

    m_palette = new SDL_Palette;
    m_palette->ncolors = bufsize / 3;

    m_palette->colors = new SDL_Color[m_palette->ncolors];
    SDL_Color* c = m_palette->colors;
    unsigned char* dunepal = buf;

    for (int i=0; i!=m_palette->ncolors; i++, c++, dunepal+=3)
    {
        c->r = (dunepal[0] << 2) + 3;
        c->g = (dunepal[1] << 2) + 3;
        c->b = (dunepal[2] << 2) + 3;

        printf("%d %03d %03d %03d\n", i, c->r, c->g, c->b);
    };

    delete [] buf;
};