1SDL_SetColors(3)               SDL API Reference              SDL_SetColors(3)
2
3
4

NAME

6       SDL_SetColors - Sets a portion of the colormap for the given 8-bit sur‐
7       face.
8

SYNOPSIS

10       #include "SDL.h"
11
12       int SDL_SetColors(SDL_Surface *surface, SDL_Color *colors,  int  first‐
13       color, int ncolors);
14

DESCRIPTION

16       Sets a portion of the colormap for the given 8-bit surface.
17
18       When  surface  is  the surface associated with the current display, the
19       display  colormap  will  be  updated  with  the  requested  colors.  If
20       SDL_HWPALETTE  was  set  in  SDL_SetVideoMode flags, SDL_SetColors will
21       always return 1, and the palette is guaranteed to be set  the  way  you
22       desire,  even if the window colormap has to be warped or run under emu‐
23       lation.
24
25       The color components of a SDL_Color structure are 8-bits in size,  giv‐
26       ing you a total of 256^3 =16777216 colors.
27
28       Palettized (8-bit) screen surfaces with the SDL_HWPALETTE flag have two
29       palettes, a logical palette that is used for mapping blits to/from  the
30       surface  and  a physical palette (that determines how the hardware will
31       map the colors to the display). SDL_SetColors  modifies  both  palettes
32       (if  present),  and  is  equivalent  to calling SDL_SetPalette with the
33       flags set to (SDL_LOGPAL | SDL_PHYSPAL).
34

RETURN VALUE

36       If surface is not a palettized surface,  this  function  does  nothing,
37       returning  0. If all of the colors were set as passed to SDL_SetColors,
38       it will return 1. If not all the color  entries  were  set  exactly  as
39       given,  it will return 0, and you should look at the surface palette to
40       determine the actual color palette.
41

EXAMPLE

43       /* Create a display surface with a grayscale palette */
44       SDL_Surface *screen;
45       SDL_Color colors[256];
46       int i;
47       .
48       .
49       .
50       /* Fill colors with color information */
51       for(i=0;i<256;i++){
52         colors[i].r=i;
53         colors[i].g=i;
54         colors[i].b=i;
55       }
56
57       /* Create display */
58       screen=SDL_SetVideoMode(640, 480, 8, SDL_HWPALETTE);
59       if(!screen){
60         printf("Couldn't set video mode: %s
61       ", SDL_GetError());
62         exit(-1);
63       }
64
65       /* Set palette */
66       SDL_SetColors(screen, colors, 0, 256);
67       .
68       .
69       .
70       .
71

SEE ALSO

73       SDL_Color SDL_Surface, SDL_SetPalette, SDL_SetVideoMode
74
75
76
77SDL                         Tue 11 Sep 2001, 23:01            SDL_SetColors(3)
Impressum