~ubuntu-branches/ubuntu/gutsy/pygame/gutsy

« back to all changes in this revision

Viewing changes to docs/ref/Surface.html

  • Committer: Bazaar Package Importer
  • Author(s): Ed Boraas
  • Date: 2002-02-20 06:39:24 UTC
  • Revision ID: james.westby@ubuntu.com-20020220063924-amlzj7tqkeods4eq
Tags: upstream-1.4
ImportĀ upstreamĀ versionĀ 1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html>
 
2
<title>Surface</title>
 
3
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>
 
4
 
 
5
 
 
6
<table cellspacing=3 width=100%><tr><td bgcolor=#00000>
 
7
<table width=100%><tr><td bgcolor=c2fc20 align=center>
 
8
    <a href=http://www.pygame.org>
 
9
    <img src=../pygame_tiny.gif border=0 width=200 height=60></a><br>
 
10
    <b>pygame&nbsp;&nbsp;&nbsp;documentation</b>
 
11
</td><td bgcolor=6aee28 align=center valign=top width=100%>
 
12
 
 
13
        ||&nbsp;
 
14
        <a href=http://www.pygame.org>Home</a> &nbsp;||&nbsp;
 
15
        <a href=../index.html>Help Contents</a> &nbsp;||
 
16
        <br>&nbsp;<br>
 
17
 
 
18
|| <a href=pygame.html>pygame</a> || 
 
19
<a href=pygame_cdrom.html>cdrom</a> || 
 
20
<a href=pygame_constants.html>constants</a> || 
 
21
<a href=pygame_display.html>display</a> || 
 
22
<a href=pygame_draw.html>draw</a> || 
 
23
<a href=pygame_event.html>event</a> ||<br>
 
24
|| <a href=pygame_font.html>font</a> || 
 
25
<a href=pygame_image.html>image</a> || 
 
26
<a href=pygame_joystick.html>joystick</a> || 
 
27
<a href=pygame_key.html>key</a> || 
 
28
<a href=pygame_mixer.html>mixer</a> || 
 
29
<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
 
30
|| <a href=pygame_mouse.html>mouse</a> || 
 
31
<a href=pygame_movie.html>movie</a> || 
 
32
<a href=pygame_surfarray.html>surfarray</a> || 
 
33
<a href=pygame_time.html>time</a> || 
 
34
<a href=pygame_transform.html>transform</a> ||<br>
 
35
&nbsp;<br>|| <a href=CD.html>CD</a> || 
 
36
<a href=Channel.html>Channel</a> || 
 
37
<a href=Clock.html>Clock</a> || 
 
38
<a href=Font.html>Font</a> || 
 
39
<a href=Joystick.html>Joystick</a> || 
 
40
<a href=Movie.html>Movie</a> ||<br>
 
41
|| <a href=Rect.html>Rect</a> || 
 
42
<a href=Sound.html>Sound</a> || 
 
43
<a href=Surface.html>Surface</a> ||<br>
 
44
&nbsp;<br>|| <a href=pygame_cursors.html>cursors</a> || 
 
45
<a href=pygame_sprite.html>sprite</a> || 
 
46
<a href=pygame_version.html>version</a> ||<br>
 
47
 
 
48
 
 
49
</td></tr></table></td></tr></table>
 
50
<br>
 
51
<h2 align=center>Surface</h2>
 
52
Surface objects represent a simple memory buffer of pixels.
 
53
Surface objects can reside in system memory, or in special
 
54
hardware memory, which can be hardware accelerated. Surfaces that
 
55
are 8 bits per pixel use a colormap to represent their color
 
56
values. All Surfaces with higher bits per pixel use a packed
 
57
pixels to store their color values.
 
58
<br>&nbsp;<br>
 
59
Surfaces can have many extra attributes like alpha planes,
 
60
colorkeys, source rectangle clipping. These functions mainly
 
61
effect how the Surface is blitted to other Surfaces. The blit
 
62
routines will attempt to use hardware acceleration when possible,
 
63
otherwise will use highly optimized software blitting methods.
 
