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>
30 <h1 id="NAME">NAME</h1><p><a href="#TOP" class="toplink">Top</a></p>
31 <div id="NAME_CONTENT">
32 <p>SDL::Surface - Graphic surface structure</p>
35 <h1 id="CATEGORY">CATEGORY</h1><p><a href="#TOP" class="toplink">Top</a></p>
36 <div id="CATEGORY_CONTENT">
37 <p>Core, Video, Structure</p>
40 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
41 <div id="SYNOPSIS_CONTENT">
46 # Create the main surface (display)
47 SDL::init(SDL_INIT_VIDEO);
48 my $display = SDL::Video::set_video_mode(640, 480, 16, SDL_SWSURFACE);
50 # Create other surfaces attached to the $display.
51 my $surface = SDL::Surface->new(SDL_ASYNCBLIT | SDL_HWSURFACE, 640, 480, 16, 0, 0, 0, 0);
52 my $surface2 = SDL::Surface->new_from($surface, 100, 100, 8, 0, 0, 0, 0);
57 <h1 id="DESCRIPTION">DESCRIPTION</h1><p><a href="#TOP" class="toplink">Top</a></p>
58 <div id="DESCRIPTION_CONTENT">
59 <p>An <code>SDL_Surface</code> defines a surfaceangular area of pixels.</p>
62 <h1 id="CONSTANTS">CONSTANTS</h1><p><a href="#TOP" class="toplink">Top</a></p>
63 <div id="CONSTANTS_CONTENT">
64 <p>The constants for SDL::Surface belong to SDL::Video, under the export tag of <code>':surface'</code>.</p>
66 <dt>SDL_ASYNCBLIT</dt>
68 <p>Use asynchronous blit if possible</p>
70 <dt>SDL_SWSURFACE</dt>
72 <p>Store in system memory</p>
74 <dt>SDL_HWSURFACE</dt>
76 <p>Store in video memory</p>
81 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
82 <div id="METHODS_CONTENT">
86 <div id="new_CONTENT">
87 <pre> my $surface = SDL::Surface->new(
88 $flags, $width, $height, $depth, $Rmask, $Gmask, $Bmask, $Amask
92 <p>The constructor creates a new surface with the specified parameter values.</p>
93 <p>The four mask values are the bits that the channel will ignore.
94 For example, an Rmask of <code>0xFF</code> will ignore that channel completely, making everything on the surface more green/blue.</p>
97 <h2 id="new_from">new_from</h2>
98 <div id="new_from_CONTENT">
99 <pre> my $surface = SDL::Surface->new_from(
100 $surface, $width, $height, $depth, $Rmask, $Gmask, $Bmask, $Amask
104 <p>The constructor creates a new surface with the specified parameter values.
105 The flags are taken from the specified <code>$surface</code>.</p>
110 <pre> my $w = $surface->w;
113 <p>Returns the width of the surface.
114 SDL::Surface width is defined at construction so this is read-only.</p>
119 <pre> my $h = $surface->h;
122 <p>Returns the height of the surface.
123 SDL::Surface height is defined at construction so this is read-only.</p>
126 <h2 id="format">format</h2>
127 <div id="format_CONTENT">
128 <pre> my $format = $surface->format;
131 <p>The format of the pixels stored in the surface.
132 See <a href="SDL-PixelFormat.html">SDL::PixelFormat</a></p>
135 <h2 id="pitch">pitch</h2>
136 <div id="pitch_CONTENT">
137 <pre> my $pitch = $surface->pitch;
140 <p>The scanline length in bytes.</p>
143 <h1 id="Direct_Write_to_Surface_Pixel">Direct Write to Surface Pixel</h1><p><a href="#TOP" class="toplink">Top</a></p>
144 <div id="Direct_Write_to_Surface_Pixel_CONTEN">
145 <p><strong>Disclaimer:</strong> The following methods can be very slow, making them suitable for creating surfaces, but not for animations</p>
148 <h2 id="get_pixel">get_pixel</h2>
149 <div id="get_pixel_CONTENT">
150 <pre> my $pixel = $surface->get_pixel( $offset )
153 <p>Returns the pixel value for the given <code>$offset</code>.
154 The pixel value depends on current pixel format.</p>
155 <p><strong>Note:</strong> For surfaces with a palette (1 byte per pixel) the palette index is returned instead of color values.</p>
158 <h2 id="set_pixels">set_pixels</h2>
159 <div id="set_pixels_CONTENT">
160 <pre> $surface->set_pixels( $offset, $value );
163 <p>Sets the pixel <code>$value</code> to the given <code>$offset</code>.
164 The pixel value must fit the pixel format of the surface.</p>
165 <p><strong>Note</strong>: For surfaces with a palette (1 byte per pixel) the palette index must be passed instead of color values.</p>
168 my ($x, $y, $color) = @_;
169 $display->set_pixels( $x + $y * $display->w, $color);
173 <p>See also <cite>examples/pixel_operations/sols/ch02.pl</cite>!</p>
176 <h2 id="get_pixels_ptr">get_pixels_ptr</h2>
177 <div id="get_pixels_ptr_CONTENT">
178 <pre> my $ptr = $surface->get_pixels_ptr;
181 <p>Returns a reference to the surface's pixels.</p>
184 <h1 id="SEE_ALSO">SEE ALSO</h1><p><a href="#TOP" class="toplink">Top</a></p>
185 <div id="SEE_ALSO_CONTENT">
186 <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>