Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

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