64
<br>&nbsp;<br>
 
65
There is support for pixel access for the Surfaces. Pixel access
 
66
on hardware surfaces is slow and not recommended. Pixels can be
 
67
accessed using the <a href=#get_at>get_at()</a> and <a href=#set_at>set_at()</a> functions. These methods
 
68
are fine for simple access, but will be considerably slow when
 
69
doing of pixel work with them. If you plan on doing a lot of
 
70
pixel level work, it is recommended to use the pygame.surfarray
 
71
module, which can treat the surfaces like large multidimensional
 
72
arrays (and it's quite quick).<p>&nbsp;</p>Any functions that directly access a surface's pixel data will
 
73
need that surface to be <a href=#lock>lock()</a>'ed. These functions can <a href=#lock>lock()</a>
 
74
and <a href=#unlock>unlock()</a> the surfaces themselves without assistance. But, if
 
75
a function will be called many times, there will be a lot of overhead
 
76
for multiple locking and unlocking of the surface. It is best to lock
 
77
the surface manually before making the function call many times, and
 
78
then unlocking when you are finished. All functions that need a locked
 
79
surface will say so in their docs.
 
80
<br>&nbsp;<br>
 
81
Also remember that you will want to leave the surface locked for the
 
82
shortest amount of time needed.
 
83
<br>&nbsp;<br>
 
84
<br>&nbsp;<br>
 
85
Here is the quick breakdown of how packed pixels work (don't worry if
 
86
you don't quite understand this, it is only here for informational
 
87
purposes, it is not needed). Each colorplane mask can be used to
 
88
isolate the values for a colorplane from the packed pixel color.
 
89
Therefore PACKED_COLOR & RED_MASK == REDPLANE. Note that the
 
90
REDPLANE is not exactly the red color value, but it is the red
 
91
color value bitwise left shifted a certain amount. The losses and
 
92
masks can be used to convert back and forth between each
 
93
colorplane and the actual color for that plane. Here are the
 
94
final formulas used be map and unmap.
 
95
PACKED_COLOR = RED&gt;&gt;losses[0]&lt;&lt;shifts[0] |
 
96
      GREEN&gt;&gt;losses[1]&lt;&lt;shifts[1] | BLUE&gt;&gt;losses[2]&lt;&lt;shifts[2]
 
97
RED = PACKED_COLOR & masks[0] &gt;&gt; shifts[0] &lt;&lt; losses[0]
 
98
GREEN = PACKED_COLOR & masks[1] &gt;&gt; shifts[1] &lt;&lt; losses[1]
 
99
BLUE = PACKED_COLOR & masks[2] &gt;&gt; shifts[2] &lt;&lt; losses[2]
 
100
There is also an alpha channel for some Surfaces.
 
101
 
 
102
<hr>
 
103
 
 
104
<table>
 
105
<tr><td><a href=#blit>blit</a></td><td> -
 
106
copy a one Surface to another.</td></tr>
 
107
 
 
108
 
 
109
<tr><td><a href=#convert>convert</a></td><td> -
 
110
new copy of surface with different format</td></tr>
 
111
 
 
112
 
 
113
<tr><td><a href=#convert_alpha>convert_alpha</a></td><td> -
 
114
new copy of surface with different format and per pixel alpha</td></tr>
 
115
 
 
116
 
 
117
<tr><td><a href=#fill>fill</a></td><td> -
 
118
fill areas of a Surface</td></tr>
 
119
 
 
120
 
 
121
<tr><td><a href=#get_alpha>get_alpha</a></td><td> -
 
122
query alpha information</td></tr>
 
123
 
 
124
 
 
125
<tr><td><a href=#get_at>get_at</a></td><td> -
 
126
get a pixel color</td></tr>
 
127
 
 
128
 
 
129
<tr><td><a href=#get_bitsize>get_bitsize</a></td><td> -
 
130
query size of pixel</td></tr>
 
131
 
 
132
 
 
133
<tr><td><a href=#get_bytesize>get_bytesize</a></td><td> -
 
134
query size of pixel</td></tr>
 
135
 
 
136
 
 
137
<tr><td><a href=#get_clip>get_clip</a></td><td> -
 
138
query the clipping area</td></tr>
 
139
 
 
140
 
 
141
<tr><td><a href=#get_colorkey>get_colorkey</a></td><td> -
 
142
query colorkey</td></tr>
 
143
 
 
144
 
 
145
<tr><td><a href=#get_flags>get_flags</a></td><td> -
 
146
query the surface flags</td></tr>
 
147
 
 
148
 
 
149
<tr><td><a href=#get_height>get_height</a></td><td> -
 
150
query the surface height</td></tr>
 
151
 
 
152
 
 
153
<tr><td><a href=#get_locked>get_locked</a></td><td> -
 
154
check if the surface needs locking</td></tr>
 
155
 
 
156
 
 
157
<tr><td><a href=#get_losses>get_losses</a></td><td> -
 
158
get mapping losses for each colorplane</td></tr>
 
159
 
 
160
 
 
161
<tr><td><a href=#get_masks>get_masks</a></td><td> -
 
162
get mapping bitmasks for each colorplane</td></tr>
 
163
 
 
164
 
 
165
<tr><td><a href=#get_palette>get_palette</a></td><td> -
 
166
get the palette</td></tr>
 
167
 
 
168
 
 
169
<tr><td><a href=#get_palette_at>get_palette_at</a></td><td> -
 
170
get a palette entry</td></tr>
 
171
 
 
172
 
 
173
<tr><td><a href=#get_pitch>get_pitch</a></td><td> -
 
174
query the surface pitch</td></tr>
 
175
 
 
176
 
 
177
<tr><td><a href=#get_rect>get_rect</a></td><td> -
 
178
get a rectangle covering the entire surface</td></tr>
 
179
 
 
180
 
 
181
<tr><td><a href=#get_shifts>get_shifts</a></td><td> -
 
182
alphashift</td></tr>
 
183
 
 
184
 
 
185
<tr><td><a href=#get_size>get_size</a></td><td> -
 
186
query the surface size</td></tr>
 
187
 
 
188
 
 
189
<tr><td><a href=#get_width>get_width</a></td><td> -
 
190
query the surface width</td></tr>
 
191
 
 
192
 
 
193
<tr><td><a href=#lock>lock</a></td><td> -
 
194
locks Surface for pixel access</td></tr>
 
195
 
 
196
 
 
197
<tr><td><a href=#map_rgb>map_rgb</a></td><td> -
 
198
convert RGB into a mapped color</td></tr>
 
199
 
 
200
 
 
201
<tr><td><a href=#mustlock>mustlock</a></td><td> -
 
202
check if the surface needs locking</td></tr>
 
203
 
 
204
 
 
205
<tr><td><a href=#set_alpha>set_alpha</a></td><td> -
 
206
change alpha information</td></tr>
 
207
 
 
208
 
 
209
<tr><td><a href=#set_at>set_at</a></td><td> -
 
210
set pixel at given position</td></tr>
 
211
 
 
212
 
 
213
<tr><td><a href=#set_clip>set_clip</a></td><td> -
 
214
assign destination clipping rectangle</td></tr>
 
215
 
 
216
 
 
217
<tr><td><a href=#set_colorkey>set_colorkey</a></td><td> -
 
218
change colorkey information</td></tr>
 
219
 
 
220
 
 
221
<tr><td><a href=#set_palette>set_palette</a></td><td> -
 
222
set the palette</td></tr>
 
223
 
 
224
 
 
225
<tr><td><a href=#set_palette_at>set_palette_at</a></td><td> -
 
226
set a palette entry</td></tr>
 
227
 
 
228
 
 
229
<tr><td><a href=#subsurface>subsurface</a></td><td> -
 
230
create a new surface that shares pixel data</td></tr>
 
231
 
 
232
 
 
233
<tr><td><a href=#unlock>unlock</a></td><td> -
 
234
locks Surface for pixel access</td></tr>
 
235
 
 
236
 
 
237
<tr><td><a href=#unmap_rgb>unmap_rgb</a></td><td> -
 
238
convert mapped color into RGB</td></tr>
 
239
 
 
240
 
 
241
</table>
 
242
 
 
243
<hr>
 
244
 
 
245
<a name=blit><font size=+2><b>blit
 
246
</b></font><br><font size=+1><tt>
 
247
Surface.blit(source, destpos, [sourcerect]) -> Rect
 
248
</tt></font><ul>
 
249
The blitting will transfer one surface to another. It will
 
250
respect any special modes like colorkeying and alpha. If hardware
 
251
support is available, it will be used. The given source is the
 
252
Surface to copy from. The destoffset is a 2-number-sequence that
 
253
specifies where on the destination Surface the blit happens (see below).
 
254
When sourcerect isn't supplied, the blit will copy the
 
255
entire source surface. If you would like to copy only a portion
 
256
of the source, use the sourcerect argument to control
 
257
what area is copied.
 
258
<br>&nbsp;<br>
 
259
The blit is subject to be clipped by the active clipping
 
260
rectangle. The return value contains the actual area blitted.
 
261
<br>&nbsp;<br>
 
262
As a shortcut, the destination position can be passed as a
 
263
rectangle. If a rectangle is given, the blit will use the topleft
 
264
corner of the rectangle as the blit destination position. The
 
265
rectangle sizes will be ignored.
 
266
 
 
267
<br>&nbsp;<br>
 
268
Note that blitting surfaces with alpha onto 8bit destinations will
 
269
not use the surface alpha values.
 
270
 
 
271
</ul><br>&nbsp;<br>
 
272
 
 
273
<a name=convert><font size=+2><b>convert
 
274
</b></font><br><font size=+1><tt>
 
275
Surface.convert([src_surface] OR depth, [flags] OR masks) -> Surface
 
276
</tt></font><ul>
 
277
Creates a new copy of the surface with the desired pixel format.
 
278
Surfaces with the same pixel format will blit much faster than
 
279
those with mixed formats. The pixel format of the new surface
 
280
will match the format given as the argument. If no surface is
 
281
given, the new surface will have the same pixel format as the
 
282
current display.
 
283
<br>&nbsp;<br>
 
284
convert() will also accept bitsize or mask arguments like the
 
285
Surface() constructor function. Either pass an integer bitsize
 
286
or a sequence of color masks to specify the format of surface
 
287
you would like to convert to. When used this way you may also
 
288
pass an optional flags argument (whew).
 
289
</ul><br>&nbsp;<br>
 
290
 
 
291
<a name=convert_alpha><font size=+2><b>convert_alpha
 
292
</b></font><br><font size=+1><tt>
 
293
Surface.convert_alpha([src_surface]) -> Surface
 
294
</tt></font><ul>
 
295
Creates a new copy of the surface with the desired pixel format.
 
296
The new surface will be in a format suited for quick blitting to
 
297
the given format with per pixel alpha. If no surface is given,
 
298
the new surface will be optimized for blittint to the current
 
299
display.
 
300
<br>&nbsp;<br>
 
301
Unlike the <a href=#convert>convert()</a> method, the pixel format for the new image
 
302
will not be exactly the same as the requested source, but it will
 
303
be optimized for fast alpha blitting to the destination.
 
304
</ul><br>&nbsp;<br>
 
305
 
 
306
<a name=fill><font size=+2><b>fill
 
307
</b></font><br><font size=+1><tt>
 
308
Surface.fill(color, [rectstyle])) -> Rect
 
