SDL_SetPalette函数:
设置8位表面的调色板。
定义:
#include "SDL.h" int SDL_SetPalette(SDL_Surface *surface, int flags, SDL_Color *colors, int firstcolor, int ncolors);
/* Create a display surface with a grayscale palette */ SDL_Surface *screen; SDL_Color colors[256]; int i; . . . /* Fill colors with color information */ for(i=0;i<256;i++){ colors[i].r=i; colors[i].g=i; colors[i].b=i; } /* Create display */ screen=SDL_SetVideoMode(640, 480, 8, SDL_HWPALETTE); if(!screen){ printf("Couldn't set video mode: %s\n", SDL_GetError()); exit(-1); } /* Set palette */ SDL_SetPalette(screen, SDL_LOGPAL|SDL_PHYSPAL, colors, 0, 256); . . . .
蔡军生