Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5131 clevermous 1
2
>
3
>
4
>SDL_SetPalette
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_SetColors"
17
HREF="sdlsetcolors.html">
18
REL="NEXT"
19
TITLE="SDL_SetGamma"
20
HREF="sdlsetgamma.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="sdlsetcolors.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="sdlsetgamma.html"
61
>Next
62
>
63
>
64
>
65
>
66
ALIGN="LEFT"
67
WIDTH="100%">
68
>
69
>
70
NAME="SDLSETPALETTE"
71
>SDL_SetPalette
72
>
73
>
74
CLASS="REFNAMEDIV"
75
>
76
NAME="AEN1102"
77
>
78
>
79
>Name
80
>SDL_SetPalette -- Sets the colors in the palette of an 8-bit surface.
81
>
82
CLASS="REFSYNOPSISDIV"
83
>
84
NAME="AEN1105"
85
>
86
>
87
>Synopsis
88
>
89
CLASS="FUNCSYNOPSIS"
90
>
91
NAME="AEN1106"
92
>
93
>
94
>
95
>
96
CLASS="FUNCSYNOPSISINFO"
97
>#include "SDL.h"
98
>
99
>
100
>
101
CLASS="FUNCDEF"
102
>int 
103
CLASS="FSFUNC"
104
>SDL_SetPalette
105
>
106
>(SDL_Surface *surface, int flags, SDL_Color *colors, int firstcolor, int ncolors);
107
>
108
>
109
>
110
>
111
>
112
>
113
CLASS="REFSECT1"
114
>
115
NAME="AEN1112"
116
>
117
>
118
>Description
119
>
120
>Sets a portion of the palette for the given 8-bit surface.
121
>
122
>Palettized (8-bit) screen surfaces with the
123
124
CLASS="LITERAL"
125
>SDL_HWPALETTE
126
> flag have two palettes, a logical
127
palette that is used for mapping blits to/from the surface and a
128
physical palette (that determines how the hardware will map the colors
129
to the display). 
130
HREF="sdlblitsurface.html"
131
>SDL_BlitSurface
132
>
133
always uses the logical palette when blitting surfaces (if it has to
134
convert between surface pixel formats). Because of this, it is often
135
useful to modify only one or the other palette to achieve various
136
special color effects (e.g., screen fading, color flashes, screen dimming).
137
>
138
>This function can modify either the logical or physical palette by
139
specifing 
140
CLASS="LITERAL"
141
>SDL_LOGPAL
142
> or
143
144
CLASS="LITERAL"
145
>SDL_PHYSPAL
146
>the in the 
147
CLASS="PARAMETER"
148
>
149
>flags
150
>
151
>
152
parameter.
153
>
154
>When 
155
CLASS="PARAMETER"
156
>
157
>surface
158
>
159
> is the surface associated with the current
160
display, the display colormap will be updated with the requested colors.  If
161
162
CLASS="LITERAL"
163
>SDL_HWPALETTE
164
> was set in 
165
HREF="sdlsetvideomode.html"
166
>SDL_SetVideoMode
167
> flags,
168
169
CLASS="FUNCTION"
170
>SDL_SetPalette
171
> will always return 
172
CLASS="RETURNVALUE"
173
>1
174
>,
175
and the palette is guaranteed to be set the way you desire, even if the window
176
colormap has to be warped or run under emulation.
177
>
178
>The color components of a
179
180
HREF="sdlcolor.html"
181
>
182
CLASS="STRUCTNAME"
183
>SDL_Color
184
>
185
> structure
186
are 8-bits in size, giving you a total of
187
256
188
>3
189
>=16777216 colors.
190
>
191
>
192
CLASS="REFSECT1"
193
>
194
NAME="AEN1132"
195
>
196
>
197
>Return Value
198
>
199
>If 
200
CLASS="PARAMETER"
201
>
202
>surface
203
>
204
> is not a palettized surface, this function
205
does nothing, returning 
206
CLASS="RETURNVALUE"
207
>0
208
>.  If all of the colors were set
209
as passed to 
210
CLASS="FUNCTION"
211
>SDL_SetPalette
212
>, it will return
213
214
CLASS="RETURNVALUE"
215
>1
216
>.  If not all the color entries were set exactly as
217
given, it will return 
218
CLASS="RETURNVALUE"
219
>0
220
>, and you should look at the
221
surface palette to determine the actual color palette.
222
>
223
>
224
CLASS="REFSECT1"
225
>
226
NAME="AEN1140"
227
>
228
>
229
>Example
230
>
231
CLASS="PROGRAMLISTING"
232
>        /* Create a display surface with a grayscale palette */
233
        SDL_Surface *screen;
234
        SDL_Color colors[256];
235
        int i;
236
        .
237
        .
238
        .
239
        /* Fill colors with color information */
240
        for(i=0;i<256;i++){
241
          colors[i].r=i;
242
          colors[i].g=i;
243
          colors[i].b=i;
244
        }
245
 
246
        /* Create display */
247
        screen=SDL_SetVideoMode(640, 480, 8, SDL_HWPALETTE);
248
        if(!screen){
249
          printf("Couldn't set video mode: %s\n", SDL_GetError());
250
          exit(-1);
251
        }
252
 
253
        /* Set palette */
254
        SDL_SetPalette(screen, SDL_LOGPAL|SDL_PHYSPAL, colors, 0, 256);
255
        .
256
        .
257
        .
258
        .
259
>
260
>
261
CLASS="REFSECT1"
262
>
263
NAME="AEN1143"
264
>
265
>
266
>See Also
267
>
268
>
269
HREF="sdlsetcolors.html"
270
>SDL_SetColors
271
>,
272
273
HREF="sdlsetvideomode.html"
274
>SDL_SetVideoMode
275
>,
276
277
HREF="sdlsurface.html"
278
>SDL_Surface
279
>,
280
281
HREF="sdlcolor.html"
282
>SDL_Color
283
>
284
>
285
>
286
CLASS="NAVFOOTER"
287
>
288
ALIGN="LEFT"
289
WIDTH="100%">
290
WIDTH="100%"
291
BORDER="0"
292
CELLPADDING="0"
293
CELLSPACING="0"
294
>
295
>
296
WIDTH="33%"
297
ALIGN="left"
298
VALIGN="top"
299
>
300
HREF="sdlsetcolors.html"
301
>Prev
302
>
303
>
304
WIDTH="34%"
305
ALIGN="center"
306
VALIGN="top"
307
>
308
HREF="index.html"
309
>Home
310
>
311
>
312
WIDTH="33%"
313
ALIGN="right"
314
VALIGN="top"
315
>
316
HREF="sdlsetgamma.html"
317
>Next
318
>
319
>
320
>
321
>
322
WIDTH="33%"
323
ALIGN="left"
324
VALIGN="top"
325
>SDL_SetColors
326
>
327
WIDTH="34%"
328
ALIGN="center"
329
VALIGN="top"
330
>
331
HREF="video.html"
332
>Up
333
>
334
>
335
WIDTH="33%"
336
ALIGN="right"
337
VALIGN="top"
338
>SDL_SetGamma
339
>
340
>
341
>
342
>
343
>
344
>