309
</tt></font><ul>
 
310
Fills the specified area of the Surface with the mapped color
 
311
value. If no destination rectangle is supplied, it will fill the
 
312
entire Surface.
 
313
<br>&nbsp;<br>
 
314
The color argument can be a RGBA sequence or a mapped color integer.
 
315
<br>&nbsp;<br>
 
316
The fill is subject to be clipped by the active clipping
 
317
rectangle. The return value contains the actual area filled.
 
318
</ul><br>&nbsp;<br>
 
319
 
 
320
<a name=get_alpha><font size=+2><b>get_alpha
 
321
</b></font><br><font size=+1><tt>
 
322
Surface.get_alpha() -> alpha
 
323
</tt></font><ul>
 
324
Returns the current alpha value for the Surface. If transparency
 
325
is disabled for the Surface, it returns None.
 
326
</ul><br>&nbsp;<br>
 
327
 
 
328
<a name=get_at><font size=+2><b>get_at
 
329
</b></font><br><font size=+1><tt>
 
330
Surface.get_at(position) -> RGBA
 
331
</tt></font><ul>
 
332
Returns the RGB color values at a given pixel. If the
 
333
Surface has no per-pixel alpha, the alpha will be 255 (opaque).
 
334
<br>&nbsp;<br>
 
335
This function will need to temporarily lock the surface.
 
