7 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
10 TITLE="SDL Library Documentation"
11 HREF="index.html"><LINK
14 HREF="video.html"><LINK
17 HREF="sdlsetcolors.html"><LINK
20 HREF="sdlsetgamma.html"></HEAD
31 SUMMARY="Header navigation table"
40 >SDL Library Documentation</TH
48 HREF="sdlsetcolors.html"
62 HREF="sdlsetgamma.html"
83 >SDL_SetPalette -- Sets the colors in the palette of an 8-bit surface.</DIV
85 CLASS="REFSYNOPSISDIV"
99 CLASS="FUNCSYNOPSISINFO"
100 >#include "SDL.h"</PRE
109 >(SDL_Surface *surface, int flags, SDL_Color *colors, int firstcolor, int ncolors);</CODE
123 >Sets a portion of the palette for the given 8-bit surface.</P
125 >Palettized (8-bit) screen surfaces with the
129 > flag have two palettes, a logical
130 palette that is used for mapping blits to/from the surface and a
131 physical palette (that determines how the hardware will map the colors
133 HREF="sdlblitsurface.html"
136 always uses the logical palette when blitting surfaces (if it has to
137 convert between surface pixel formats). Because of this, it is often
138 useful to modify only one or the other palette to achieve various
139 special color effects (e.g., screen fading, color flashes, screen dimming).</P
141 >This function can modify either the logical or physical palette by
162 > is the surface associated with the current
163 display, the display colormap will be updated with the requested colors. If
168 HREF="sdlsetvideomode.html"
174 > will always return <SPAN
178 and the palette is guaranteed to be set the way you desire, even if the window
179 colormap has to be warped or run under emulation.</P
181 >The color components of a
189 are 8-bits in size, giving you a total of
192 >=16777216 colors.</P
207 > is not a palettized surface, this function
208 does nothing, returning <SPAN
211 >. If all of the colors were set
219 >. If not all the color entries were set exactly as
220 given, it will return <SPAN
223 >, and you should look at the
224 surface palette to determine the actual color palette.</P
234 CLASS="PROGRAMLISTING"
235 > /* Create a display surface with a grayscale palette */
237 SDL_Color colors[256];
242 /* Fill colors with color information */
243 for(i=0;i<256;i++){
250 screen=SDL_SetVideoMode(640, 480, 8, SDL_HWPALETTE);
252 printf("Couldn't set video mode: %s\n", SDL_GetError());
257 SDL_SetPalette(screen, SDL_LOGPAL|SDL_PHYSPAL, colors, 0, 256);
272 HREF="sdlsetcolors.html"
276 HREF="sdlsetvideomode.html"
280 HREF="sdlsurface.html"
293 SUMMARY="Footer navigation table"
304 HREF="sdlsetcolors.html"
322 HREF="sdlsetgamma.html"