5131
clevermous
1
2
>
3
>
4
>SDL_BlitSurface
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_ConvertSurface"
17
HREF="sdlconvertsurface.html">
18
REL="NEXT"
19
TITLE="SDL_FillRect"
20
HREF="sdlfillrect.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="sdlconvertsurface.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="sdlfillrect.html"
61
>Next
62
>
63
>
64
>
65
>
66
ALIGN="LEFT"
67
WIDTH="100%">
68
>
69
>
70
NAME="SDLBLITSURFACE"
71
>SDL_BlitSurface
72
>
73
>
74
CLASS="REFNAMEDIV"
75
>
76
NAME="AEN1883"
77
>
78
>
79
>Name
80
>SDL_BlitSurface -- This performs a fast blit from the source surface to the destination surface.
81
>
82
CLASS="REFSYNOPSISDIV"
83
>
84
NAME="AEN1886"
85
>
86
>
87
>Synopsis
88
>
89
CLASS="FUNCSYNOPSIS"
90
>
91
NAME="AEN1887"
92
>
93
>
94
>
95
>
96
CLASS="FUNCSYNOPSISINFO"
97
>#include "SDL.h"
98
>
99
>
100
>
101
CLASS="FUNCDEF"
102
>int
103
CLASS="FSFUNC"
104
>SDL_BlitSurface
105
>
106
>(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect);
107
>
108
>
109
>
110
>
111
>
112
>
113
CLASS="REFSECT1"
114
>
115
NAME="AEN1893"
116
>
117
>
118
>Description
119
>
120
>This performs a fast blit from the source surface to the destination surface.
121
>
122
>Only the position is used in the
123
CLASS="PARAMETER"
124
>
125
>dstrect
126
>
127
> (the
128
width and height are ignored).
129
>
130
>If either
131
CLASS="PARAMETER"
132
>
133
>srcrect
134
>
135
> or
136
137
CLASS="PARAMETER"
138
>
139
>dstrect
140
>
141
> are
142
CLASS="LITERAL"
143
>NULL
144
>, the entire
145
surface (
146
CLASS="PARAMETER"
147
>
148
>src
149
>
150
> or
151
CLASS="PARAMETER"
152
>
153
>dst
154
>
155
>) is
156
copied.
157
>
158
>The final blit rectangle is saved in
159
160
CLASS="PARAMETER"
161
>
162
>dstrect
163
>
164
> after all clipping is performed
165
(
166
CLASS="PARAMETER"
167
>
168
>srcrect
169
>
170
> is not modified).
171
>
172
>The blit function should not be called on a locked surface.
173
>
174
>The results of blitting operations vary greatly depending on whether
175
CLASS="LITERAL"
176
>SDL_SRCAPLHA
177
> is set or not. See
178
HREF="sdlsetalpha.html"
179
>SDL_SetAlpha
180
> for an explaination of how this affects your results. Colorkeying and alpha attributes also interact with surface blitting, as the following pseudo-code should hopefully explain.
181
182
CLASS="PROGRAMLISTING"
183
>if (source surface has SDL_SRCALPHA set) {
184
if (source surface has alpha channel (that is, format->Amask != 0))
185
blit using per-pixel alpha, ignoring any colour key
186
else {
187
if (source surface has SDL_SRCCOLORKEY set)
188
blit using the colour key AND the per-surface alpha value
189
else
190
blit using the per-surface alpha value
191
}
192
} else {
193
if (source surface has SDL_SRCCOLORKEY set)
194
blit using the colour key
195
else
196
ordinary opaque rectangular blit
197
}
198
>
199
>
200
>
201
CLASS="REFSECT1"
202
>
203
NAME="AEN1912"
204
>
205
>
206
>Return Value
207
>
208
>If the blit is successful, it returns
209
CLASS="RETURNVALUE"
210
>0
211
>,
212
otherwise it returns
213
CLASS="RETURNVALUE"
214
>-1
215
>.
216
>
217
>If either of the surfaces were in video memory, and the blit returns
218
219
CLASS="RETURNVALUE"
220
>-2
221
>, the video memory was lost, so it should be
222
reloaded with artwork and re-blitted:
223
224
CLASS="PROGRAMLISTING"
225
> while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) {
226
while ( SDL_LockSurface(image)) < 0 )
227
Sleep(10);
228
-- Write image pixels to image->pixels --
229
SDL_UnlockSurface(image);
230
}
231
>
232
This happens under DirectX 5.0 when the system switches away from your
233
fullscreen application. Locking the surface will also fail until you
234
have access to the video memory again.
235
>
236
>
237
CLASS="REFSECT1"
238
>
239
NAME="AEN1920"
240
>
241
>
242
>See Also
243
>
244
>
245
HREF="sdllocksurface.html"
246
>
247
CLASS="FUNCTION"
248
>SDL_LockSurface
249
>
250
>,
251
252
HREF="sdlfillrect.html"
253
>
254
CLASS="FUNCTION"
255
>SDL_FillRect
256
>
257
>,
258
259
HREF="sdlsurface.html"
260
>
261
CLASS="STRUCTNAME"
262
>SDL_Surface
263
>
264
>,
265
266
HREF="sdlrect.html"
267
>
268
CLASS="STRUCTNAME"
269
>SDL_Rect
270
>
271
>
272
>
273
>
274
CLASS="NAVFOOTER"
275
>
276
ALIGN="LEFT"
277
WIDTH="100%">
329
>
330
>
331
>
332
>