0
|
1 <HTML
|
|
2 ><HEAD
|
|
3 ><TITLE
|
|
4 >SDL_SetAlpha</TITLE
|
|
5 ><META
|
|
6 NAME="GENERATOR"
|
|
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.61
|
|
8 "><LINK
|
|
9 REL="HOME"
|
|
10 TITLE="SDL Library Documentation"
|
|
11 HREF="index.html"><LINK
|
|
12 REL="UP"
|
|
13 TITLE="Video"
|
|
14 HREF="video.html"><LINK
|
|
15 REL="PREVIOUS"
|
|
16 TITLE="SDL_SetColorKey"
|
|
17 HREF="sdlsetcolorkey.html"><LINK
|
|
18 REL="NEXT"
|
|
19 TITLE="SDL_SetClipRect"
|
|
20 HREF="sdlsetcliprect.html"></HEAD
|
|
21 ><BODY
|
|
22 CLASS="REFENTRY"
|
|
23 BGCOLOR="#FFF8DC"
|
|
24 TEXT="#000000"
|
|
25 LINK="#0000ee"
|
|
26 VLINK="#551a8b"
|
|
27 ALINK="#ff0000"
|
|
28 ><DIV
|
|
29 CLASS="NAVHEADER"
|
|
30 ><TABLE
|
|
31 WIDTH="100%"
|
|
32 BORDER="0"
|
|
33 CELLPADDING="0"
|
|
34 CELLSPACING="0"
|
|
35 ><TR
|
|
36 ><TH
|
|
37 COLSPAN="3"
|
|
38 ALIGN="center"
|
|
39 >SDL Library Documentation</TH
|
|
40 ></TR
|
|
41 ><TR
|
|
42 ><TD
|
|
43 WIDTH="10%"
|
|
44 ALIGN="left"
|
|
45 VALIGN="bottom"
|
|
46 ><A
|
|
47 HREF="sdlsetcolorkey.html"
|
|
48 >Prev</A
|
|
49 ></TD
|
|
50 ><TD
|
|
51 WIDTH="80%"
|
|
52 ALIGN="center"
|
|
53 VALIGN="bottom"
|
|
54 ></TD
|
|
55 ><TD
|
|
56 WIDTH="10%"
|
|
57 ALIGN="right"
|
|
58 VALIGN="bottom"
|
|
59 ><A
|
|
60 HREF="sdlsetcliprect.html"
|
|
61 >Next</A
|
|
62 ></TD
|
|
63 ></TR
|
|
64 ></TABLE
|
|
65 ><HR
|
|
66 ALIGN="LEFT"
|
|
67 WIDTH="100%"></DIV
|
|
68 ><H1
|
|
69 ><A
|
|
70 NAME="SDLSETALPHA"
|
|
71 >SDL_SetAlpha</A
|
|
72 ></H1
|
|
73 ><DIV
|
|
74 CLASS="REFNAMEDIV"
|
|
75 ><A
|
|
76 NAME="AEN1612"
|
|
77 ></A
|
|
78 ><H2
|
|
79 >Name</H2
|
|
80 >SDL_SetAlpha -- Adjust the alpha properties of a surface</DIV
|
|
81 ><DIV
|
|
82 CLASS="REFSYNOPSISDIV"
|
|
83 ><A
|
|
84 NAME="AEN1615"
|
|
85 ></A
|
|
86 ><H2
|
|
87 >Synopsis</H2
|
|
88 ><DIV
|
|
89 CLASS="FUNCSYNOPSIS"
|
|
90 ><A
|
|
91 NAME="AEN1616"
|
|
92 ></A
|
|
93 ><P
|
|
94 ></P
|
|
95 ><PRE
|
|
96 CLASS="FUNCSYNOPSISINFO"
|
|
97 >#include "SDL.h"</PRE
|
|
98 ><P
|
|
99 ><CODE
|
|
100 ><CODE
|
|
101 CLASS="FUNCDEF"
|
|
102 >int <B
|
|
103 CLASS="FSFUNC"
|
|
104 >SDL_SetAlpha</B
|
|
105 ></CODE
|
|
106 >(SDL_Surface *surface, Uint32 flag, Uint8 alpha);</CODE
|
|
107 ></P
|
|
108 ><P
|
|
109 ></P
|
|
110 ></DIV
|
|
111 ></DIV
|
|
112 ><DIV
|
|
113 CLASS="REFSECT1"
|
|
114 ><A
|
|
115 NAME="AEN1622"
|
|
116 ></A
|
|
117 ><H2
|
|
118 >Description</H2
|
|
119 ><DIV
|
|
120 CLASS="NOTE"
|
|
121 ><BLOCKQUOTE
|
|
122 CLASS="NOTE"
|
|
123 ><P
|
|
124 ><B
|
|
125 >Note: </B
|
|
126 >This function and the semantics of SDL alpha blending have changed since version 1.1.4. Up until version 1.1.5, an alpha value of 0 was considered opaque and a value of 255 was considered transparent. This has now been inverted: 0 (<TT
|
|
127 CLASS="LITERAL"
|
|
128 >SDL_ALPHA_TRANSPARENT</TT
|
|
129 >) is now considered transparent and 255 (<TT
|
|
130 CLASS="LITERAL"
|
|
131 >SDL_ALPHA_OPAQUE</TT
|
|
132 >) is now considered opaque.</P
|
|
133 ></BLOCKQUOTE
|
|
134 ></DIV
|
|
135 ><P
|
|
136 ><TT
|
|
137 CLASS="FUNCTION"
|
|
138 >SDL_SetAlpha</TT
|
|
139 > is used for setting the per-surface alpha and/or enabling and disabling per-pixel alpha blending.</P
|
|
140 ><P
|
|
141 >The <TT
|
|
142 CLASS="PARAMETER"
|
|
143 ><I
|
|
144 >surface</I
|
|
145 ></TT
|
|
146 > parameter specifies which surface whose alpha attributes you wish to adjust. <TT
|
|
147 CLASS="PARAMETER"
|
|
148 ><I
|
|
149 >flags</I
|
|
150 ></TT
|
|
151 > is used to specify whether alpha blending should be used (<TT
|
|
152 CLASS="LITERAL"
|
|
153 >SDL_SRCALPHA</TT
|
|
154 >) and whether the surface should use RLE acceleration for blitting (<TT
|
|
155 CLASS="LITERAL"
|
|
156 >SDL_RLEACCEL</TT
|
|
157 >). <TT
|
|
158 CLASS="PARAMETER"
|
|
159 ><I
|
|
160 >flags</I
|
|
161 ></TT
|
|
162 > can be an OR'd combination of these two options, one of these options or 0. If <TT
|
|
163 CLASS="LITERAL"
|
|
164 >SDL_SRCALPHA</TT
|
|
165 > is not passed as a flag then all alpha information is ignored when blitting the surface. The <TT
|
|
166 CLASS="PARAMETER"
|
|
167 ><I
|
|
168 >alpha</I
|
|
169 ></TT
|
|
170 > parameter is the per-surface alpha value, a surface need not have an alpha channel to use per-surface alpha and blitting can still be accelerated with <TT
|
|
171 CLASS="LITERAL"
|
|
172 >SDL_RLEACCEL</TT
|
|
173 >. Setting the per-surface alpha value to 0 disables per-surface alpha blending.</P
|
|
174 ><DIV
|
|
175 CLASS="NOTE"
|
|
176 ><BLOCKQUOTE
|
|
177 CLASS="NOTE"
|
|
178 ><P
|
|
179 ><B
|
|
180 >Note: </B
|
|
181 >The per-surface alpha value of 128 is considered a special case and is optimised, so it's much faster than other per-surface values.</P
|
|
182 ></BLOCKQUOTE
|
|
183 ></DIV
|
|
184 ><P
|
|
185 >Alpha effects surface blitting in the following ways:</P
|
|
186 ><DIV
|
|
187 CLASS="INFORMALTABLE"
|
|
188 ><A
|
|
189 NAME="AEN1642"
|
|
190 ></A
|
|
191 ><P
|
|
192 ></P
|
|
193 ><TABLE
|
|
194 BORDER="0"
|
|
195 CLASS="CALSTABLE"
|
|
196 ><TBODY
|
|
197 ><TR
|
|
198 ><TD
|
|
199 ALIGN="LEFT"
|
|
200 VALIGN="TOP"
|
|
201 >RGBA->RGB with <TT
|
|
202 CLASS="LITERAL"
|
|
203 >SDL_SRCALPHA</TT
|
|
204 ></TD
|
|
205 ><TD
|
|
206 ALIGN="LEFT"
|
|
207 VALIGN="TOP"
|
|
208 ><P
|
|
209 >The source is alpha-blended with the destination, using the alpha channel. <TT
|
|
210 CLASS="LITERAL"
|
|
211 >SDL_SRCCOLORKEY</TT
|
|
212 > and the per-surface alpha are ignored.</P
|
|
213 ></TD
|
|
214 ></TR
|
|
215 ><TR
|
|
216 ><TD
|
|
217 ALIGN="LEFT"
|
|
218 VALIGN="TOP"
|
|
219 >RGBA->RGB without <TT
|
|
220 CLASS="LITERAL"
|
|
221 >SDL_SRCALPHA</TT
|
|
222 ></TD
|
|
223 ><TD
|
|
224 ALIGN="LEFT"
|
|
225 VALIGN="TOP"
|
|
226 ><P
|
|
227 >The RGB data is copied from the source. The source alpha channel and the per-surface alpha value are ignored.</P
|
|
228 ></TD
|
|
229 ></TR
|
|
230 ><TR
|
|
231 ><TD
|
|
232 ALIGN="LEFT"
|
|
233 VALIGN="TOP"
|
|
234 >RGB->RGBA with <TT
|
|
235 CLASS="LITERAL"
|
|
236 >SDL_SRCALPHA</TT
|
|
237 ></TD
|
|
238 ><TD
|
|
239 ALIGN="LEFT"
|
|
240 VALIGN="TOP"
|
|
241 ><P
|
|
242 >The source is alpha-blended with the destination using the per-surface alpha value. If <TT
|
|
243 CLASS="LITERAL"
|
|
244 >SDL_SRCCOLORKEY</TT
|
|
245 >literal> is set, only the pixels not matching the colorkey value are copied.</P
|
|
246 ></TD
|
|
247 ></TR
|
|
248 ><TR
|
|
249 ><TD
|
|
250 ALIGN="LEFT"
|
|
251 VALIGN="TOP"
|
|
252 >RGB->RGBA without <TT
|
|
253 CLASS="LITERAL"
|
|
254 >SDL_SRCALPHA</TT
|
|
255 ></TD
|
|
256 ><TD
|
|
257 ALIGN="LEFT"
|
|
258 VALIGN="TOP"
|
|
259 ><P
|
|
260 >The RGB data is copied from the source and the destination alpha is zero to opaque. If <TT
|
|
261 CLASS="LITERAL"
|
|
262 >SDL_SRCCOLORKEY</TT
|
|
263 > is set, only the pixels not matching the colorkey value are copied.</P
|
|
264 ></TD
|
|
265 ></TR
|
|
266 ><TR
|
|
267 ><TD
|
|
268 ALIGN="LEFT"
|
|
269 VALIGN="TOP"
|
|
270 >RGBA->RGBA with <TT
|
|
271 CLASS="LITERAL"
|
|
272 >SDL_SRCALPHA</TT
|
|
273 ></TD
|
|
274 ><TD
|
|
275 ALIGN="LEFT"
|
|
276 VALIGN="TOP"
|
|
277 ><P
|
|
278 >The source is alpha-blended with the destination using the source alpha channel. The alpha channel in the destination surface is left untouched. <TT
|
|
279 CLASS="LITERAL"
|
|
280 >SDL_SRCCOLORKEY</TT
|
|
281 > is ignored.</P
|
|
282 ></TD
|
|
283 ></TR
|
|
284 ><TR
|
|
285 ><TD
|
|
286 ALIGN="LEFT"
|
|
287 VALIGN="TOP"
|
|
288 >RGBA->RGBA without <TT
|
|
289 CLASS="LITERAL"
|
|
290 >SDL_SRCALPHA</TT
|
|
291 ></TD
|
|
292 ><TD
|
|
293 ALIGN="LEFT"
|
|
294 VALIGN="TOP"
|
|
295 ><P
|
|
296 >The RGBA data is copied to the destination surface. If <TT
|
|
297 CLASS="LITERAL"
|
|
298 >SDL_SRCCOLORKEY</TT
|
|
299 > is set, only the pixels not matching the colorkey value are copied.</P
|
|
300 ></TD
|
|
301 ></TR
|
|
302 ><TR
|
|
303 ><TD
|
|
304 ALIGN="LEFT"
|
|
305 VALIGN="TOP"
|
|
306 >RGB->RGB with <TT
|
|
307 CLASS="LITERAL"
|
|
308 >SDL_SRCALPHA</TT
|
|
309 ></TD
|
|
310 ><TD
|
|
311 ALIGN="LEFT"
|
|
312 VALIGN="TOP"
|
|
313 ><P
|
|
314 >The source is alpha-blended with the destination using the per-surface alpha value. If <TT
|
|
315 CLASS="LITERAL"
|
|
316 >SDL_SRCCOLORKEY</TT
|
|
317 > is set, only the pixels not matching the colorkey value are copied.</P
|
|
318 ></TD
|
|
319 ></TR
|
|
320 ><TR
|
|
321 ><TD
|
|
322 ALIGN="LEFT"
|
|
323 VALIGN="TOP"
|
|
324 >RGB->RGB without <TT
|
|
325 CLASS="LITERAL"
|
|
326 >SDL_SRCALPHA</TT
|
|
327 ></TD
|
|
328 ><TD
|
|
329 ALIGN="LEFT"
|
|
330 VALIGN="TOP"
|
|
331 ><P
|
|
332 >The RGB data is copied from the source. If <TT
|
|
333 CLASS="LITERAL"
|
|
334 >SDL_SRCCOLORKEY</TT
|
|
335 > is set, only the pixels not matching the colorkey value are copied.</P
|
|
336 ></TD
|
|
337 ></TR
|
|
338 ></TBODY
|
|
339 ></TABLE
|
|
340 ><P
|
|
341 ></P
|
|
342 ></DIV
|
|
343 ></DIV
|
|
344 ><DIV
|
|
345 CLASS="REFSECT1"
|
|
346 ><A
|
|
347 NAME="AEN1692"
|
|
348 ></A
|
|
349 ><H2
|
|
350 >See Also</H2
|
|
351 ><P
|
|
352 ><A
|
|
353 HREF="sdlmaprgba.html"
|
|
354 ><TT
|
|
355 CLASS="FUNCTION"
|
|
356 >SDL_MapRGBA</TT
|
|
357 ></A
|
|
358 >,
|
|
359 <A
|
|
360 HREF="sdlgetrgba.html"
|
|
361 ><TT
|
|
362 CLASS="FUNCTION"
|
|
363 >SDL_GetRGBA</TT
|
|
364 ></A
|
|
365 >,
|
|
366 <A
|
|
367 HREF="sdldisplayformatalpha.html"
|
|
368 ><TT
|
|
369 CLASS="FUNCTION"
|
|
370 >SDL_DisplayFormatAlpha</TT
|
|
371 ></A
|
|
372 >,
|
|
373 <A
|
|
374 HREF="sdlblitsurface.html"
|
|
375 ><TT
|
|
376 CLASS="FUNCTION"
|
|
377 >SDL_BlitSurface</TT
|
|
378 ></A
|
|
379 ></P
|
|
380 ></DIV
|
|
381 ><DIV
|
|
382 CLASS="NAVFOOTER"
|
|
383 ><HR
|
|
384 ALIGN="LEFT"
|
|
385 WIDTH="100%"><TABLE
|
|
386 WIDTH="100%"
|
|
387 BORDER="0"
|
|
388 CELLPADDING="0"
|
|
389 CELLSPACING="0"
|
|
390 ><TR
|
|
391 ><TD
|
|
392 WIDTH="33%"
|
|
393 ALIGN="left"
|
|
394 VALIGN="top"
|
|
395 ><A
|
|
396 HREF="sdlsetcolorkey.html"
|
|
397 >Prev</A
|
|
398 ></TD
|
|
399 ><TD
|
|
400 WIDTH="34%"
|
|
401 ALIGN="center"
|
|
402 VALIGN="top"
|
|
403 ><A
|
|
404 HREF="index.html"
|
|
405 >Home</A
|
|
406 ></TD
|
|
407 ><TD
|
|
408 WIDTH="33%"
|
|
409 ALIGN="right"
|
|
410 VALIGN="top"
|
|
411 ><A
|
|
412 HREF="sdlsetcliprect.html"
|
|
413 >Next</A
|
|
414 ></TD
|
|
415 ></TR
|
|
416 ><TR
|
|
417 ><TD
|
|
418 WIDTH="33%"
|
|
419 ALIGN="left"
|
|
420 VALIGN="top"
|
|
421 >SDL_SetColorKey</TD
|
|
422 ><TD
|
|
423 WIDTH="34%"
|
|
424 ALIGN="center"
|
|
425 VALIGN="top"
|
|
426 ><A
|
|
427 HREF="video.html"
|
|
428 >Up</A
|
|
429 ></TD
|
|
430 ><TD
|
|
431 WIDTH="33%"
|
|
432 ALIGN="right"
|
|
433 VALIGN="top"
|
|
434 >SDL_SetClipRect</TD
|
|
435 ></TR
|
|
436 ></TABLE
|
|
437 ></DIV
|
|
438 ></BODY
|
|
439 ></HTML
|
|
440 > |