336
</ul><br>&nbsp;<br>
 
337
 
 
338
<a name=get_bitsize><font size=+2><b>get_bitsize
 
339
</b></font><br><font size=+1><tt>
 
340
Surface.get_bitsize() -> int
 
341
</tt></font><ul>
 
342
Returns the number of bits used to represent each pixel. This
 
343
value may not exactly fill the number of bytes used per pixel.
 
344
For example a 15 bit Surface still requires a full 2 bytes.
 
345
</ul><br>&nbsp;<br>
 
346
 
 
347
<a name=get_bytesize><font size=+2><b>get_bytesize
 
348
</b></font><br><font size=+1><tt>
 
349
Surface.get_bytesize() -> int
 
350
</tt></font><ul>
 
351
Returns the number of bytes used to store each pixel.
 
352
</ul><br>&nbsp;<br>
 
353
 
 
354
<a name=get_clip><font size=+2><b>get_clip
 
355
</b></font><br><font size=+1><tt>
 
356
Surface.get_clip() -> rect
 
357
</tt></font><ul>
 
358
Returns the current destination clipping area being used by the
 
359
Surface. If the clipping area is not set, it will return a
 
360
rectangle containing the full Surface area.
 
361
</ul><br>&nbsp;<br>
 
362
 
 
363
<a name=get_colorkey><font size=+2><b>get_colorkey
 
