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="sdlflip.html"><LINK
19 TITLE="SDL_SetPalette"
20 HREF="sdlsetpalette.html"></HEAD
31 SUMMARY="Header navigation table"
40 >SDL Library Documentation</TH
62 HREF="sdlsetpalette.html"
83 >SDL_SetColors -- Sets a portion of the colormap for the given 8-bit surface.</DIV
85 CLASS="REFSYNOPSISDIV"
99 CLASS="FUNCSYNOPSISINFO"
100 >#include "SDL.h"</PRE
109 >(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors);</CODE
123 >Sets a portion of the colormap for the given 8-bit surface.</P
130 > is the surface associated with the current
131 display, the display colormap will be updated with the requested colors. If
136 HREF="sdlsetvideomode.html"
142 > will always return <SPAN
146 and the palette is guaranteed to be set the way you desire, even if the window
147 colormap has to be warped or run under emulation.</P
149 >The color components of a
157 structure are 8-bits in size, giving you a total of 256<SUP
162 >Palettized (8-bit) screen surfaces with the <TT
166 flag have two palettes, a logical palette that is used for mapping blits
167 to/from the surface and a physical palette (that determines how the
168 hardware will map the colors to the display). <TT
172 modifies both palettes (if present), and is equivalent to calling
174 HREF="sdlsetpalette.html"
185 >(SDL_LOGPAL | SDL_PHYSPAL)</TT
201 > is not a palettized surface, this function
202 does nothing, returning <SPAN
205 >. If all of the colors were set
213 >. If not all the color entries were set exactly as
214 given, it will return <SPAN
217 >, and you should look at the
218 surface palette to determine the actual color palette.</P
228 CLASS="PROGRAMLISTING"
229 >/* Create a display surface with a grayscale palette */
231 SDL_Color colors[256];
236 /* Fill colors with color information */
237 for(i=0;i<256;i++){
244 screen=SDL_SetVideoMode(640, 480, 8, SDL_HWPALETTE);
246 printf("Couldn't set video mode: %s\n", SDL_GetError());
251 SDL_SetColors(screen, colors, 0, 256);
273 HREF="sdlsurface.html"
280 HREF="sdlsetpalette.html"
287 HREF="sdlsetvideomode.html"
290 >SDL_SetVideoMode</TT
299 SUMMARY="Footer navigation table"
328 HREF="sdlsetpalette.html"