Commits

Anonymous committed 5c55c84

Added pygame.get_sdl_byteorder() to get the SDL byte order. Added pixelarray and mask html docs. Fixed buffer length in surface.get_buffer().

Comments (0)

Files changed (9)

docs/ref/index.html

 <ul>
 <li><a href="pygame.html#pygame.error">pygame.error</a> - <font size=-1>standard pygame exception</font></li>
 <li><a href="pygame.html#pygame.get_error">pygame.get_error</a> - <font size=-1>get the current error message</font></li>
+<li><a href="pygame.html#pygame.get_sdl_byteorder">pygame.get_sdl_byteorder</a> - <font size=-1>get the byte order of SDL</font></li>
 <li><a href="pygame.html#pygame.get_sdl_version">pygame.get_sdl_version</a> - <font size=-1>get the version number of SDL</font></li>
 <li><a href="pygame.html#pygame.init">pygame.init</a> - <font size=-1>initialize all imported pygame modules</font></li>
 <li><a href="cdrom.html#pygame.cdrom">pygame.cdrom</a> - <font size=-1>pygame module for audio cdrom control</font></li>

docs/ref/mask.html

+
+<html>
+<title>mask - Pygame Documentation</title>
+<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>
+
+
+<table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
+<tr>
+<td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
+<td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
+	||&nbsp;
+	<a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
+	<a href=../index.html>Help Contents</a> &nbsp;||
+	<a href=index.html>Reference Index</a> &nbsp;||
+	<br>&nbsp;<br>
+	
+<a href=cdrom.html>Cdrom</a>&nbsp;||&nbsp;
+<a href=cursors.html>Cursors</a>&nbsp;||&nbsp;
+<a href=display.html>Display</a>&nbsp;||&nbsp;
+<a href=draw.html>Draw</a>&nbsp;||&nbsp;
+<a href=event.html>Event</a>&nbsp;||&nbsp;
+<a href=font.html>Font</a>&nbsp;||&nbsp;
+<a href=image.html>Image</a>&nbsp;||&nbsp;
+<a href=joystick.html>Joystick</a>&nbsp;||&nbsp;
+<a href=key.html>Key</a>&nbsp;||&nbsp;
+<a href=mask.html>Mask</a>&nbsp;||&nbsp;
+<a href=mixer.html>Mixer</a>&nbsp;||&nbsp;
+<a href=mouse.html>Mouse</a>&nbsp;||&nbsp;
+<a href=movie.html>Movie</a>&nbsp;||&nbsp;
+<a href=music.html>Music</a>&nbsp;||&nbsp;
+<a href=overlay.html>Overlay</a>&nbsp;||&nbsp;
+<a href=pixelarray.html>Pixelarray</a>&nbsp;||&nbsp;
+<a href=pygame.html>Pygame</a>&nbsp;||&nbsp;
+<a href=rect.html>Rect</a>&nbsp;||&nbsp;
+<a href=scrap.html>Scrap</a>&nbsp;||&nbsp;
+<a href=sndarray.html>Sndarray</a>&nbsp;||&nbsp;
+<a href=sprite.html>Sprite</a>&nbsp;||&nbsp;
+<a href=surface.html>Surface</a>&nbsp;||&nbsp;
+<a href=surfarray.html>Surfarray</a>&nbsp;||&nbsp;
+<a href=time.html>Time</a>&nbsp;||&nbsp;
+<a href=transform.html>Transform</a>
+</td></tr></table>
+<br>
+
+
+<a name="pygame.mask">
+<big><b>pygame.mask</big></b><br><ul>
+  <i>pygame module for image masks.</i><br>
+<ul><small><table>
+  <tr><td><a href="mask.html#pygame.mask.pygame.mask.from_surface">pygame.mask.pygame.mask.from_surface</a> - <font size=-1>Returns the size of the mask.</font></td><td>Returns the size of the mask.</td></tr>
+  <tr><td><a href="mask.html#pygame.mask.pygame.Mask">pygame.mask.pygame.Mask</a> - <font size=-1>pygame object for representing 2d bitmasks</font></td><td>pygame object for representing 2d bitmasks</td></tr>
+  <tr><td><a href="mask.html#pygame.mask.get_size">pygame.mask.get_size</a> - <font size=-1>Returns the size of the mask.</font></td><td>Returns the size of the mask.</td></tr>
+  <tr><td><a href="mask.html#pygame.mask.get_at">pygame.mask.get_at</a> - <font size=-1>Returns nonzero if the bit at (x,y) is set.</font></td><td>Returns nonzero if the bit at (x,y) is set.</td></tr>
+  <tr><td><a href="mask.html#pygame.mask.set_at">pygame.mask.set_at</a> - <font size=-1>Sets the position in the mask given by x and y.</font></td><td>Sets the position in the mask given by x and y.</td></tr>
+  <tr><td><a href="mask.html#pygame.mask.overlap">pygame.mask.overlap</a> - <font size=-1>Returns nonzero if the masks overlap with the given offset.</font></td><td>Returns nonzero if the masks overlap with the given offset.</td></tr>
+  <tr><td><a href="mask.html#pygame.mask.overlap_area">pygame.mask.overlap_area</a> - <font size=-1>Returns the number of overlapping 'pixels'.</font></td><td>Returns the number of overlapping 'pixels'.</td></tr>
+  <tr><td><a href="mask.html#pygame.mask.get_bounding_rects">pygame.mask.get_bounding_rects</a> - <font size=-1>Returns a list of bounding rects of regions of set pixels.</font></td><td>Returns a list of bounding rects of regions of set pixels.</td></tr>
+  <tr><td>None</td><td></td></tr>
+</table></small></ul>
+<p>Useful for fast pixel perfect collision detection. <tt>A</tt> Mask uses 1bit per pixel to store which parts collide. </p>
+<p>New in pygame <tt>1.8</tt>. </p>
+<!--COMMENTS:pygame.mask--> &nbsp;<br> 
+
+
+<a name="pygame.mask.pygame.mask.from_surface">
+<big><b>pygame.mask.pygame.mask.from_surface</big></b><br><ul>
+  <i>Returns the size of the mask.</i><br>
+  <tt>pygame.mask.from_surface(surface) -> Mask</tt><br>
+ &nbsp;<br> 
+<!--COMMENTS:pygame.mask.pygame.mask.from_surface--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="pygame.mask.pygame.Mask">
+<big><b>pygame.mask.pygame.Mask</big></b><br><ul>
+  <i>pygame object for representing 2d bitmasks</i><br>
+  <tt>pygame.Mask((width, height): return Mask</tt><br>
+ &nbsp;<br> 
+<!--COMMENTS:pygame.mask.pygame.Mask--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="pygame.mask.get_size">
+<big><b>pygame.mask.get_size</big></b><br><ul>
+  <i>Returns the size of the mask.</i><br>
+  <tt>Mask.get_size() -> width,height</tt><br>
+ &nbsp;<br> 
+<!--COMMENTS:pygame.mask.get_size--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="pygame.mask.get_at">
+<big><b>pygame.mask.get_at</big></b><br><ul>
+  <i>Returns nonzero if the bit at (x,y) is set.</i><br>
+  <tt>Mask.get_at((x,y)) -> int</tt><br>
+<p>Coordinates start at (0,0) </p>
+<!--COMMENTS:pygame.mask.get_at--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="pygame.mask.set_at">
+<big><b>pygame.mask.set_at</big></b><br><ul>
+  <i>Sets the position in the mask given by x and y.</i><br>
+  <tt>Mask.set_at((x,y),value)</tt><br>
+ &nbsp;<br> 
+<!--COMMENTS:pygame.mask.set_at--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="pygame.mask.overlap">
+<big><b>pygame.mask.overlap</big></b><br><ul>
+  <i>Returns nonzero if the masks overlap with the given offset.</i><br>
+  <tt>Mask.overlap(othermask, offset) -> x,y</tt><br>
+<p>The overlap tests uses the following offsets (which may be negative): </p>
+<pre>   +----+----------..
+   |A   | yoffset
+   |  +-+----------..
+   +--|B
+   |xoffset
+   |  |
+   :  :
+</pre>
+<!--COMMENTS:pygame.mask.overlap--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="pygame.mask.overlap_area">
+<big><b>pygame.mask.overlap_area</big></b><br><ul>
+  <i>Returns the number of overlapping 'pixels'.</i><br>
+  <tt>Mask.overlap_area(othermask, offset) -> numpixels</tt><br>
+ &nbsp;<br> 
+<!--COMMENTS:pygame.mask.overlap_area--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="pygame.mask.get_bounding_rects">
+<big><b>pygame.mask.get_bounding_rects</big></b><br><ul>
+  <i>Returns a list of bounding rects of regions of set pixels.</i><br>
+  <tt>Mask.get_bounding_rects() -> Rects</tt><br>
+ &nbsp;<br> 
+<!--COMMENTS:pygame.mask.get_bounding_rects--> &nbsp;<br> 
+<br></ul>
+
+
+<a name="">
+<big><b></big></b><br><ul>
+ &nbsp;<br> 
+<!--COMMENTS:--> &nbsp;<br> 
+<br></ul>
+<br></ul>
+
+</body></html>

docs/ref/pixelarray.html

+
+<html>
+<title>pixelarray - Pygame Documentation</title>
+<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>
+
+
+<table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
+<tr>
+<td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
+<td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
+	||&nbsp;
+	<a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
+	<a href=../index.html>Help Contents</a> &nbsp;||
+	<a href=index.html>Reference Index</a> &nbsp;||
+	<br>&nbsp;<br>
+	
+<a href=cdrom.html>Cdrom</a>&nbsp;||&nbsp;
+<a href=cursors.html>Cursors</a>&nbsp;||&nbsp;
+<a href=display.html>Display</a>&nbsp;||&nbsp;
+<a href=draw.html>Draw</a>&nbsp;||&nbsp;
+<a href=event.html>Event</a>&nbsp;||&nbsp;
+<a href=font.html>Font</a>&nbsp;||&nbsp;
+<a href=image.html>Image</a>&nbsp;||&nbsp;
+<a href=joystick.html>Joystick</a>&nbsp;||&nbsp;
+<a href=key.html>Key</a>&nbsp;||&nbsp;
+<a href=mask.html>Mask</a>&nbsp;||&nbsp;
+<a href=mixer.html>Mixer</a>&nbsp;||&nbsp;
+<a href=mouse.html>Mouse</a>&nbsp;||&nbsp;
+<a href=movie.html>Movie</a>&nbsp;||&nbsp;
+<a href=music.html>Music</a>&nbsp;||&nbsp;
+<a href=overlay.html>Overlay</a>&nbsp;||&nbsp;
+<a href=pixelarray.html>Pixelarray</a>&nbsp;||&nbsp;
+<a href=pygame.html>Pygame</a>&nbsp;||&nbsp;
+<a href=rect.html>Rect</a>&nbsp;||&nbsp;
+<a href=scrap.html>Scrap</a>&nbsp;||&nbsp;
+<a href=sndarray.html>Sndarray</a>&nbsp;||&nbsp;
+<a href=sprite.html>Sprite</a>&nbsp;||&nbsp;
+<a href=surface.html>Surface</a>&nbsp;||&nbsp;
+<a href=surfarray.html>Surfarray</a>&nbsp;||&nbsp;
+<a href=time.html>Time</a>&nbsp;||&nbsp;
+<a href=transform.html>Transform</a>
+</td></tr></table>
+<br>
+
+
+<a name="pygame.PixelArray">
+<big><b>pygame.PixelArray</big></b><br><ul>
+  <i>pygame Object for direct pixel access of surfaces</i><br>
+  <tt>pygame.PixelArray(surface): return PixelArray</tt><br>
+<ul><small><table>
+  <tr><td><a href="pixelarray.html#PixelArray.surface">PixelArray.surface</a> - <font size=-1>Gets the Surface, the PixelArray uses</font></td><td>Gets the Surface, the PixelArray uses</td></tr>
+</table></small></ul>
+<p>The PixelArray wraps up a Surface and provides a direct <tt>2D</tt> array access to its pixels using the surface its rows as first and its columns as second axis. It supports slicing, row and pixel manipluation while inplace operations such as addition, subtraction, multiplication, division and slice assignments are not allowed. </p>
+<p>During its lifetime, the PixelArray locks the surface, thus you explicitly have to delete it once its not used anymore and the surface should perform operations in the same scope. </p>
+<!--COMMENTS:pygame.PixelArray--> &nbsp;<br> 
+
+
+<a name="PixelArray.surface">
+<big><b>PixelArray.surface</big></b><br><ul>
+  <i>Gets the Surface, the PixelArray uses</i><br>
+  <tt>PixelArray.surface: Return Surface</tt><br>
+<p>Gets the Surface, the PixelArray was created for. </p>
+<!--COMMENTS:PixelArray.surface--> &nbsp;<br> 
+<br></ul>
+<br></ul>
+
+</body></html>

docs/ref/pygame.html

   <tr><td><a href="pygame.html#pygame.error">pygame.error</a> - <font size=-1>standard pygame exception</font></td><td>standard pygame exception</td></tr>
   <tr><td><a href="pygame.html#pygame.get_error">pygame.get_error</a> - <font size=-1>get the current error message</font></td><td>get the current error message</td></tr>
   <tr><td><a href="pygame.html#pygame.get_sdl_version">pygame.get_sdl_version</a> - <font size=-1>get the version number of SDL</font></td><td>get the version number of SDL</td></tr>
+  <tr><td><a href="pygame.html#pygame.get_sdl_byteorder">pygame.get_sdl_byteorder</a> - <font size=-1>get the byte order of SDL</font></td><td>get the byte order of SDL</td></tr>
   <tr><td><a href="pygame.html#pygame.register_quit">pygame.register_quit</a> - <font size=-1>register a function to be called when pygame quits</font></td><td>register a function to be called when pygame quits</td></tr>
   <tr><td><a href="pygame.html#pygame.version">pygame.version</a> - <font size=-1>small module containing version information</font></td><td>small module containing version information</td></tr>
 </table></small></ul>
 <br></ul>
 
 
+<a name="pygame.get_sdl_byteorder">
+<big><b>pygame.get_sdl_byteorder</big></b><br><ul>
+  <i>get the byte order of SDL</i><br>
+  <tt>pygame.get_sdl_byteorder(): return int</tt><br>
+<p>Returns the byte order of the <tt>SDL</tt> library. It returns <tt>LIL_ENDIAN</tt> for little endian byte order and <tt>BIG_ENDIAN</tt> for big endian byte order. </p>
+<p>get_sdl_byteorder is new in pygame <tt>1.8</tt> </p>
+<!--COMMENTS:pygame.get_sdl_byteorder--> &nbsp;<br> 
+<br></ul>
+
+
 <a name="pygame.register_quit">
 <big><b>pygame.register_quit</big></b><br><ul>
   <i>register a function to be called when pygame quits</i><br>
 }
 
 static PyObject*