364
</b></font><br><font size=+1><tt>
 
365
Surface.get_colorkey() -> RGBA
 
366
</tt></font><ul>
 
367
Returns the current mapped color value being used for
 
368
colorkeying. If colorkeying is not enabled for this surface, it
 
369
returns None
 
370
</ul><br>&nbsp;<br>
 
371
 
 
372
<a name=get_flags><font size=+2><b>get_flags
 
373
</b></font><br><font size=+1><tt>
 
374
Surface.get_flags() -> flags
 
375
</tt></font><ul>
 
376
Returns the current state flags for the surface.
 
377
</ul><br>&nbsp;<br>
 
378
 
 
379
<a name=get_height><font size=+2><b>get_height
 
380
</b></font><br><font size=+1><tt>
 
381
Surface.get_height() -> height
 
382
</tt></font><ul>
 
383
Returns the height of the Surface.
 
384
</ul><br>&nbsp;<br>
 
385
 
 
386
<a name=get_locked><font size=+2><b>get_locked
 
387
</b></font><br><font size=+1><tt>
 
388
Surface.get_locked() -> bool
 
389
</tt></font><ul>
 
390
Returns true if the surface is currently locked.
 
391
</ul><br>&nbsp;<br>
 
392
 
 
393
<a name=get_losses><font size=+2><b>get_losses
 
394
</b></font><br><font size=+1><tt>
 
395
Surface.get_losses() -> redloss, greenloss, blueloss, alphaloss
 
396
</tt></font><ul>
 
397
Returns the bitloss for each color plane. The loss is the number
 
398
of bits removed for each colorplane from a full 8 bits of
 
399
resolution. A value of 8 usually indicates that colorplane is not
 
400
used (like the alpha)
 
