version 2, including all changes.
.
Rev |
Author |
# |
Line |
2 |
perry |
1 |
SDL_!SetPalette |
|
|
2 |
!!!SDL_!SetPalette |
1 |
perry |
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
RETURN VALUE |
|
|
7 |
EXAMPLE |
|
|
8 |
SEE ALSO |
|
|
9 |
---- |
|
|
10 |
!!NAME |
|
|
11 |
|
|
|
12 |
|
2 |
perry |
13 |
SDL_!SetPalette- Sets the colors in the palette of an 8-bit surface. |
1 |
perry |
14 |
!!SYNOPSIS |
|
|
15 |
|
|
|
16 |
|
|
|
17 |
__#include __ |
|
|
18 |
|
|
|
19 |
|
2 |
perry |
20 |
__int SDL_!SetPalette__(__SDL_Surface *surface, int |
1 |
perry |
21 |
flags, int SDL_Color *colors, int firstcolor, int |
|
|
22 |
ncolors__); |
|
|
23 |
!!DESCRIPTION |
|
|
24 |
|
|
|
25 |
|
|
|
26 |
Sets a portion of the palette for the given 8-bit |
|
|
27 |
surface. |
|
|
28 |
|
|
|
29 |
|
|
|
30 |
Palettized (8-bit) screen surfaces with the |
|
|
31 |
__SDL_HWPALETTE__ flag have two palettes, a logical |
|
|
32 |
palette that is used for mapping blits to/from the surface |
|
|
33 |
and a physical palette (that determines how the hardware |
2 |
perry |
34 |
will map the colors to the display). ''SDL_!BlitSurface'' |
1 |
perry |
35 |
always uses the logical palette when blitting surfaces (if |
|
|
36 |
it has to convert between surface pixel formats). Because of |
|
|
37 |
this, it is often useful to modify only one or the other |
|
|
38 |
palette to achieve various special color effects (e.g., |
|
|
39 |
screen fading, color flashes, screen dimming). |
|
|
40 |
|
|
|
41 |
|
|
|
42 |
This function can modify either the logical or physical |
|
|
43 |
palette by specifing __SDL_LOGPAL__ or |
|
|
44 |
__SDL_PHYSPAL__the in the __flags__ |
|
|
45 |
parameter. |
|
|
46 |
|
|
|
47 |
|
|
|
48 |
When __surface__ is the surface associated with the |
|
|
49 |
current display, the display colormap will be updated with |
|
|
50 |
the requested colors. If __SDL_HWPALETTE__ was set in |
2 |
perry |
51 |
''SDL_!SetVideoMode'' flags, __SDL_!SetPalette__ will |
1 |
perry |
52 |
always return __1__, and the palette is guaranteed to be |
|
|
53 |
set the way you desire, even if the window colormap has to |
|
|
54 |
be warped or run under emulation. |
|
|
55 |
|
|
|
56 |
|
|
|
57 |
The color components of a __SDL_Color__ structure are |
|
|
58 |
8-bits in size, giving you a total of 256^3=16777216 |
|
|
59 |
colors. |
|
|
60 |
!!RETURN VALUE |
|
|
61 |
|
|
|
62 |
|
|
|
63 |
If __surface__ is not a palettized surface, this function |
|
|
64 |
does nothing, returning __0__. If all of the colors were |
2 |
perry |
65 |
set as passed to __SDL_!SetPalette__, it will return |
1 |
perry |
66 |
__1__. If not all the color entries were set exactly as |
|
|
67 |
given, it will return __0__, and you should look at the |
|
|
68 |
surface palette to determine the actual color |
|
|
69 |
palette. |
|
|
70 |
!!EXAMPLE |
|
|
71 |
|
|
|
72 |
|
|
|
73 |
/* Create a display surface with a grayscale palette */ |
|
|
74 |
SDL_Surface *screen; |
|
|
75 |
SDL_Color colors[[256]; |
|
|
76 |
int i; |
|
|
77 |
. |
|
|
78 |
. |
|
|
79 |
. |
|
|
80 |
/* Fill colors with color information */ |
|
|
81 |
for(i=0;i |
|
|
82 |
!!SEE ALSO |
|
|
83 |
|
|
|
84 |
|
2 |
perry |
85 |
''SDL_!SetColors'', ''SDL_!SetVideoMode'', |
1 |
perry |
86 |
''SDL_Surface'', ''SDL_Color'' |
|
|
87 |
---- |