11 MODULE = SDL::Surface PACKAGE = SDL::Surface PREFIX = surface_
15 SDL_Surface -- Graphic surface structure
17 typedef struct SDL_Surface {
18 Uint32 flags; /* Read-only */
19 SDL_PixelFormat *format; /* Read-only */
20 int w, h; /* Read-only */
21 Uint16 pitch; /* Read-only */
22 void *pixels; /* Read-write */
23 SDL_Rect clip_rect; /* Read-only */
24 int refcount; /* Read-mostly */
26 /* This structure also contains private fields not shown here */
32 surface_new (CLASS, flags, width, height, depth, Rmask, Gmask, Bmask, Amask )
43 RETVAL = SDL_CreateRGBSurface ( flags, width, height,
44 depth, Rmask, Gmask, Bmask, Amask );
49 surface_new_from (CLASS, pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask )
62 int len = pitch * height;
63 Newx(pixeldata,len,Uint8);
64 Copy(pixels,pixeldata,len,Uint8);
65 RETVAL = SDL_CreateRGBSurfaceFrom ( pixeldata, width, height,
66 depth, pitch, Rmask, Gmask, Bmask, Amask );
73 surface_format ( surface )
76 char* CLASS = "SDL::PixelFormat";
78 RETVAL = surface->format;
83 surface_pitch( surface )
86 RETVAL = surface->pitch;
107 surface_get_pixels(surface)
110 if(!surface->pixels) croak("Incomplete surface");
111 RETVAL = PTR2IV(surface->pixels);
116 surface_set_pixels(surface, pixels)
126 p = SvPV(pixels, len);
127 if (len > surface->pitch*surface->h)
128 len = surface->pitch*surface->h;
129 memcpy(surface->pixels, p, len);
132 surface_DESTROY(surface)
135 Uint8* pixels = surface->pixels;
136 Uint32 flags = surface->flags;
137 SDL_FreeSurface(surface);
138 if (flags & SDL_PREALLOC)