401
</ul><br>&nbsp;<br>
 
402
 
 
403
<a name=get_masks><font size=+2><b>get_masks
 
404
</b></font><br><font size=+1><tt>
 
405
Surface.get_masks() -> redmask, greenmask, bluemask, alphamask
 
406
</tt></font><ul>
 
407
Returns the bitmasks for each color plane. The bitmask is used to
 
408
isolate each colorplane value from a mapped color value. A value
 
409
of zero means that colorplane is not used (like alpha)
 
410
</ul><br>&nbsp;<br>
 
411
 
 
412
<a name=get_palette><font size=+2><b>get_palette
 
413
</b></font><br><font size=+1><tt>
 
414
Surface.get_palette() -> [[r, g, b], ...]
 
415
</tt></font><ul>
 
416
This will return the an array of all the color indexes in the
 
417
Surface's palette.
 
418
</ul><br>&nbsp;<br>
 
419
 
 
420
<a name=get_palette_at><font size=+2><b>get_palette_at
 
421
</b></font><br><font size=+1><tt>
 
422
Surface.get_palette_at(index) -> r, g, b
 
423
</tt></font><ul>
 
424
This will retreive an individual color entry from the Surface's
 
425
palette.
 
426
</ul><br>&nbsp;<br>
 
427
 
 
428
<a name=get_pitch><font size=+2><b>get_pitch
 
429
</b></font><br><font size=+1><tt>
 
430
Surface.get_pitch() -> pitch
 
431
</tt></font><ul>
 
432
The surface pitch is the number of bytes used in each
 
433
scanline. This function should rarely needed, mainly for
 
434
any special-case debugging.
 
435
</ul><br>&nbsp;<br>
 
436
 
 
437
<a name=get_rect><font size=+2><b>get_rect
 
438
</b></font><br><font size=+1><tt>
 
439
Surface.get_rect() -> rect
 
440
</tt></font><ul>
 
441
Returns a new rectangle covering the entire surface.
 
442
This rectangle will always start at 0, 0 with a width.
 
443
and height the same size as the image.
 
444
</ul><br>&nbsp;<br>
 
445
 
 
446
<a name=get_shifts><font size=+2><b>get_shifts
 
447
</b></font><br><font size=+1><tt>
 
448
Surface.get_shifts() -> redshift, greenshift, blueshift,
 
449
</tt></font><ul>
 
450
<br>&nbsp;<br>
 
451
Returns the bitshifts used for each color plane. The shift is
 
452
determine how many bits left-shifted a colorplane value is in a
 
453
mapped color value.
 
454
</ul><br>&nbsp;<br>
 
455
 
 
456
<a name=get_size><font size=+2><b>get_size
 
457
</b></font><br><font size=+1><tt>
 
458
Surface.get_size() -> x, y
 
459
</tt></font><ul>
 
460
Returns the width and height of the Surface.
 
461
</ul><br>&nbsp;<br>
 
462
 
 
463
<a name=get_width><font size=+2><b>get_width
 
464
</b></font><br><font size=+1><tt>
 
465
Surface.get_width() -> width
 
466
</tt></font><ul>
 
467
Returns the width of the Surface.
 
468
</ul><br>&nbsp;<br>
 
469
 
 
470
<a name=lock><font size=+2><b>lock
 
471
</b></font><br><font size=+1><tt>
 
472
Surface.lock() -> None
 
473
</tt></font><ul>
 
474
On accelerated surfaces, it is usually required to lock the
 
475
surface before you can access the pixel values. To be safe, it is
 
476
always a good idea to lock the surface before entering a block of
 
477
code that changes or accesses the pixel values. The surface must
 
478
not be locked when performing other pygame functions on it like
 
479
fill and blit.
 
480
<br>&nbsp;<br>
 
481
You can doublecheck to really make sure a lock is needed by
 
482
calling the <a href=#mustlock>mustlock()</a> member. This should not be needed, since
 
483
it is usually recommended to lock anyways and work with all
 
484
surface types. If the surface does not need to be locked, the
 
