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

AUTHOR

217       David J. Goehrig
218

SEE ALSO

220       perl SDL::App SDL::Color SDL::Palette SDL::Rect
221
222
223
224perl v5.12.0                      2010-05-06                   SDL::Surface(3)
Impressum