NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
REL="HOME"
TITLE="SDL Library Documentation"
REL="UP"
TITLE="Video"
REL="PREVIOUS"
TITLE="SDL_Flip"
HREF="sdlflip.html"><
LINK
REL="NEXT"
TITLE="SDL_SetPalette"
HREF="sdlsetpalette.html"><
/HEAD
CLASS="REFENTRY"
BGCOLOR="#FFF8DC"
TEXT="#000000"
LINK="#0000ee"
VLINK="#551a8b"
ALINK="#ff0000"
CLASS="NAVHEADER"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
COLSPAN="3"
ALIGN="center"
>SDL Library Documentation<
/TH
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
HREF="sdlflip.html"
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
HREF="sdlsetpalette.html"
ALIGN="LEFT"
NAME="SDLSETCOLORS"
CLASS="REFNAMEDIV"
NAME="AEN1047"
>SDL_SetColors -- Sets a portion of the colormap
for the given
8-bit surface.<
/DIV
CLASS="REFSYNOPSISDIV"
NAME="AEN1050"
CLASS="FUNCSYNOPSIS"
NAME="AEN1051"
CLASS="FUNCSYNOPSISINFO"
CLASS="FUNCDEF"
CLASS="FSFUNC"
>
(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors
);<
/CODE
CLASS="REFSECT1"
NAME="AEN1057"
>Sets a portion of the colormap
for the given
8-bit surface.<
/P
CLASS="PARAMETER"
> is the surface associated with the current
display, the display colormap will be updated with the requested colors. If
CLASS="LITERAL"
HREF="sdlsetvideomode.html"
> flags,
CLASS="FUNCTION"
> will always return <
SPAN
CLASS="RETURNVALUE"
>,
and the palette is guaranteed to be set the way you desire, even if the window
colormap has to be warped or run under emulation.<
/P
>The color components of a
HREF="sdlcolor.html"
CLASS="STRUCTNAME"
>
structure are
8-bits in
size, giving you a total of
256<
SUP
>
>Palettized
(8-bit
) screen surfaces with the <
TT
CLASS="LITERAL"
>
flag have two palettes, a logical palette that is used for mapping blits
to/from the surface and a physical palette (that determines how the
hardware will map the colors to the display
). <
TT
CLASS="FUNCTION"
>
modifies both palettes (if present), and is equivalent to calling
HREF="sdlsetpalette.html"
> with the
CLASS="PARAMETER"
> set to
CLASS="LITERAL"
>
(SDL_LOGPAL | SDL_PHYSPAL
)<
/TT
CLASS="REFSECT1"
NAME="AEN1076"
CLASS="PARAMETER"
> is not a palettized surface, this function
does nothing, returning <
SPAN
CLASS="RETURNVALUE"
>. If all of the colors were set
CLASS="FUNCTION"
>, it will return
CLASS="RETURNVALUE"
>. If not all the color entries were set exactly as
given, it will return <
SPAN
CLASS="RETURNVALUE"
>, and you should look at the
surface palette to determine the actual
color palette.<
/P
CLASS="REFSECT1"
NAME="AEN1084"
CLASS="PROGRAMLISTING"
>/* 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_SetColors(screen, colors, 0, 256);
.
.
.
CLASS="REFSECT1"
NAME="AEN1087"
HREF="sdlcolor.html"
CLASS="STRUCTNAME"
>
HREF="sdlsurface.html"
CLASS="STRUCTNAME"
>,
HREF="sdlsetpalette.html"
CLASS="FUNCTION"
>,
HREF="sdlsetvideomode.html"
CLASS="FUNCTION"
CLASS="NAVFOOTER"
ALIGN="LEFT"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
WIDTH="33%"
ALIGN="left"
VALIGN="top"
HREF="sdlflip.html"
WIDTH="34%"
ALIGN="center"
VALIGN="top"
HREF="index.html"
WIDTH="33%"
ALIGN="right"
VALIGN="top"
HREF="sdlsetpalette.html"
WIDTH="33%"
ALIGN="left"
VALIGN="top"
WIDTH="34%"
ALIGN="center"
VALIGN="top"
HREF="video.html"
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>