tune the preloads a bit
[sdl_omap.git] / docs / html / sdlsetcolors.html
CommitLineData
e14743d1 1<HTML
2><HEAD
3><TITLE
4>SDL_SetColors</TITLE
5><META
6NAME="GENERATOR"
7CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
8"><LINK
9REL="HOME"
10TITLE="SDL Library Documentation"
11HREF="index.html"><LINK
12REL="UP"
13TITLE="Video"
14HREF="video.html"><LINK
15REL="PREVIOUS"
16TITLE="SDL_Flip"
17HREF="sdlflip.html"><LINK
18REL="NEXT"
19TITLE="SDL_SetPalette"
20HREF="sdlsetpalette.html"></HEAD
21><BODY
22CLASS="REFENTRY"
23BGCOLOR="#FFF8DC"
24TEXT="#000000"
25LINK="#0000ee"
26VLINK="#551a8b"
27ALINK="#ff0000"
28><DIV
29CLASS="NAVHEADER"
30><TABLE
31SUMMARY="Header navigation table"
32WIDTH="100%"
33BORDER="0"
34CELLPADDING="0"
35CELLSPACING="0"
36><TR
37><TH
38COLSPAN="3"
39ALIGN="center"
40>SDL Library Documentation</TH
41></TR
42><TR
43><TD
44WIDTH="10%"
45ALIGN="left"
46VALIGN="bottom"
47><A
48HREF="sdlflip.html"
49ACCESSKEY="P"
50>Prev</A
51></TD
52><TD
53WIDTH="80%"
54ALIGN="center"
55VALIGN="bottom"
56></TD
57><TD
58WIDTH="10%"
59ALIGN="right"
60VALIGN="bottom"
61><A
62HREF="sdlsetpalette.html"
63ACCESSKEY="N"
64>Next</A
65></TD
66></TR
67></TABLE
68><HR
69ALIGN="LEFT"
70WIDTH="100%"></DIV
71><H1
72><A
73NAME="SDLSETCOLORS"
74></A
75>SDL_SetColors</H1
76><DIV
77CLASS="REFNAMEDIV"
78><A
79NAME="AEN1462"
80></A
81><H2
82>Name</H2
83>SDL_SetColors&nbsp;--&nbsp;Sets a portion of the colormap for the given 8-bit surface.</DIV
84><DIV
85CLASS="REFSYNOPSISDIV"
86><A
87NAME="AEN1465"
88></A
89><H2
90>Synopsis</H2
91><DIV
92CLASS="FUNCSYNOPSIS"
93><A
94NAME="AEN1466"
95></A
96><P
97></P
98><PRE
99CLASS="FUNCSYNOPSISINFO"
100>#include "SDL.h"</PRE
101><P
102><CODE
103><CODE
104CLASS="FUNCDEF"
105>int <B
106CLASS="FSFUNC"
107>SDL_SetColors</B
108></CODE
109>(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors);</CODE
110></P
111><P
112></P
113></DIV
114></DIV
115><DIV
116CLASS="REFSECT1"
117><A
118NAME="AEN1472"
119></A
120><H2
121>Description</H2
122><P
123>Sets a portion of the colormap for the given 8-bit surface.</P
124><P
125>When <TT
126CLASS="PARAMETER"
127><I
128>surface</I
129></TT
130> is the surface associated with the current
131display, the display colormap will be updated with the requested colors. If
132<TT
133CLASS="LITERAL"
134>SDL_HWPALETTE</TT
135> was set in <A
136HREF="sdlsetvideomode.html"
137>SDL_SetVideoMode</A
138> flags,
139<TT
140CLASS="FUNCTION"
141>SDL_SetColors</TT
142> will always return <SPAN
143CLASS="RETURNVALUE"
144>1</SPAN
145>,
146and the palette is guaranteed to be set the way you desire, even if the window
147colormap has to be warped or run under emulation.</P
148><P
149>The color components of a
150<A
151HREF="sdlcolor.html"
152><SPAN
153CLASS="STRUCTNAME"
154>SDL_Color</SPAN
155></A
156>
157structure are 8-bits in size, giving you a total of 256<SUP
158>3</SUP
159>
160=16777216 colors.</P
161><P
162>Palettized (8-bit) screen surfaces with the <TT
163CLASS="LITERAL"
164>SDL_HWPALETTE</TT
165>
166flag have two palettes, a logical palette that is used for mapping blits
167to/from the surface and a physical palette (that determines how the
168hardware will map the colors to the display). <TT
169CLASS="FUNCTION"
170>SDL_SetColors</TT
171>
172modifies both palettes (if present), and is equivalent to calling
173<A
174HREF="sdlsetpalette.html"
175>SDL_SetPalette</A
176> with the
177<TT
178CLASS="PARAMETER"
179><I
180>flags</I
181></TT
182> set to
183<TT
184CLASS="LITERAL"
185>(SDL_LOGPAL | SDL_PHYSPAL)</TT
186>.</P
187></DIV
188><DIV
189CLASS="REFSECT1"
190><A
191NAME="AEN1491"
192></A
193><H2
194>Return Value</H2
195><P
196>If <TT
197CLASS="PARAMETER"
198><I
199>surface</I
200></TT
201> is not a palettized surface, this function
202does nothing, returning <SPAN
203CLASS="RETURNVALUE"
204>0</SPAN
205>. If all of the colors were set
206as passed to <TT
207CLASS="FUNCTION"
208>SDL_SetColors</TT
209>, it will return
210<SPAN
211CLASS="RETURNVALUE"
212>1</SPAN
213>. If not all the color entries were set exactly as
214given, it will return <SPAN
215CLASS="RETURNVALUE"
216>0</SPAN
217>, and you should look at the
218surface palette to determine the actual color palette.</P
219></DIV
220><DIV
221CLASS="REFSECT1"
222><A
223NAME="AEN1499"
224></A
225><H2
226>Example</H2
227><PRE
228CLASS="PROGRAMLISTING"
229>/* Create a display surface with a grayscale palette */
230SDL_Surface *screen;
231SDL_Color colors[256];
232int i;
233.
234.
235.
236/* Fill colors with color information */
237for(i=0;i&#60;256;i++){
238 colors[i].r=i;
239 colors[i].g=i;
240 colors[i].b=i;
241}
242
243/* Create display */
244screen=SDL_SetVideoMode(640, 480, 8, SDL_HWPALETTE);
245if(!screen){
246 printf("Couldn't set video mode: %s\n", SDL_GetError());
247 exit(-1);
248}
249
250/* Set palette */
251SDL_SetColors(screen, colors, 0, 256);
252.
253.
254.
255.</PRE
256></DIV
257><DIV
258CLASS="REFSECT1"
259><A
260NAME="AEN1502"
261></A
262><H2
263>See Also</H2
264><P
265><A
266HREF="sdlcolor.html"
267><SPAN
268CLASS="STRUCTNAME"
269>SDL_Color</SPAN
270></A
271>
272<A
273HREF="sdlsurface.html"
274><SPAN
275CLASS="STRUCTNAME"
276>SDL_Surface</SPAN
277></A
278>,
279<A
280HREF="sdlsetpalette.html"
281><TT
282CLASS="FUNCTION"
283>SDL_SetPalette</TT
284></A
285>,
286<A
287HREF="sdlsetvideomode.html"
288><TT
289CLASS="FUNCTION"
290>SDL_SetVideoMode</TT
291></A
292></P
293></DIV
294><DIV
295CLASS="NAVFOOTER"
296><HR
297ALIGN="LEFT"
298WIDTH="100%"><TABLE
299SUMMARY="Footer navigation table"
300WIDTH="100%"
301BORDER="0"
302CELLPADDING="0"
303CELLSPACING="0"
304><TR
305><TD
306WIDTH="33%"
307ALIGN="left"
308VALIGN="top"
309><A
310HREF="sdlflip.html"
311ACCESSKEY="P"
312>Prev</A
313></TD
314><TD
315WIDTH="34%"
316ALIGN="center"
317VALIGN="top"
318><A
319HREF="index.html"
320ACCESSKEY="H"
321>Home</A
322></TD
323><TD
324WIDTH="33%"
325ALIGN="right"
326VALIGN="top"
327><A
328HREF="sdlsetpalette.html"
329ACCESSKEY="N"
330>Next</A
331></TD
332></TR
333><TR
334><TD
335WIDTH="33%"
336ALIGN="left"
337VALIGN="top"
338>SDL_Flip</TD
339><TD
340WIDTH="34%"
341ALIGN="center"
342VALIGN="top"
343><A
344HREF="video.html"
345ACCESSKEY="U"
346>Up</A
347></TD
348><TD
349WIDTH="33%"
350ALIGN="right"
351VALIGN="top"
352>SDL_SetPalette</TD
353></TR
354></TABLE
355></DIV
356></BODY
357></HTML
358>