X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=sdlgit%2FSDL-Site.git;a=blobdiff_plain;f=pages%2FSDL-Surface.html-inc;h=83709ba4e325a5273cf98fe29552da9f800ad3e7;hp=da88a7d896cac252d9b462423c5997450d9ba3f1;hb=f373167ec31ba16ae0770ba461f9de43f41a7ac1;hpb=56d4907c407e8564b4a8a9d09e252573131fad3e diff --git a/pages/SDL-Surface.html-inc b/pages/SDL-Surface.html-inc index da88a7d..83709ba 100644 --- a/pages/SDL-Surface.html-inc +++ b/pages/SDL-Surface.html-inc @@ -24,7 +24,7 @@
Disclaimer: This can be very slow, it is suitable for creating surfaces one time and not for animations
-$surface->get_pixels( $offset ) +get_pixel
++my $pixel = $surface->get_pixel( $offset )-Returns the current integer value at (surface->pixels)[offset]
+Returns the pixel value for the given
+$offset
. The pixel value depends on current pixel format.Note: For surfaces with a palette (1 byte per pixel) the palette index is returned instead of color values.
set_pixels
@@ -192,20 +193,19 @@$surface->set_pixels( $offset, $value );-Sets the current integer to $value at (surface->pixels)[offset]
+Sets the current pixel
+$value
to the given$offset
. The pixel value must fit the pixel format of the surface.Note: For surfaces with a palette (1 byte per pixel) the palette index must be passed instead of color values.
sub putpixel - { - my($x, $y, $color) = @_; - my $lineoffset = $y * ($screen->pitch / $depth_in_bytes); - $screen->set_pixels( $lineoffset+ $x, $color); - } +sub putpixel + { + my($x, $y, $color) = @_; + $screen->set_pixels( $x + $y * $screen->w, $color); + }-Note: $depth_in_bytes for 32 is 4, 16 is 2, 8 is 1;
See also examples/sols/ch02.pl