SDL_CreateRGBSurfaceFrom

Name

SDL_CreateRGBSurfaceFrom -- Create an SDL_Surface from pixel data

Synopsis

#include "SDL.h"

SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels,
                        int width, int height, int depth, int pitch,
                        Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);

Description

Creates an SDL_Surface from the provided pixel data.

No copy is made from the pixel data. A special undocumented surface flag is set. The pixel data won't be deallocated automatically when SDL_FreeSurface is invoked with the surface and it should not be freed until the surface has been freed. The data stored in pixels is assumed to have depth bits per pixel. Pitch is the size of the scanline of the surface, in bytes, i.e. widthInPixels*bytesPerPixel. The scanline is the width of the image multiplied by bytes per pixel, plus any bytes added for alignment (that is if pixels points to the leftmost pixel on the first row of the surface, then pixels+pitch points to the leftmost pixel on the second row of the surface).

The pixel data is considered to be in software memory. If the pixel data lies in hardware memory (as pixel data from a hardware surface), the appropriate surface flag has to be set manually.

See SDL_CreateRGBSurface for a more detailed description of the other parameters.

Return Value

Returns the created surface, or NULL upon error.

See Also

SDL_CreateRGBSurface, SDL_FreeSurface

SDL_CreateRGBSurfaceFrom (last edited 2009-09-12 21:40:11 by Ondratra)