Source

pygame / docs / pygame_surfarray.html

Full commit
<html>
<title>pygame.surfarray</title>
<body bgcolor=#dddddd text=#333377 link=#7777bb vlink=#7777bb>

<table border=0 width=100% cellpadding=0 cellspacing=0 bgcolor=#f5f5f5><tr valign=top>
<td rowspan=2 width=60%><table border=0 cellpadding=5 cellspacing=0 bgcolor=#333377>
<tr height=86 align=left><td valign=top><font color=#ffffff size=+5>
	<a href=../>
      <img src=mainlogo.gif width=300 height=100 alt="PyGame Logo" border=0></a></td>
<td valign=middle><tt><font color=#dddddd><br>
	PyGame<br>Documentation</font>
</td></tr></table></td><td width=100% height=100% align=center valign=middle>

	||&nbsp;
	<a href=../>Home</a> &nbsp;||&nbsp;
	<a href=index.html>Help Contents</a> &nbsp;||
	<br>&nbsp;<br>

|| <a href=CD.html>CD</a> || 
<a href=Channel.html>Channel</a> || 
<a href=Font.html>Font</a> || 
<a href=Joystick.html>Joystick</a> || 
<a href=Rect.html>Rect</a> ||<br>
|| <a href=Sound.html>Sound</a> || 
<a href=Surface.html>Surface</a> || 
<a href=pygame.html>pygame</a> || 
<a href=pygame_cdrom.html>cdrom</a> || 
<a href=pygame_display.html>display</a> ||<br>
|| <a href=pygame_event.html>event</a> || 
<a href=pygame_font.html>font</a> || 
<a href=pygame_image.html>image</a> || 
<a href=pygame_joystick.html>joystick</a> || 
<a href=pygame_key.html>key</a> ||<br>
|| <a href=pygame_mixer.html>mixer</a> || 
<a href=pygame_mouse.html>mouse</a> || 
<a href=pygame_music.html>music</a> || 
<a href=pygame_surfarray.html>surfarray</a> || 
<a href=pygame_time.html>time</a> ||<br>


</td></tr></table>
<br>
<h2 align=center>pygame.surfarray</h2>
Contains routines for mixing numeric arrays with
surfaces

<hr>

<table>
<tr><td><a href=#array2d>array2d</a></td><td> -
get a 2d array copied from a surface</td></tr>


<tr><td><a href=#array3d>array3d</a></td><td> -
get a 3d array copied from a surface</td></tr>


<tr><td><a href=#blit_array>blit_array</a></td><td> -
quickly transfer an array to a Surface</td></tr>


<tr><td><a href=#map_array>map_array</a></td><td> -
map an array with RGB values into mapped colors</td></tr>


<tr><td><a href=#pixels2d>pixels2d</a></td><td> -
get a 2d reference array to a surface</td></tr>


<tr><td><a href=#pixels3d>pixels3d</a></td><td> -
get a 3d reference array to a surface</td></tr>


</table>

<hr>

<a name=array2d><font size=+2><b>array2d
</b></font><br><font size=+1><tt>
pygame.surfarray.array2d(Surface) -> Array
</tt></font><ul>
This returns a new contigous 2d array. Think of it
as a 2d image array with a mapped pixel value at
each index.

You'll need the surface to be locked if that is
required. Once the array is created you can unlock
the surface.
</ul><br>&nbsp;<br>

<a name=array3d><font size=+2><b>array3d
</b></font><br><font size=+1><tt>
pygame.surfarray.array3d(Surface) -> Array
</tt></font><ul>
This returns a new contigous 3d array. Think of it
as a 2d image array with an RGB array for each
pixel value.

You'll need the surface to be locked if that is
required. Once the array is created you can unlock
the surface.
</ul><br>&nbsp;<br>

<a name=blit_array><font size=+2><b>blit_array
</b></font><br><font size=+1><tt>
pygame.surfarray.blit_array(surf, array) -> None
</tt></font><ul>
Transfer an array of any type (3d or 2d) onto a
Surface. The array must be the same dimensions as
the destination Surface. While you can assign the
values of an array to the pixel referenced arrays,
using this blit method will usually be quicker
because of it's smarter handling of noncontiguous
arrays. Plus it allows you to blit from any image
array type to any surface format in one step, no
conversions.
</ul><br>&nbsp;<br>

<a name=map_array><font size=+2><b>map_array
</b></font><br><font size=+1><tt>
pygame.surfarray.map_array(surf, array3d) -> array2d
</tt></font><ul>
Create a new array with the RGB pixel values of a
3d array into mapped color values in a 2D array.

Just so you know, this can also map a 2D array
with RGB values into a 1D array of mapped color
values
</ul><br>&nbsp;<br>

<a name=pixels2d><font size=+2><b>pixels2d
</b></font><br><font size=+1><tt>
pygame.surfarray.pixels2d(Surface) -> Array
</tt></font><ul>
This returns a new noncontigous 2d array that
directly effects a Surface's contents. Think of it
as a 2d image array with a mapped pixel value at
each index.

This will not work on 24bit surfaces, since there
is no native 24bit data type to access the pixel
values.

You'll need the surface to be locked if that is
required. Also be aware that between unlocking and
relocking a surface, the pixel data can be moved,
so don't hang onto this array after you have
unlocked the surface.
</ul><br>&nbsp;<br>

<a name=pixels3d><font size=+2><b>pixels3d
</b></font><br><font size=+1><tt>
pygame.surfarray.pixels3d(Surface) -> Array
</tt></font><ul>
This returns a new noncontigous 3d array that
directly effects a Surface's contents. Think of it
as a 2d image array with an RGB array for each
pixel value.

This will only work for 24 and 32 bit surfaces,
where the RGB components can be accessed without
requiring any masking.

You'll need the surface to be locked if that is
required. Also be aware that between unlocking and
relocking a surface, the pixel data can be moved,
so don't hang onto this array after you have
unlocked the surface.
</ul><br>&nbsp;<br>


<hr>

</body></html>