3 <h3 id="TOP">Index</h3>
5 <ul><li><a href="#NAME">NAME</a></li>
6 <li><a href="#CATEGORY">CATEGORY</a></li>
7 <li><a href="#SYNOPSIS">SYNOPSIS</a></li>
8 <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
9 <li><a href="#CONSTANTS">CONSTANTS</a></li>
10 <li><a href="#METHODS">METHODS</a>
11 <ul><li><a href="#new">new</a></li>
12 <li><a href="#new_from">new_from</a></li>
13 <li><a href="#w">w</a></li>
14 <li><a href="#h">h</a></li>
15 <li><a href="#format">format</a></li>
16 <li><a href="#pitch">pitch</a></li>
19 <li><a href="#Direct_Write_to_Surface_Pixel">Direct Write to Surface Pixel</a>
20 <ul><li><a href="#get_pixel">get_pixel</a></li>
21 <li><a href="#set_pixels">set_pixels</a></li>
22 <li><a href="#get_pixels_ptr">get_pixels_ptr</a></li>
25 <li><a href="#SEE_ALSO">SEE ALSO</a></li>
26 <li><a href="#AUTHORS">AUTHORS</a>
31 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
32 <div id="NAME_CONTENT">
33 <p>SDL::Surface - Graphic surface structure</p>
36 <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
37 <div id="CATEGORY_CONTENT">
38 <p>Core, Video, Structure</p>
41 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
42 <div id="SYNOPSIS_CONTENT">
47 # Create the main surface (display)
48 SDL::init(SDL_INIT_VIDEO);
49 my $display = SDL::Video::set_video_mode(640, 480, 16, SDL_SWSURFACE);
51 # Create other surfaces attached to the $display.
52 my $surface = SDL::Surface->new(SDL_ASYNCBLIT | SDL_HWSURFACE, 640, 480, 16, 0, 0, 0, 0);
53 my $surface2 = SDL::Surface->new_from($surface, 100, 100, 8, 0, 0, 0, 0);
58 <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
59 <div id="DESCRIPTION_CONTENT">
60 <p>An <code>SDL_Surface</code> defines a surfaceangular area of pixels.</p>
63 <h1 id="CONSTANTS">CONSTANTS</h1><p><a href="#TOP" class="toplink">Top</a></p>
64 <div id="CONSTANTS_CONTENT">
65 <p>The constants for SDL::Surface belong to SDL::Video, under the export tag of <code>':surface'</code>.</p>
67 <dt>SDL_ASYNCBLIT</dt>
69 <p>Use asynchronous blit if possible</p>
71 <dt>SDL_SWSURFACE</dt>
73 <p>Store in system memory</p>
75 <dt>SDL_HWSURFACE</dt>
77 <p>Store in video memory</p>
82 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
83 <div id="METHODS_CONTENT">
87 <div id="new_CONTENT">
88 <pre> my $surface = SDL::Surface->new(
89 $flags, $width, $height, $depth, $Rmask, $Gmask, $Bmask, $Amask
93 <p>The constructor creates a new surface with the specified parameter values.</p>
94 <p>The four mask values are the bits that the channel will ignore.
95 For example, an Rmask of <code>0xFF</code> will ignore that channel completely, making everything on the surface more green/blue.</p>
98 <h2 id="new_from">new_from</h2>
99 <div id="new_from_CONTENT">
100 <pre> my $surface = SDL::Surface->new_from(
101 $surface, $width, $height, $depth, $Rmask, $Gmask, $Bmask, $Amask
105 <p>The constructor creates a new surface with the specified parameter values.
106 The flags are taken from the specified <code>$surface</code>.</p>
111 <pre> my $w = $surface->w;
114 <p>Returns the width of the surface.
115 SDL::Surface width is defined at construction so this is read-only.</p>
120 <pre> my $h = $surface->h;
123 <p>Returns the height of the surface.
124 SDL::Surface height is defined at construction so this is read-only.</p>
127 <h2 id="format">format</h2>
128 <div id="format_CONTENT">
129 <pre> my $format = $surface->format;
132 <p>The format of the pixels stored in the surface.
133 See <a href="SDL-PixelFormat.html">SDL::PixelFormat</a></p>
136 <h2 id="pitch">pitch</h2>
137 <div id="pitch_CONTENT">
138 <pre> my $pitch = $surface->pitch;
141 <p>The scanline length in bytes.</p>
144 <h1 id="Direct_Write_to_Surface_Pixel">Direct Write to Surface Pixel</h1><p><a href="#TOP" class="toplink">Top</a></p>
145 <div id="Direct_Write_to_Surface_Pixel_CONTEN">
146 <p><strong>Disclaimer:</strong> The following methods can be very slow, making them suitable for creating surfaces, but not for animations</p>
149 <h2 id="get_pixel">get_pixel</h2>
150 <div id="get_pixel_CONTENT">
151 <pre> my $pixel = $surface->get_pixel( $offset )
154 <p>Returns the pixel value for the given <code>$offset</code>.
155 The pixel value depends on current pixel format.</p>
156 <p><strong>Note:</strong> For surfaces with a palette (1 byte per pixel) the palette index is returned instead of color values.</p>
159 <h2 id="set_pixels">set_pixels</h2>
160 <div id="set_pixels_CONTENT">
161 <pre> $surface->set_pixels( $offset, $value );
164 <p>Sets the pixel <code>$value</code> to the given <code>$offset</code>.
165 The pixel value must fit the pixel format of the surface.</p>
166 <p><strong>Note</strong>: For surfaces with a palette (1 byte per pixel) the palette index must be passed instead of color values.</p>
169 my ($x, $y, $color) = @_;
170 $display->set_pixels( $x + $y * $display->w, $color);
174 <p>See also <cite>examples/pixel_operations/sols/ch02.pl</cite>!</p>
177 <h2 id="get_pixels_ptr">get_pixels_ptr</h2>
178 <div id="get_pixels_ptr_CONTENT">
179 <pre> my $ptr = $surface->get_pixels_ptr;
182 <p>Returns a reference to the surface's pixels.</p>
185 <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p>
186 <div id="SEE_ALSO_CONTENT">
187 <p><a href="SDL.html">SDL</a>, <a href="SDL-PixelFormat.html">SDL::PixelFormat</a>, <a href="SDL-Video.html">SDL::Video</a>, <a href="SDL-Rect.html">SDL::Rect</a></p>
190 <h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
191 <div id="AUTHORS_CONTENT">
192 <p>See <a href="/SDL.html#AUTHORS">/SDL.html#AUTHORS</a>.</p>