485
operation will return quickly with minute overhead.
 
486
<br>&nbsp;<br>
 
487
On some platforms a necessary lock can shut off some parts of the
 
488
system. This is not a problem unless you leave surfaces locked
 
489
for long periouds of time. Only keep the surface locked when you
 
490
need the pixel access. At the same time, it is not a good too
 
491
repeatedly lock and unlock the surface inside tight loops. It is
 
492
fine to leave the surface locked while needed, just don't be
 
493
lazy.
 
494
</ul><br>&nbsp;<br>
 
495
 
 
496
<a name=map_rgb><font size=+2><b>map_rgb
 
497
</b></font><br><font size=+1><tt>
 
498
Surface.map_rgb(RGBA) -> int
 
499
</tt></font><ul>
 
500
Uses the Surface format to convert RGBA into a mapped color value.
 
501
<br>&nbsp;<br>
 
502
This function is not as needed as normal C code using SDL. The pygame
 
503
functions do not used mapped colors, so there is no need to map them.
 
504
</ul><br>&nbsp;<br>
 
505
 
 
506
<a name=mustlock><font size=+2><b>mustlock
 
507
</b></font><br><font size=+1><tt>
 
508
Surface.mustlock() -> bool
 
509
</tt></font><ul>
 
510
Returns true if the surface really does need locking to gain
 
511
pixel access. Usually the overhead of checking before locking
 
512
outweight the overhead of just locking any surface before access.
 
513
</ul><br>&nbsp;<br>
 
514
 
 
515
<a name=set_alpha><font size=+2><b>set_alpha
 
516
</b></font><br><font size=+1><tt>
 
517
Surface.set_alpha([alpha, [flags]]) -> None
 
518
</tt></font><ul>
 
519
Set the overall transparency for the surface. If no alpha is
 
520
passed, alpha blending is disabled for the surface. An alpha of 0
 
521
is fully transparent, an alpha of 255 is fully opaque. If no
 
522
arguments or None is passed, this will disable the surface alpha.
 
523
<br>&nbsp;<br>
 
524
If your surface has a pixel alpha channel, it will override the
 
525
overall surface transparency. You'll need to change the actual
 
526
pixel transparency to make changes.
 
527
<br>&nbsp;<br>
 
528
If your image also has pixel alpha values, will be used repeatedly, you
 
529
will probably want to pass the RLEACCEL flag to the call. This
 
530
will take a short time to compile your surface, and increase the
 
531
blitting speed.
 
532
</ul><br>&nbsp;<br>
 
533
 
 
534
<a name=set_at><font size=+2><b>set_at
 
535
</b></font><br><font size=+1><tt>
 
536
Surface.set_at(position, RGBA) -> None
 
537
</tt></font><ul>
 
538
Assigns color to the image at the give position. Color can be a
 
539
RGBA sequence or a mapped color integer.
 
540
<br>&nbsp;<br>
 
541
In some situations just using the <a href=#fill>fill()</a> function with a one-pixel
 
542
sized rectangle will be quicker. Also the fill function does not
 
543
require the surface to be locked.
 
544
<br>&nbsp;<br>
 
545
This function will need to temporarily lock the surface.
 
546
</ul><br>&nbsp;<br>
 
547
 
 
548
<a name=set_clip><font size=+2><b>set_clip
 
549
</b></font><br><font size=+1><tt>
 
550
Surface.set_clip([rectstyle]) -> None
 
551
</tt></font><ul>
 
552
Assigns the destination clipping rectangle for the Surface. When
 
553
blit or fill operations are performed on the Surface, they are
 
554
restricted to the inside of the clipping rectangle. If no
 
555
rectangle is passed, the clipping region is set to the entire
 
556
Surface area. The rectangle you pass will be clipped to the area of
 
557
the Surface.
 
558
</ul><br>&nbsp;<br>
 
559
 
 
560
<a name=set_colorkey><font size=+2><b>set_colorkey
 
561
</b></font><br><font size=+1><tt>
 
