176 lines
11 KiB
HTML
176 lines
11 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<title>2D and 3D direct pixel access — PySDL2 0.9.5 documentation</title>
|
|
|
|
<link rel="stylesheet" href="../_static/classic.css" type="text/css" />
|
|
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT: '../',
|
|
VERSION: '0.9.5',
|
|
COLLAPSE_INDEX: false,
|
|
FILE_SUFFIX: '.html',
|
|
HAS_SOURCE: true
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
<link rel="top" title="PySDL2 0.9.5 documentation" href="../index.html" />
|
|
<link rel="up" title="sdl2.ext - Python extensions for SDL2" href="sdl2ext.html" />
|
|
<link rel="next" title="Resource management" href="sdl2ext_resources.html" />
|
|
<link rel="prev" title="sdl2.ext.particles - A simple particle system" href="sdl2ext_particles.html" />
|
|
</head>
|
|
<body role="document">
|
|
<div class="related" role="navigation" aria-label="related navigation">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="../genindex.html" title="General Index"
|
|
accesskey="I">index</a></li>
|
|
<li class="right" >
|
|
<a href="../py-modindex.html" title="Python Module Index"
|
|
>modules</a> |</li>
|
|
<li class="right" >
|
|
<a href="sdl2ext_resources.html" title="Resource management"
|
|
accesskey="N">next</a> |</li>
|
|
<li class="right" >
|
|
<a href="sdl2ext_particles.html" title="sdl2.ext.particles - A simple particle system"
|
|
accesskey="P">previous</a> |</li>
|
|
<li class="nav-item nav-item-0"><a href="../index.html">PySDL2 0.9.5 documentation</a> »</li>
|
|
<li class="nav-item nav-item-1"><a href="index.html" >API reference</a> »</li>
|
|
<li class="nav-item nav-item-2"><a href="sdl2ext.html" accesskey="U">sdl2.ext - Python extensions for SDL2</a> »</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="document">
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
<div class="body" role="main">
|
|
|
|
<div class="section" id="d-and-3d-direct-pixel-access">
|
|
<h1>2D and 3D direct pixel access<a class="headerlink" href="#d-and-3d-direct-pixel-access" title="Permalink to this headline">¶</a></h1>
|
|
<dl class="class">
|
|
<dt id="sdl2.ext.PixelView">
|
|
<em class="property">class </em><code class="descclassname">sdl2.ext.</code><code class="descname">PixelView</code><span class="sig-paren">(</span><em>source : object</em><span class="sig-paren">)</span><a class="headerlink" href="#sdl2.ext.PixelView" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>2D <a class="reference internal" href="sdl2ext_array.html#sdl2.ext.MemoryView" title="sdl2.ext.MemoryView"><code class="xref py py-class docutils literal"><span class="pre">MemoryView</span></code></a> for <a class="reference internal" href="sdl2ext_sprite.html#sdl2.ext.SoftwareSprite" title="sdl2.ext.SoftwareSprite"><code class="xref py py-class docutils literal"><span class="pre">SoftwareSprite</span></code></a> and
|
|
<code class="xref py py-class docutils literal"><span class="pre">sdl2.SDL_surface</span></code> pixel access.</p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<blockquote>
|
|
<div>If necessary, the <em>source</em> surface will be locked for accessing its
|
|
pixel data. The lock will be removed once the <a class="reference internal" href="#sdl2.ext.PixelView" title="sdl2.ext.PixelView"><code class="xref py py-class docutils literal"><span class="pre">PixelView</span></code></a> is
|
|
garbage-collected or deleted.</div></blockquote>
|
|
<p>The <a class="reference internal" href="#sdl2.ext.PixelView" title="sdl2.ext.PixelView"><code class="xref py py-class docutils literal"><span class="pre">PixelView</span></code></a> uses a y/x-layout. Accessing <code class="docutils literal"><span class="pre">view[N]</span></code> will
|
|
operate on the Nth row of the underlying surface. To access a specific
|
|
column within that row, <code class="docutils literal"><span class="pre">view[N][C]</span></code> has to be used.</p>
|
|
<div class="last admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last"><a class="reference internal" href="#sdl2.ext.PixelView" title="sdl2.ext.PixelView"><code class="xref py py-class docutils literal"><span class="pre">PixelView</span></code></a> is implemented on top of the <a class="reference internal" href="sdl2ext_array.html#sdl2.ext.MemoryView" title="sdl2.ext.MemoryView"><code class="xref py py-class docutils literal"><span class="pre">MemoryView</span></code></a>
|
|
class. As such it makes heavy use of recursion to access rows and
|
|
columns and can be considered as slow in contrast to optimised
|
|
ndim-array solutions such as <code class="xref py py-mod docutils literal"><span class="pre">numpy</span></code>.</p>
|
|
</div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="sdl2.ext.pixels2d">
|
|
<code class="descclassname">sdl2.ext.</code><code class="descname">pixels2d</code><span class="sig-paren">(</span><em>source : object</em><span class="sig-paren">)</span><a class="headerlink" href="#sdl2.ext.pixels2d" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Creates a 2D pixel array, based on <code class="docutils literal"><span class="pre">numpy.ndarray</span></code>, from the passed
|
|
<em>source</em>. <em>source</em> can be a <a class="reference internal" href="sdl2ext_sprite.html#sdl2.ext.SoftwareSprite" title="sdl2.ext.SoftwareSprite"><code class="xref py py-class docutils literal"><span class="pre">SoftwareSprite</span></code></a> or
|
|
<code class="xref py py-class docutils literal"><span class="pre">sdl2.SDL_Surface</span></code>. The <code class="docutils literal"><span class="pre">SDL_Surface</span></code> of the <em>source</em> will be
|
|
locked and unlocked automatically.</p>
|
|
<p>The <em>source</em> pixels will be accessed and manipulated directly.</p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last"><a class="reference internal" href="#sdl2.ext.pixels2d" title="sdl2.ext.pixels2d"><code class="xref py py-func docutils literal"><span class="pre">pixels2d()</span></code></a> is only usable, if the numpy package is available
|
|
within the target environment. If numpy could not be imported, a
|
|
<a class="reference internal" href="sdl2ext_compat.html#sdl2.ext.compat.UnsupportedError" title="sdl2.ext.compat.UnsupportedError"><code class="xref py py-exc docutils literal"><span class="pre">sdl2.ext.compat.UnsupportedError</span></code></a> will be raised.</p>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="sdl2.ext.pixels3d">
|
|
<code class="descclassname">sdl2.ext.</code><code class="descname">pixels3d</code><span class="sig-paren">(</span><em>source : object</em><span class="sig-paren">)</span><a class="headerlink" href="#sdl2.ext.pixels3d" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Creates a 3D pixel array, based on <code class="docutils literal"><span class="pre">numpy.ndarray</span></code>, from the passed
|
|
<em>source</em>. <em>source</em> can be a <a class="reference internal" href="sdl2ext_sprite.html#sdl2.ext.SoftwareSprite" title="sdl2.ext.SoftwareSprite"><code class="xref py py-class docutils literal"><span class="pre">SoftwareSprite</span></code></a>
|
|
or <code class="xref py py-class docutils literal"><span class="pre">sdl2.SDL_Surface</span></code>. The <code class="docutils literal"><span class="pre">SDL_Surface</span></code> of the <em>source</em>
|
|
will be locked and unlocked automatically.</p>
|
|
<p>The <em>source</em> pixels will be accessed and manipulated directly.</p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last"><a class="reference internal" href="#sdl2.ext.pixels3d" title="sdl2.ext.pixels3d"><code class="xref py py-func docutils literal"><span class="pre">pixels3d()</span></code></a> is only usable, if the numpy package is available
|
|
within the target environment. If numpy could not be imported, a
|
|
<a class="reference internal" href="sdl2ext_compat.html#sdl2.ext.compat.UnsupportedError" title="sdl2.ext.compat.UnsupportedError"><code class="xref py py-exc docutils literal"><span class="pre">sdl2.ext.compat.UnsupportedError</span></code></a> will be raised.</p>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
|
<div class="sphinxsidebarwrapper">
|
|
<h4>Previous topic</h4>
|
|
<p class="topless"><a href="sdl2ext_particles.html"
|
|
title="previous chapter">sdl2.ext.particles - A simple particle system</a></p>
|
|
<h4>Next topic</h4>
|
|
<p class="topless"><a href="sdl2ext_resources.html"
|
|
title="next chapter">Resource management</a></p>
|
|
<div role="note" aria-label="source link">
|
|
<h3>This Page</h3>
|
|
<ul class="this-page-menu">
|
|
<li><a href="../_sources/modules/sdl2ext_pixelaccess.txt"
|
|
rel="nofollow">Show Source</a></li>
|
|
</ul>
|
|
</div>
|
|
<div id="searchbox" style="display: none" role="search">
|
|
<h3>Quick search</h3>
|
|
<form class="search" action="../search.html" method="get">
|
|
<div><input type="text" name="q" /></div>
|
|
<div><input type="submit" value="Go" /></div>
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
</div>
|
|
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
<div class="related" role="navigation" aria-label="related navigation">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="../genindex.html" title="General Index"
|
|
>index</a></li>
|
|
<li class="right" >
|
|
<a href="../py-modindex.html" title="Python Module Index"
|
|
>modules</a> |</li>
|
|
<li class="right" >
|
|
<a href="sdl2ext_resources.html" title="Resource management"
|
|
>next</a> |</li>
|
|
<li class="right" >
|
|
<a href="sdl2ext_particles.html" title="sdl2.ext.particles - A simple particle system"
|
|
>previous</a> |</li>
|
|
<li class="nav-item nav-item-0"><a href="../index.html">PySDL2 0.9.5 documentation</a> »</li>
|
|
<li class="nav-item nav-item-1"><a href="index.html" >API reference</a> »</li>
|
|
<li class="nav-item nav-item-2"><a href="sdl2ext.html" >sdl2.ext - Python extensions for SDL2</a> »</li>
|
|
</ul>
|
|
</div>
|
|
<div class="footer" role="contentinfo">
|
|
© Copyright 2013-2016, Marcus von Appen.
|
|
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.6.
|
|
</div>
|
|
</body>
|
|
</html> |