</ul>
</li>
<li><a href="#Direct_Write_to_Surface_Pixel">Direct Write to Surface Pixel</a>
-<ul><li><a href="#get_pixels">get_pixels</a></li>
+<ul><li><a href="#get_pixel">get_pixel</a></li>
<li><a href="#set_pixels">set_pixels</a>
<ul><li><a href="#Usage">Usage</a></li>
</ul>
</div>
<h1 id="CONSTANTS">CONSTANTS</h1><p><a href="#TOP" class="toplink">Top</a></p>
<div id="CONSTANTS_CONTENT">
-<p>The constants are not exported by default. You can export them into your namespace by doing:</p>
-<pre> use SDL::Video ':flags';
+<p>The constants are exported by default. You can avoid this by doing:</p>
+<pre> use SDL::Video ();
</pre>
-<p>or</p>
-<pre> use SDL::Video ':all';
-
-</pre>
-<p>or access them directly:</p>
+<p>and access them directly:</p>
<pre> SDL::Video::SDL_SWSURFACE;
</pre>
<p>Disclaimer: This can be very slow, it is suitable for creating surfaces one time and not for animations</p>
</div>
-<h2 id="get_pixels">get_pixels</h2>
-<div id="get_pixels_CONTENT">
-<pre> $surface->get_pixels( $offset )
+<h2 id="get_pixel">get_pixel</h2>
+<div id="get_pixel_CONTENT">
+<pre> my $pixel = $surface->get_pixel( $offset )
</pre>
-<p>Returns the current integer value at (surface->pixels)[offset] </p>
+<p>Returns the pixel value for the given <code>$offset</code>. The pixel value depends on current pixel format.</p>
+<p><strong>Note</strong>: For surfaces with a palette (1 byte per pixel) the palette index is returned instead of color values.</p>
</div>
<h2 id="set_pixels">set_pixels</h2>
<pre> $surface->set_pixels( $offset, $value );
</pre>
-<p>Sets the current integer to $value at (surface->pixels)[offset]</p>
+<p>Sets the current pixel <code>$value</code> to the given <code>$offset</code>. The pixel value must fit the pixel format of the surface.</p>
+<p><strong>Note</strong>: For surfaces with a palette (1 byte per pixel) the palette index must be passed instead of color values.</p>
</div>
<h3 id="Usage">Usage</h3>
<div id="Usage_CONTENT">
-<pre> sub putpixel
- {
- my($x, $y, $color) = @_;
- my $lineoffset = $y * ($screen->pitch / $depth_in_bytes);
- $screen->set_pixels( $lineoffset+ $x, $color);
- }
+<pre> sub putpixel
+ {
+ my($x, $y, $color) = @_;
+ $screen->set_pixels( $x + $y * $screen->w, $color);
+ }
</pre>
-<p>Note: $depth_in_bytes for 32 is 4, 16 is 2, 8 is 1;</p>
<p>See also examples/sols/ch02.pl</p>
</div>