+get_sdl_byteorder (PyObject *self)
+{
+    return PyLong_FromLong (SDL_BYTEORDER);
+}
+
+static PyObject*
 quit (PyObject* self)
 {
     atexit_quit ();
     { "get_error", (PyCFunction) get_error, METH_NOARGS, DOC_PYGAMEGETERROR },
     { "get_sdl_version", (PyCFunction) get_sdl_version, METH_NOARGS,
       DOC_PYGAMEGETSDLVERSION },
+    { "get_sdl_byteorder", (PyCFunction) get_sdl_byteorder, METH_NOARGS,
+      DOC_PYGAMEGETSDLBYTEORDER },
 
     { "segfault", (PyCFunction) do_segfault, METH_NOARGS, "crash" },
     { NULL, NULL, 0, NULL }
     module = Py_InitModule3
         ("constants", builtins,
          "Constants defined by SDL and needed in Pygame.\n");
+
+    DEC_CONST (LIL_ENDIAN);
+    DEC_CONST (BIG_ENDIAN);
     
     DEC_CONST(YV12_OVERLAY);
     DEC_CONST(IYUV_OVERLAY);
 <END>
 
 
+get_sdl_byteorder
+get the byte order of SDL
+pygame.get_sdl_byteorder(): return int
+
+Returns the byte order of the SDL library. It returns LIL_ENDIAN for
+little endian byte order and BIG_ENDIAN for big endian byte order.
+
+get_sdl_byteorder is new in pygame 1.8
+<END>
+
 
 register_quit
 register a function to be called when pygame quits
 
 #define DOC_PYGAMEGETSDLVERSION "pygame.get_sdl_version(): return major, minor, patch\nget the version number of SDL"
 
+#define DOC_PYGAMEGETSDLBYTEORDER "pygame.get_sdl_byteorder(): return int\nget the byte order of SDL"
+
 #define DOC_PYGAMEREGISTERQUIT "register_quit(callable): return None\nregister a function to be called when pygame quits"
 
 #define DOC_PYGAMEVERSION "module pygame.version\nsmall module containing version information"
         break;
     }
 
-    length = (Py_ssize_t) surface->w * surface->h * mod;
+    length = (Py_ssize_t) surface->pitch * surface->h;
     lock = PySurface_LockLifetime (self);
     if (!lock)
     {
     if (!buffer)
     {
         Py_DECREF (lock);
-        return RAISE (PyExc_SDLError, "could acquire a buffer for the surface");
+        return RAISE (PyExc_SDLError,
+                      "could not acquire a buffer for the surface");
     }
     return buffer;
 }