Module surface

Module surface 

Source
Expand description

SDL surfaces are buffers of pixels in system RAM. These are useful for passing around and manipulating images that are not stored in GPU memory.

SDL_Surface makes serious efforts to manage images in various formats, and provides a reasonable toolbox for transforming the data, including copying between surfaces, filling rectangles in the image data, etc.

There is also a simple .bmp loader, SDL_LoadBMP(), and a simple .png loader, SDL_LoadPNG(). SDL itself does not provide loaders for other file formats, but there are several excellent external libraries that do, including its own satellite library, SDL_image .

In general these functions are thread-safe in that they can be called on different threads with different surfaces. You should not try to modify any surface from two threads simultaneously.

Structs§

SDL_FlipMode
The flip mode.
SDL_ScaleMode
The scaling mode.
SDL_Surface
A collection of pixels used in software blitting.
SDL_SurfaceFlags
The flags on an SDL_Surface.

Constants§

SDL_FLIP_HORIZONTAL
flip horizontally
SDL_FLIP_HORIZONTAL_AND_VERTICAL
flip horizontally and vertically (not a diagonal flip)
SDL_FLIP_NONE
Do not flip
SDL_FLIP_VERTICAL
flip vertically
SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT
SDL_PROP_SURFACE_HOTSPOT_X_NUMBER
SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER
SDL_PROP_SURFACE_ROTATION_FLOAT
SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT
SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING
SDL_SCALEMODE_INVALID
SDL_SCALEMODE_LINEAR
linear filtering
SDL_SCALEMODE_NEAREST
nearest pixel sampling
SDL_SCALEMODE_PIXELART
nearest pixel sampling with improved scaling for pixel art, available since SDL 3.4.0
SDL_SURFACE_LOCKED
Surface is currently locked
SDL_SURFACE_LOCK_NEEDED
Surface needs to be locked to access pixels
SDL_SURFACE_PREALLOCATED
Surface uses preallocated pixel memory
SDL_SURFACE_SIMD_ALIGNED
Surface uses pixel memory allocated with SDL_aligned_alloc()

Functions§

SDL_AddSurfaceAlternateImage
Add an alternate version of a surface.
SDL_BlitSurface
Performs a fast blit from the source surface to the destination surface with clipping.
SDL_BlitSurface9Grid
Perform a scaled blit using the 9-grid algorithm to a destination surface, which may be of a different format.
SDL_BlitSurfaceScaled
Perform a scaled blit to a destination surface, which may be of a different format.
SDL_BlitSurfaceTiled
Perform a tiled blit to a destination surface, which may be of a different format.
SDL_BlitSurfaceTiledWithScale
Perform a scaled and tiled blit to a destination surface, which may be of a different format.
SDL_BlitSurfaceUnchecked
Perform low-level surface blitting only.
SDL_BlitSurfaceUncheckedScaled
Perform low-level surface scaled blitting only.
SDL_ClearSurface
Clear a surface with a specific color, with floating point precision.
SDL_ConvertPixels
Copy a block of pixels of one format to another format.
SDL_ConvertPixelsAndColorspace
Copy a block of pixels of one format and colorspace to another format and colorspace.
SDL_ConvertSurface
Copy an existing surface to a new surface of the specified format.
SDL_ConvertSurfaceAndColorspace
Copy an existing surface to a new surface of the specified format and colorspace.
SDL_CreateSurface
Allocate a new surface with a specific pixel format.
SDL_CreateSurfaceFrom
Allocate a new surface with a specific pixel format and existing pixel data.
SDL_CreateSurfacePalette
Create a palette and associate it with a surface.
SDL_DestroySurface
Free a surface.
SDL_DuplicateSurface
Creates a new surface identical to the existing surface.
SDL_FillSurfaceRect
Perform a fast fill of a rectangle with a specific color.
SDL_FillSurfaceRects
Perform a fast fill of a set of rectangles with a specific color.
SDL_FlipSurface
Flip a surface vertically or horizontally.
SDL_GetSurfaceAlphaMod
Get the additional alpha value used in blit operations.
SDL_GetSurfaceBlendMode
Get the blend mode used for blit operations.
SDL_GetSurfaceClipRect
Get the clipping rectangle for a surface.
SDL_GetSurfaceColorKey
Get the color key (transparent pixel) for a surface.
SDL_GetSurfaceColorMod
Get the additional color value multiplied into blit operations.
SDL_GetSurfaceColorspace
Get the colorspace used by a surface.
SDL_GetSurfaceImages
Get an array including all versions of a surface.
SDL_GetSurfacePalette
Get the palette used by a surface.
SDL_GetSurfaceProperties
Get the properties associated with a surface.
SDL_LoadBMP
Load a BMP image from a file.
SDL_LoadBMP_IO
Load a BMP image from a seekable SDL data stream.
SDL_LoadPNG
Load a PNG image from a file.
SDL_LoadPNG_IO
Load a PNG image from a seekable SDL data stream.
SDL_LoadSurface
Load a BMP or PNG image from a file.
SDL_LoadSurface_IO
Load a BMP or PNG image from a seekable SDL data stream.
SDL_LockSurface
Set up a surface for directly accessing the pixels.
SDL_MUSTLOCK
Evaluates to true if the surface needs to be locked before access.
SDL_MapSurfaceRGB
Map an RGB triple to an opaque pixel value for a surface.
SDL_MapSurfaceRGBA
Map an RGBA quadruple to a pixel value for a surface.
SDL_PremultiplyAlpha
Premultiply the alpha on a block of pixels.
SDL_PremultiplySurfaceAlpha
Premultiply the alpha in a surface.
SDL_ReadSurfacePixel
Retrieves a single pixel from a surface.
SDL_ReadSurfacePixelFloat
Retrieves a single pixel from a surface.
SDL_RemoveSurfaceAlternateImages
Remove all alternate versions of a surface.
SDL_RotateSurface
Return a copy of a surface rotated clockwise a number of degrees.
SDL_SaveBMP
Save a surface to a file in BMP format.
SDL_SaveBMP_IO
Save a surface to a seekable SDL data stream in BMP format.
SDL_SavePNG
Save a surface to a file in PNG format.
SDL_SavePNG_IO
Save a surface to a seekable SDL data stream in PNG format.
SDL_ScaleSurface
Creates a new surface identical to the existing surface, scaled to the desired size.
SDL_SetSurfaceAlphaMod
Set an additional alpha value used in blit operations.
SDL_SetSurfaceBlendMode
Set the blend mode used for blit operations.
SDL_SetSurfaceClipRect
Set the clipping rectangle for a surface.
SDL_SetSurfaceColorKey
Set the color key (transparent pixel) in a surface.
SDL_SetSurfaceColorMod
Set an additional color value multiplied into blit operations.
SDL_SetSurfaceColorspace
Set the colorspace used by a surface.
SDL_SetSurfacePalette
Set the palette used by a surface.
SDL_SetSurfaceRLE
Set the RLE acceleration hint for a surface.
SDL_StretchSurface
Perform a stretched pixel copy from one surface to another.
SDL_SurfaceHasAlternateImages
Return whether a surface has alternate versions available.
SDL_SurfaceHasColorKey
Returns whether the surface has a color key.
SDL_SurfaceHasRLE
Returns whether the surface is RLE enabled.
SDL_UnlockSurface
Release a surface after directly accessing the pixels.
SDL_WriteSurfacePixel
Writes a single pixel to a surface.
SDL_WriteSurfacePixelFloat
Writes a single pixel to a surface.