All pastes #920811 Raw Edit

Stuff

public text v1 · immutable
#920811 ·published 2008-02-27 17:00 UTC
rendered paste body
#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b)                        \
do {                                                                       \
        switch (bpp) {                                                     \
                case 2:                                                    \
                        Pixel = *((Uint16 *)(buf));                        \
                break;                                                     \
                                                                           \
                case 3: {                                                  \
                        Uint8 *B = (Uint8 *)buf;                           \
                        if(SDL_BYTEORDER == SDL_LIL_ENDIAN) {              \
                                Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
                        } else {                                           \
                                Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
                        }                                                  \
                }                                                          \
                break;                                                     \
                                                                           \
                case 4:                                                    \
                        Pixel = *((Uint32 *)(buf));                        \
                break;                                                     \
                                                                           \
                default:                                                   \
                        Pixel = 0;      /* prevent gcc from complaining */ \
                break;                                                     \
        }                                                                  \
        RGB_FROM_PIXEL(Pixel, fmt, r, g, b);                               \
} while(0)