2017-05-03 50 views

回答

0

SDL_SetPaletteColors()和表從SDL衍生1.2的SDL_SetVideoMode()輸出給我這個片斷:

surface = SDL_CreateRGBSurface(0, 100, 100, 8, 0, 0, 0, 0); 
Uint8 r[8] = { 0, 36, 73, 109, 146, 182, 219, 255 }; 
Uint8 g[8] = { 0, 36, 73, 109, 146, 182, 219, 255 }; 
Uint8 b[4] = { 0, 85, 170, 255 }; 
int curColor = 0; 
for(unsigned int i = 0; i < 8; ++i) 
for(unsigned int j = 0; j < 8; ++j) 
for(unsigned int k = 0; k < 4; ++k) 
{ 
    SDL_Color color = { r[i], g[j], b[k], 255 }; 
    SDL_SetPaletteColors(surface->format->palette, &color, curColor, 1); 
    curColor++; 
}