1SDL_SetAlpha(3) SDL API Reference SDL_SetAlpha(3)
2
3
4
6 SDL_SetAlpha - Adjust the alpha properties of a surface
7
9 #include "SDL.h"
10
11 int SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha);
12
14 Note:
15
16 This function and the semantics of SDL alpha blending have
17 changed since version 1.1.4. Up until version 1.1.5, an alpha
18 value of 0 was considered opaque and a value of 255 was consid‐
19 ered transparent. This has now been inverted: 0
20 (SDL_ALPHA_TRANSPARENT) is now considered transparent and 255
21 (SDL_ALPHA_OPAQUE) is now considered opaque.
22
23 SDL_SetAlpha is used for setting the per-surface alpha value and/or
24 enabling and disabling alpha blending.
25
26 Thesurface parameter specifies which surface whose alpha attributes you
27 wish to adjust. flags is used to specify whether alpha blending should
28 be used (SDL_SRCALPHA) and whether the surface should use RLE accelera‐
29 tion for blitting (SDL_RLEACCEL). flags can be an OR'd combination of
30 these two options, one of these options or 0. If SDL_SRCALPHA is not
31 passed as a flag then all alpha information is ignored when blitting
32 the surface. The alpha parameter is the per-surface alpha value; a sur‐
33 face need not have an alpha channel to use per-surface alpha and blit‐
34 ting can still be accelerated with SDL_RLEACCEL.
35
36 Note:
37
38 The per-surface alpha value of 128 is considered a special case
39 and is optimised, so it's much faster than other per-surface
40 values.
41
42 Alpha effects surface blitting in the following ways:
43
44 RGBA->RGB with SDL_SRCALPHA
45 The source is alpha-blended with the destination,
46 using the alpha channel. SDL_SRCCOLORKEY and the
47 per-surface alpha are ignored.
48
49 RGBA->RGB without SDL_SRCALPHA
50 The RGB data is copied from the source. The source
51 alpha channel and the per-surface alpha value are
52 ignored.
53
54 RGB->RGBA with SDL_SRCALPHA
55 The source is alpha-blended with the destination
56 using the per-surface alpha value. If SDL_SRCCOL‐
57 ORKEY is set, only the pixels not matching the col‐
58 orkey value are copied. The alpha channel of the
59 copied pixels is set to opaque.
60
61 RGB->RGBA without SDL_SRCALPHA
62 The RGB data is copied from the source and the
63 alpha value of the copied pixels is set to opaque.
64 If SDL_SRCCOLORKEY is set, only the pixels not
65 matching the colorkey value are copied.
66
67 RGBA->RGBA with SDL_SRCALPHA
68 The source is alpha-blended with the destination
69 using the source alpha channel. The alpha channel
70 in the destination surface is left untouched.
71 SDL_SRCCOLORKEY is ignored.
72
73 RGBA->RGBA without SDL_SRCALPHA
74 The RGBA data is copied to the destination surface.
75 If SDL_SRCCOLORKEY is set, only the pixels not
76 matching the colorkey value are copied.
77
78 RGB->RGB with SDL_SRCALPHA
79 The source is alpha-blended with the destination
80 using the per-surface alpha value. If SDL_SRCCOL‐
81 ORKEY is set, only the pixels not matching the col‐
82 orkey value are copied.
83
84 RGB->RGB without SDL_SRCALPHA
85 The RGB data is copied from the source. If SDL_SRC‐
86 COLORKEY is set, only the pixels not matching the
87 colorkey value are copied.
88
89 Note:
90
91 Note that RGBA->RGBA blits (with SDL_SRCALPHA set) keep the
92 alpha of the destination surface. This means that you cannot
93 compose two arbitrary RGBA surfaces this way and get the result
94 you would expect from "overlaying" them; the destination alpha
95 will work as a mask.
96
97 Also note that per-pixel and per-surface alpha cannot be com‐
98 bined; the per-pixel alpha is always used if available
99
101 This function returns 0, or -1 if there was an error.
102
104 SDL_MapRGBA, SDL_GetRGBA, SDL_DisplayFormatAlpha, SDL_BlitSurface
105
106
107
108SDL Tue 11 Sep 2001, 23:01 SDL_SetAlpha(3)