562
Surface.set_colorkey([color, [flags]]) -> None
 
563
</tt></font><ul>
 
564
Set the colorkey for the surface by passing a mapped color value
 
565
as the color argument. If no arguments or None is passed,
 
566
colorkeying will be disabled for this surface.
 
567
<br>&nbsp;<br>
 
568
The color argument can be either a RGBA sequence or a mapped integer.
 
569
<br>&nbsp;<br>
 
570
If your image is nonchanging and will be used repeatedly, you
 
571
will probably want to pass the RLEACCEL flag to the call. This
 
572
will take a short time to compile your surface, and increase the
 
573
blitting speed.
 
574
</ul><br>&nbsp;<br>
 
575
 
 
576
<a name=set_palette><font size=+2><b>set_palette
 
577
</b></font><br><font size=+1><tt>
 
578
Surface.set_palette([[r, g, b], ...]) -> None
 
579
</tt></font><ul>
 
580
This will replace the entire palette with color
 
581
information you provide.
 
582
<br>&nbsp;<br>
 
583
You can pass an incomplete list of RGB values, and
 
584
this will only change the first colors in the palette.
 
585
</ul><br>&nbsp;<br>
 
586
 
 
587
<a name=set_palette_at><font size=+2><b>set_palette_at
 
588
</b></font><br><font size=+1><tt>
 
589
Surface.set_palette_at(index, [r, g, b]) -> None
 
590
</tt></font><ul>
 
591
This function sets the palette color at a specific entry.
 
592
</ul><br>&nbsp;<br>
 
593
 
 
594
<a name=subsurface><font size=+2><b>subsurface
 
595
</b></font><br><font size=+1><tt>
 
596
Surface.subsurface(rectstyle) -> Surface
 
597
</tt></font><ul>
 
598
Creates a new surface that shares pixel data of the given surface.
 
599
Note that only the pixel data is shared. Things like clipping rectangles
 
600
and colorkeys will be unique for the new surface.
 
601
<br>&nbsp;<br>
 
602
The new subsurface will inherit the palette, colorkey, and surface alpha
 
603
values from the base image.
 
604
<br>&nbsp;<br>
 
605
You should not use the RLEACCEL flag for parent surfaces of subsurfaces,
 
606
for the most part it will work, but it will cause a lot of extra work,
 
607
every time you change the subsurface, you must decode and recode the
 
608
RLEACCEL data for the parent surface.
 
609
<br>&nbsp;<br>
 
610
As for using RLEACCEL with the subsurfaces, that will work as you'd
 
611
expect, but changes the the parent Surface will not always take effect
 
612
in the subsurface.
 
613
</ul><br>&nbsp;<br>
 
614
 
 
615
<a name=unlock><font size=+2><b>unlock
 
616
</b></font><br><font size=+1><tt>
 
617
Surface.unlock() -> None
 
618
</tt></font><ul>
 
619
After a surface has been locked, you will need to unlock it when
 
620
you are done.
 
621
<br>&nbsp;<br>
 
622
You can doublecheck to really make sure a lock is needed by
 
623
calling the <a href=#mustlock>mustlock()</a> member. This should not be needed, since
 
624
it is usually recommended to lock anyways and work with all
 
625
surface types. If the surface does not need to be locked, the
 
626
operation will return quickly with minute overhead.
 
627
</ul><br>&nbsp;<br>
 
628
 
 
629
<a name=unmap_rgb><font size=+2><b>unmap_rgb
 
630
</b></font><br><font size=+1><tt>
 
631
Surface.unmap_rgb(color) -> RGBA
 
632
</tt></font><ul>
 
633
This function returns the RGBA components for a mapped color
 
634
value. If Surface has no per-pixel alpha, alpha will be 255 (opaque).
 
635
<br>&nbsp;<br>
 
636
This function is not as needed as normal C code using SDL. The pygame
 
637
functions do not used mapped colors, so there is no need to unmap them.
 
638
</ul><br>&nbsp;<br>
 
639
 
 
640
 
 
641
<hr>
 
642
</body></html>