updated docs
[sdlgit/SDL-Site.git] / pages / SDL-Surface.html-inc
1 <div class="pod">
2 <!-- INDEX START -->
3 <h3 id="TOP">Index</h3>
4
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>
17 </ul>
18 </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>
23 </ul>
24 </li>
25 <li><a href="#SEE_ALSO">SEE ALSO</a></li>
26 <li><a href="#AUTHORS">AUTHORS</a>
27 </li>
28 </ul><hr />
29 <!-- INDEX END -->
30
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>
34
35 </div>
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>
39
40 </div>
41 <h1 id="SYNOPSIS">SYNOPSIS</h1><p><a href="#TOP" class="toplink">Top</a></p>
42 <div id="SYNOPSIS_CONTENT">
43 <pre> use SDL;
44  use SDL::Video;
45  use SDL::Surface;
46
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);
50
51  # Create other surfaces attached to the $display.
52  my $surface  = SDL::Surface-&gt;new(SDL_ASYNCBLIT | SDL_HWSURFACE, 640, 480, 16, 0, 0, 0, 0);
53  my $surface2 = SDL::Surface-&gt;new_from($surface, 100, 100, 8, 0, 0, 0, 0);
54
55 </pre>
56
57 </div>
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>
61
62 </div>
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>
66 <dl>
67         <dt>SDL_ASYNCBLIT</dt>
68         <dd>
69                 <p>Use asynchronous blit if possible</p>
70         </dd>
71         <dt>SDL_SWSURFACE</dt>
72         <dd>
73                 <p>Store in system memory</p>
74         </dd>
75         <dt>SDL_HWSURFACE</dt>
76         <dd>
77                 <p>Store in video memory</p>
78         </dd>
79 </dl>
80
81 </div>
82 <h1 id="METHODS">METHODS</h1><p><a href="#TOP" class="toplink">Top</a></p>
83 <div id="METHODS_CONTENT">
84
85 </div>
86 <h2 id="new">new</h2>
87 <div id="new_CONTENT">
88 <pre> my $surface = SDL::Surface-&gt;new(
89      $flags, $width, $height, $depth, $Rmask, $Gmask, $Bmask, $Amask
90  );
91
92 </pre>
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>
96
97 </div>
98 <h2 id="new_from">new_from</h2>
99 <div id="new_from_CONTENT">
100 <pre> my $surface = SDL::Surface-&gt;new_from(
101      $surface, $width, $height, $depth, $Rmask, $Gmask, $Bmask, $Amask
102  );
103
104 </pre>
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>
107
108 </div>
109 <h2 id="w">w</h2>
110 <div id="w_CONTENT">
111 <pre> my $w = $surface-&gt;w;
112
113 </pre>
114 <p>Returns the width of the surface.
115 SDL::Surface width is defined at construction so this is read-only.</p>
116
117 </div>
118 <h2 id="h">h</h2>
119 <div id="h_CONTENT">
120 <pre> my $h = $surface-&gt;h;
121
122 </pre>
123 <p>Returns the height of the surface.
124 SDL::Surface height is defined at construction so this is read-only.</p>
125
126 </div>
127 <h2 id="format">format</h2>
128 <div id="format_CONTENT">
129 <pre> my $format = $surface-&gt;format;
130
131 </pre>
132 <p>The format of the pixels stored in the surface.
133 See <a href="SDL-PixelFormat.html">SDL::PixelFormat</a></p>
134
135 </div>
136 <h2 id="pitch">pitch</h2>
137 <div id="pitch_CONTENT">
138 <pre> my $pitch = $surface-&gt;pitch;
139
140 </pre>
141 <p>The scanline length in bytes.</p>
142
143 </div>
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>
147
148 </div>
149 <h2 id="get_pixel">get_pixel</h2>
150 <div id="get_pixel_CONTENT">
151 <pre> my $pixel = $surface-&gt;get_pixel( $offset )
152
153 </pre>
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>
157
158 </div>
159 <h2 id="set_pixels">set_pixels</h2>
160 <div id="set_pixels_CONTENT">
161 <pre> $surface-&gt;set_pixels( $offset, $value );
162
163 </pre>
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>
167 <p>Example:</p>
168 <pre> sub putpixel {
169      my ($x, $y, $color) = @_;
170      $display-&gt;set_pixels( $x + $y * $display-&gt;w, $color);
171  }
172
173 </pre>
174 <p>See also <cite>examples/pixel_operations/sols/ch02.pl</cite>!</p>
175
176 </div>
177 <h2 id="get_pixels_ptr">get_pixels_ptr</h2>
178 <div id="get_pixels_ptr_CONTENT">
179 <pre> my $ptr = $surface-&gt;get_pixels_ptr;
180
181 </pre>
182 <p>Returns a reference to the surface's pixels.</p>
183
184 </div>
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>
188
189 </div>
190 <h1 id="AUTHORS">AUTHORS</h1><p><a href="#TOP" class="toplink">Top</a></p>
191 <div id="AUTHORS_CONTENT">
192 <p>See <b>AUTHORS</b> in <cite>SDL</cite>.</p>
193
194 </div>
195 </div>