1SDL::Surface(3)       User Contributed Perl Documentation      SDL::Surface(3)
2
3
4

NAME

6       SDL::Surface - a SDL perl extension
7

SYNOPSIS

9         use SDL::Surface;
10         $image = new SDL::Surface(-name=>"yomama.jpg");
11

DESCRIPTION

13       The "SDL::Surface" module encapsulates the SDL_Surface* structure, and
14       many of its ancillatory functions.  Not only is it a workhorse of the
15       OO Layer, it is the base class for the "SDL::App" class.
16

EXPORTS

18               SDL_SWSURFACE           SDL_HWSURFACE
19               SDL_ASYNCBLIT           SDL_ANYFORMAT
20               SDL_HWPALETTE           SDL_DOUBLEBUF
21               SDL_FULLSCREEN          SDL_OPENGL
22               SDL_OPENGLBLIT          SDL_RESIZEABLE
23               SDL_NOFRAME             SDL_SRCCOLORKEY
24               SDL_RLEACCEL            SDL_SRCALPHA
25               SDL_PREALLOC
26

METHODS

28       new (-name => 'foo.png')
29
30       The "SDL::Surface" class can be instantiated in a number of different
31       ways.  If support for the SDL_image library was included when SDL_perl
32       was compiled, the easiest way to create a new surface is to use the
33       "SDL::Surface::new" method with the "-name" option.  This will load the
34       image from the file and return an object encapsulating the SDL_Sur‐
35       face*.
36
37       new (-from => $buffer, ... )
38
39       If the contents of the new Surface is already in memory, "SDL::Sur‐
40       face::new" may be called with the "-from" option to create an image
41       from that section of memory.  This method takes the following addi‐
42       tional parameters:
43
44       ·   -width         the width of the image in pixels
45
46       ·   -height        the height of the image in pixels
47
48       ·   -depth         the number of bits per pixel
49
50       ·   -pitch         the number of bytes per line
51
52       ·   -Rmask         an optional bitmask for red
53
54       ·   -Gmask         an optional bitmask for green
55
56       ·   -Bmask         an optional bitmask for green
57
58       ·   -Amask         an optional bitmask for alpha
59
60       new ( -flags => SDL_SWSURFACE, ... )
61
62       Finally, "SDL::Suface::new" may be invoked with the "-flags" option, in
63       a similar fashion to the "-from" directive.  This invocation takes the
64       same additional options as "-from" with the exception of "-pitch" which
65       is ignored.  This method returns a new, blank, SDL::Surface option with
66       any of the following flags turned on:
67
68       ·   SWSURFACE()    a non-accelerated surface
69
70       ·   HWSURFACE()    a hardware accelerated surface
71
72       ·   SRCCOLORKEY()  a surface with a transperant color
73
74       ·   SRCALPHA()     an alpha blended, translucent surface
75
76       flags ()
77
78       "SDL::Surface::flags" returns the flags with which the surface was ini‐
79       tialized.
80
81       palette ()
82
83       "SDL::Surface::palette" currently returns a SDL_Palette*, this may
84       change in future revisions.
85
86       bpp ()
87
88       "SDL::Surface::bpp" returns the bits per pixel of the surface
89
90       bytes_per_pixel ()
91
92       "SDL::Surface::bytes_per_pixel" returns the bytes per pixel of the sur‐
93       face
94
95       Rshift ()
96
97       "SDL::Surface::Rshift" returns the bit index of the red field for the
98       surface's pixel format
99
100       Gshift ()
101
102       "SDL::Surface::Gshift" returns the bit index of the green field for the
103       surface's pixel format
104
105       Bshift ()
106
107       "SDL::Surface::Bshift" returns the bit index of the blue field for the
108       surface's pixel format
109
110       Ashift ()
111
112       "SDL::Surface::Ashift" returns the bit index of the alpha field for the
113       surface's pixel format
114
115       Rmask ()
116
117       "SDL::Surface::Rmask" returns the bit mask for the red field for teh
118       surface's pixel format
119
120       Gmask ()
121
122       "SDL::Surface::Gmask" returns the bit mask for the green field for teh
123       surface's pixel format
124
125       Bmask ()
126
127       "SDL::Surface::Bmask" returns the bit mask for the blue field for teh
128       surface's pixel format
129
130       Amask ()
131
132       "SDL::Surface::Amask" returns the bit mask for the alpha field for teh
133       surface's pixel format
134
135       color_key ()
136
137       "SDL::Surface::color_key" returns the current color key for the image,
138       which can be set with the "SDL::Surface::set_color_key" method.  Before
139       calling "SDL::Surface::color_key" on a image, you should fist call
140       "SDL::Surface::display_format" to convert it to the same format as the
141       display.  Failure to do so will result in failure to apply the correct
142       color_key.
143
144       alpha ()
145
146       "SDL::Surface::alpha" returns the current alpha value for the image,
147       which can be set with the "SDL::Surface::set_alpha" method.
148
149       width ()
150
151       "SDL::Surface::width" returns the width in pixels of the surface
152
153       height ()
154
155       "SDL::Surface::height" returns the height in pixels of the surface
156
157       pitch ()
158
159       "SDL::Surface::pitch" returns the width of a surface's scanline in
160       bytes
161
162       pixels ()
163
164       "SDL::Surface::pixels" returns a Uint8* to the image's pixel data.
165       This is not inherently useful within perl, though may be used to pass
166       image data to user provided C functions.
167
168       pixel (x,y,[color])
169
170       "SDL::Surface::pixel" will set the color value of the pixel at (x,y) to
171       the given color if provided.  "SDL::Surface::pixel" returns a
172       SDL::Color object for the color value of the pixel at (x,y) after any
173       possible modifications.
174
175       fill (rect,color)
176
177       "SDL::Surface::fill" will fill the given SDL::Rect rectangle with the
178       specified SDL::Color This function optionally takes a SDL_Rect* and a
179       SDL_Color*
180
181       lockp ()
182
183       "SDL::Surface::lockp" returns true if the surface must be locked
184
185       lock ()
186
187       "SDL::Surface::lock" places a hardware lock if necessary, preventing
188       access to the surface's memory
189
190       unlock ()
191
192       "SDL::Surface::unlock" removes any hardware locks, enabling blits
193
194       update ( rects...)
195
196       "SDL::Surface::update" takes one or more SDL::Rect's which determine
197       which sections of the image are to be updated.  This option is only
198       useful on the appliaction surface.
199
200       flip ()
201
202       "SDL::Surface::flip" updates the full surface, using a double buffer if
203       available
204
205       blit (srect,dest,drect)
206
207       "SDL::Surface::blit" blits the current surface onto the destination
208       surface, according to the provided rectangles.  If a rectangle is 0,
209       then the full surface is used.
210
211       set_colors (start,colors...)
212
213       "SDL::Surface::set_colors" updates the palette starting at index
214       "start" with the supplied colors.  The colors may either be SDL::Color
215       objects or SDL_Color* from the low level C-style API.
216
217       set_color_key (flag,pixel) or (flag,x,y)
218
219       "SDL::Surface::set_color_key" sets the blit flag, usually SDL_SRCCOL‐
220       ORKEY, to the specified SDL::Color object.  Optional a SDL_Color* may
221       be passed.
222
223       set_alpha (flag,alpha)
224
225       "SDL::Surface::set_alpha" sets the opacity of the image for alpha
226       blits.  "alpha" takes a value from 0x00 to 0xff.
227
228       display_format ()
229
230       "SDL::Surface::display_format" converts the surface to the same format
231       as the current screen.
232
233       rgb () "SDL::Surface::rgb" converts the surface to a 24 bit rgb format
234       regardless of the initial format.
235
236       rgba () "SDL::Surface::rgba" converts the surface to a 32 bit rgba for‐
237       mat regarless of the initial format.
238
239       print (x,y,text...)
240
241       "SDL::Surface::print" renders the text using the current font onto the
242       image.  This option is only supported for with SDL_image and SFont.
243
244       save_bmp (filename)
245
246       "SDL::Surface::save_bmp" saves the surface to filename in Windows BMP
247       format.
248
249       video_info ()
250
251       "SDL::Surface::video_info" returns a hash describing the current state
252       of the video hardware.
253

AUTHOR

255       David J. Goehrig
256

SEE ALSO

258       perl SDL::App SDL::Color SDL::Palette SDL::Rect
259
260
261
262perl v5.8.8                       2006-08-28                   SDL::Surface(3)
Impressum