SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat * format, Uint8 * r, Uint8 * g,
           Uint8 * b)
{
    if (format->palette == NULL) {
        unsigned v;
        v = (pixel & format->Rmask) >> format->Rshift;
        *r = SDL_expand_byte[format->Rloss][v];
        v = (pixel & format->Gmask) >> format->Gshift;
        *g = SDL_expand_byte[format->Gloss][v];
        v = (pixel & format->Bmask) >> format->Bshift;
        *b = SDL_expand_byte[format->Bloss][v];
    } else {
        if (pixel < (unsigned)format->palette->ncolors) {
            *r = format->palette->colors[pixel].r;
            *g = format->palette->colors[pixel].g;
            *b = format->palette->colors[pixel].b;
        } else {
            *r = *g = *b = 0;
        }
    }
}
SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat * format, Uint8 * r, Uint8 * g,
           Uint8 * b)
{
    if (format->palette == NULL) {
        unsigned v;
        v = (pixel & format->Rmask) >> format->Rshift;
        *r = SDL_expand_byte[format->Rloss][v];
        v = (pixel & format->Gmask) >> format->Gshift;
        *g = SDL_expand_byte[format->Gloss][v];
        v = (pixel & format->Bmask) >> format->Bshift;
        *b = SDL_expand_byte[format->Bloss][v];
    } else {
        if (pixel < (unsigned)format->palette->ncolors) {
            *r = format->palette->colors[pixel].r;
            *g = format->palette->colors[pixel].g;
            *b = format->palette->colors[pixel].b;
        } else {
            *r = *g = *b = 0;
        }
    }
}