SDL_surface.h File Reference
`#include <SDL3/SDL_stdinc.h>`
`#include <SDL3/SDL_error.h>`
`#include <SDL3/SDL_blendmode.h>`
`#include <SDL3/SDL_pixels.h>`
`#include <SDL3/SDL_properties.h>`
`#include <SDL3/SDL_rect.h>`
`#include <SDL3/SDL_iostream.h>`
`#include <SDL3/SDL_begin_code.h>`
`#include <SDL3/SDL_close_code.h>`
Include dependency graph for SDL_surface.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | SDL_Surface

## Macros

#define | SDL_SURFACE_PREALLOCATED 0x00000001u
#define | SDL_SURFACE_LOCK_NEEDED 0x00000002u
#define | SDL_SURFACE_LOCKED 0x00000004u
#define | SDL_SURFACE_SIMD_ALIGNED 0x00000008u
#define | SDL_MUSTLOCK(S) (((S)->flags & SDL_SURFACE_LOCK_NEEDED) == SDL_SURFACE_LOCK_NEEDED)
#define | SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT "SDL.surface.SDR_white_point"
#define | SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT "SDL.surface.HDR_headroom"
#define | SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING "SDL.surface.tonemap"
#define | SDL_PROP_SURFACE_HOTSPOT_X_NUMBER "SDL.surface.hotspot.x"
#define | SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER "SDL.surface.hotspot.y"

## Typedefs

typedef Uint32 | SDL_SurfaceFlags

## Enumerations

enum | SDL_ScaleMode { SDL_SCALEMODE_NEAREST , SDL_SCALEMODE_LINEAR }
enum | SDL_FlipMode { SDL_FLIP_NONE , SDL_FLIP_HORIZONTAL , SDL_FLIP_VERTICAL }

## Functions

SDL_Surface * | SDL_CreateSurface (int width, int height, SDL_PixelFormat format)
SDL_Surface * | SDL_CreateSurfaceFrom (int width, int height, SDL_PixelFormat format, void *pixels, int pitch)
void | SDL_DestroySurface (SDL_Surface *surface)
SDL_PropertiesID | SDL_GetSurfaceProperties (SDL_Surface *surface)
bool | SDL_SetSurfaceColorspace (SDL_Surface *surface, SDL_Colorspace colorspace)
SDL_Colorspace | SDL_GetSurfaceColorspace (SDL_Surface *surface)
SDL_Palette * | SDL_CreateSurfacePalette (SDL_Surface *surface)
bool | SDL_SetSurfacePalette (SDL_Surface *surface, SDL_Palette *palette)
SDL_Palette * | SDL_GetSurfacePalette (SDL_Surface *surface)
bool | SDL_AddSurfaceAlternateImage (SDL_Surface *surface, SDL_Surface *image)
bool | SDL_SurfaceHasAlternateImages (SDL_Surface *surface)
SDL_Surface ** | SDL_GetSurfaceImages (SDL_Surface *surface, int *count)
void | SDL_RemoveSurfaceAlternateImages (SDL_Surface *surface)
bool | SDL_LockSurface (SDL_Surface *surface)
void | SDL_UnlockSurface (SDL_Surface *surface)
SDL_Surface * | SDL_LoadBMP_IO (SDL_IOStream *src, bool closeio)
SDL_Surface * | SDL_LoadBMP (const char *file)
bool | SDL_SaveBMP_IO (SDL_Surface *surface, SDL_IOStream *dst, bool closeio)
bool | SDL_SaveBMP (SDL_Surface *surface, const char *file)
bool | SDL_SetSurfaceRLE (SDL_Surface *surface, bool enabled)
bool | SDL_SurfaceHasRLE (SDL_Surface *surface)
bool | SDL_SetSurfaceColorKey (SDL_Surface *surface, bool enabled, Uint32 key)
bool | SDL_SurfaceHasColorKey (SDL_Surface *surface)
bool | SDL_GetSurfaceColorKey (SDL_Surface *surface, Uint32 *key)
bool | SDL_SetSurfaceColorMod (SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
bool | SDL_GetSurfaceColorMod (SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b)
bool | SDL_SetSurfaceAlphaMod (SDL_Surface *surface, Uint8 alpha)
bool | SDL_GetSurfaceAlphaMod (SDL_Surface *surface, Uint8 *alpha)
bool | SDL_SetSurfaceBlendMode (SDL_Surface *surface, SDL_BlendMode blendMode)
bool | SDL_GetSurfaceBlendMode (SDL_Surface *surface, SDL_BlendMode *blendMode)
bool | SDL_SetSurfaceClipRect (SDL_Surface *surface, const SDL_Rect *rect)
bool | SDL_GetSurfaceClipRect (SDL_Surface *surface, SDL_Rect *rect)
bool | SDL_FlipSurface (SDL_Surface *surface, SDL_FlipMode flip)
SDL_Surface * | SDL_DuplicateSurface (SDL_Surface *surface)
SDL_Surface * | SDL_ScaleSurface (SDL_Surface *surface, int width, int height, SDL_ScaleMode scaleMode)
SDL_Surface * | SDL_ConvertSurface (SDL_Surface *surface, SDL_PixelFormat format)
SDL_Surface * | SDL_ConvertSurfaceAndColorspace (SDL_Surface *surface, SDL_PixelFormat format, SDL_Palette *palette, SDL_Colorspace colorspace, SDL_PropertiesID props)
bool | SDL_ConvertPixels (int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch)
bool | SDL_ConvertPixelsAndColorspace (int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch)
bool | SDL_PremultiplyAlpha (int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch, bool linear)
bool | SDL_PremultiplySurfaceAlpha (SDL_Surface *surface, bool linear)
bool | SDL_ClearSurface (SDL_Surface *surface, float r, float g, float b, float a)
bool | SDL_FillSurfaceRect (SDL_Surface *dst, const SDL_Rect *rect, Uint32 color)
bool | SDL_FillSurfaceRects (SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color)
bool | SDL_BlitSurface (SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect)
bool | SDL_BlitSurfaceUnchecked (SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect)
bool | SDL_BlitSurfaceScaled (SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode)
bool | SDL_BlitSurfaceUncheckedScaled (SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode)
bool | SDL_StretchSurface (SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode)
bool | SDL_BlitSurfaceTiled (SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect)
bool | SDL_BlitSurfaceTiledWithScale (SDL_Surface *src, const SDL_Rect *srcrect, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect)
bool | SDL_BlitSurface9Grid (SDL_Surface *src, const SDL_Rect *srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect)
Uint32 | SDL_MapSurfaceRGB (SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
Uint32 | SDL_MapSurfaceRGBA (SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
bool | SDL_ReadSurfacePixel (SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
bool | SDL_ReadSurfacePixelFloat (SDL_Surface *surface, int x, int y, float *r, float *g, float *b, float *a)
bool | SDL_WriteSurfacePixel (SDL_Surface *surface, int x, int y, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
bool | SDL_WriteSurfacePixelFloat (SDL_Surface *surface, int x, int y, float r, float g, float b, float a)

## Macro Definition Documentation

## SDL_MUSTLOCK

#define SDL_MUSTLOCK | ( |  | S | ) | (((S)->flags & SDL_SURFACE_LOCK_NEEDED) == SDL_SURFACE_LOCK_NEEDED)

Evaluates to true if the surface needs to be locked before access.

Since
  This macro is available since SDL 3.2.0.

Definition at line 76 of file SDL_surface.h.

## SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT

#define SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT "SDL.surface.HDR_headroom"

Definition at line 241 of file SDL_surface.h.

## SDL_PROP_SURFACE_HOTSPOT_X_NUMBER

#define SDL_PROP_SURFACE_HOTSPOT_X_NUMBER "SDL.surface.hotspot.x"

Definition at line 243 of file SDL_surface.h.

## SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER

#define SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER "SDL.surface.hotspot.y"

Definition at line 244 of file SDL_surface.h.

## SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT

#define SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT "SDL.surface.SDR_white_point"

Definition at line 240 of file SDL_surface.h.

## SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING

#define SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING "SDL.surface.tonemap"

Definition at line 242 of file SDL_surface.h.

## SDL_SURFACE_LOCK_NEEDED

#define SDL_SURFACE_LOCK_NEEDED 0x00000002u

Surface needs to be locked to access pixels

Definition at line 67 of file SDL_surface.h.

## SDL_SURFACE_LOCKED

#define SDL_SURFACE_LOCKED 0x00000004u

Surface is currently locked

Definition at line 68 of file SDL_surface.h.

## SDL_SURFACE_PREALLOCATED

#define SDL_SURFACE_PREALLOCATED 0x00000001u

Surface uses preallocated pixel memory

Definition at line 66 of file SDL_surface.h.

## SDL_SURFACE_SIMD_ALIGNED

#define SDL_SURFACE_SIMD_ALIGNED 0x00000008u

Surface uses pixel memory allocated with SDL_aligned_alloc()

Definition at line 69 of file SDL_surface.h.

## Typedef Documentation

## SDL_SurfaceFlags

typedef Uint32 SDL_SurfaceFlags

# CategorySurface

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(). SDL itself does not provide loaders for various other file formats, but there are several excellent external libraries that do, including its own satellite library, SDL_image:

https://github.com/libsdl-org/SDL_image The flags on an SDL_Surface.

These are generally considered read-only.

Since
  This datatype is available since SDL 3.2.0.

Definition at line 64 of file SDL_surface.h.

## Enumeration Type Documentation

## SDL_FlipMode

enum SDL_FlipMode

The flip mode.

Since
  This enum is available since SDL 3.2.0.

Enumerator
SDL_FLIP_NONE | Do not flip
SDL_FLIP_HORIZONTAL | flip horizontally
SDL_FLIP_VERTICAL | flip vertically

Definition at line 94 of file SDL_surface.h.

{
SDL_FLIP_NONE, /**< Do not flip */
SDL_FLIP_HORIZONTAL, /**< flip horizontally */
SDL_FLIP_VERTICAL /**< flip vertically */
} SDL_FlipMode;
SDL_FlipMode
SDL_FlipMode
Definition SDL_surface.h:95
SDL_FLIP_VERTICAL
@ SDL_FLIP_VERTICAL
Definition SDL_surface.h:98
SDL_FLIP_NONE
@ SDL_FLIP_NONE
Definition SDL_surface.h:96
SDL_FLIP_HORIZONTAL
@ SDL_FLIP_HORIZONTAL
Definition SDL_surface.h:97

## SDL_ScaleMode

enum SDL_ScaleMode

The scaling mode.

Since
  This enum is available since SDL 3.2.0.

Enumerator
SDL_SCALEMODE_NEAREST | nearest pixel sampling
SDL_SCALEMODE_LINEAR | linear filtering

Definition at line 83 of file SDL_surface.h.

{
SDL_SCALEMODE_NEAREST, /**< nearest pixel sampling */
SDL_SCALEMODE_LINEAR /**< linear filtering */
} SDL_ScaleMode;
SDL_ScaleMode
SDL_ScaleMode
Definition SDL_surface.h:84
SDL_SCALEMODE_LINEAR
@ SDL_SCALEMODE_LINEAR
Definition SDL_surface.h:86
SDL_SCALEMODE_NEAREST
@ SDL_SCALEMODE_NEAREST
Definition SDL_surface.h:85

## Function Documentation

## SDL_AddSurfaceAlternateImage()

bool SDL_AddSurfaceAlternateImage | ( | SDL_Surface * | surface,
|  | SDL_Surface * | image
| ) |  |

extern

Add an alternate version of a surface.

This function adds an alternate version of this surface, usually used for content with high DPI representations like cursors or icons. The size, format, and content do not need to match the original surface, and these alternate versions will not be updated when the original surface changes.

This function adds a reference to the alternate version, so you should call SDL_DestroySurface() on the image after this call.

Parameters

  surface | the SDL_Surface structure to update.
  image | a pointer to an alternate SDL_Surface to associate with this surface.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_RemoveSurfaceAlternateImages
  SDL_GetSurfaceImages
  SDL_SurfaceHasAlternateImages

## SDL_BlitSurface()

bool SDL_BlitSurface | ( | SDL_Surface * | src,
|  | const SDL_Rect * | srcrect,
|  | SDL_Surface * | dst,
|  | const SDL_Rect * | dstrect
| ) |  |

extern

Performs a fast blit from the source surface to the destination surface with clipping.

If either `srcrect` or `dstrect` are NULL, the entire surface (`src` or `dst`) is copied while ensuring clipping to `dst->clip_rect`.

The final blit rectangles are saved in `srcrect` and `dstrect` after all clipping is performed.

The blit function should not be called on a locked surface.

The blit semantics for surfaces with and without blending and colorkey are defined as follows:

RGBA->RGB:
Source surface blend mode set to SDL_BLENDMODE_BLEND:
alpha-blend (using the source alpha-channel and per-surface alpha)
SDL_SRCCOLORKEY ignored.
Source surface blend mode set to SDL_BLENDMODE_NONE:
copy RGB.
if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
RGB values of the source color key, ignoring alpha in the
comparison.
RGB->RGBA:
Source surface blend mode set to SDL_BLENDMODE_BLEND:
alpha-blend (using the source per-surface alpha)
Source surface blend mode set to SDL_BLENDMODE_NONE:
copy RGB, set destination alpha to source per-surface alpha value.
both:
if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
source color key.
RGBA->RGBA:
Source surface blend mode set to SDL_BLENDMODE_BLEND:
alpha-blend (using the source alpha-channel and per-surface alpha)
SDL_SRCCOLORKEY ignored.
Source surface blend mode set to SDL_BLENDMODE_NONE:
copy all of RGBA to the destination.
if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
RGB values of the source color key, ignoring alpha in the
comparison.
RGB->RGB:
Source surface blend mode set to SDL_BLENDMODE_BLEND:
alpha-blend (using the source per-surface alpha)
Source surface blend mode set to SDL_BLENDMODE_NONE:
copy RGB.
both:
if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
source color key.
SDL_BLENDMODE_BLEND
#define SDL_BLENDMODE_BLEND
Definition SDL_blendmode.h:55
SDL_BLENDMODE_NONE
#define SDL_BLENDMODE_NONE
Definition SDL_blendmode.h:54

Parameters

  src | the SDL_Surface structure to be copied from.
  srcrect | the SDL_Rect structure representing the rectangle to be copied, or NULL to copy the entire surface.
  dst | the SDL_Surface structure that is the blit target.
  dstrect | the SDL_Rect structure representing the x and y position in the destination surface, or NULL for (0,0). The width and height are ignored, and are copied from `srcrect`. If you want a specific width and height, you should use SDL_BlitSurfaceScaled().

Returns
  true on success or false on failure; call SDL_GetError() for more information.

\threadsafety The same destination surface should not be used from two threads at once. It is safe to use the same source surface from multiple threads.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_BlitSurfaceScaled

## SDL_BlitSurface9Grid()

bool SDL_BlitSurface9Grid | ( | SDL_Surface * | src,
|  | const SDL_Rect * | srcrect,
|  | int | left_width,
|  | int | right_width,
|  | int | top_height,
|  | int | bottom_height,
|  | float | scale,
|  | SDL_ScaleMode | scaleMode,
|  | SDL_Surface * | dst,
|  | const SDL_Rect * | dstrect
| ) |  |

extern

Perform a scaled blit using the 9-grid algorithm to a destination surface, which may be of a different format.

The pixels in the source surface are split into a 3x3 grid, using the different corner sizes for each corner, and the sides and center making up the remaining pixels. The corners are then scaled using `scale` and fit into the corners of the destination rectangle. The sides and center are then stretched into place to cover the remaining destination rectangle.

Parameters

  src | the SDL_Surface structure to be copied from.
  srcrect | the SDL_Rect structure representing the rectangle to be used for the 9-grid, or NULL to use the entire surface.
  left_width | the width, in pixels, of the left corners in `srcrect`.
  right_width | the width, in pixels, of the right corners in `srcrect`.
  top_height | the height, in pixels, of the top corners in `srcrect`.
  bottom_height | the height, in pixels, of the bottom corners in `srcrect`.
  scale | the scale used to transform the corner of `srcrect` into the corner of `dstrect`, or 0.0f for an unscaled blit.
  scaleMode | scale algorithm to be used.
  dst | the SDL_Surface structure that is the blit target.
  dstrect | the SDL_Rect structure representing the target rectangle in the destination surface, or NULL to fill the entire surface.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

\threadsafety The same destination surface should not be used from two threads at once. It is safe to use the same source surface from multiple threads.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_BlitSurface

## SDL_BlitSurfaceScaled()

bool SDL_BlitSurfaceScaled | ( | SDL_Surface * | src,
|  | const SDL_Rect * | srcrect,
|  | SDL_Surface * | dst,
|  | const SDL_Rect * | dstrect,
|  | SDL_ScaleMode | scaleMode
| ) |  |

extern

Perform a scaled blit to a destination surface, which may be of a different format.

Parameters

  src | the SDL_Surface structure to be copied from.
  srcrect | the SDL_Rect structure representing the rectangle to be copied, or NULL to copy the entire surface.
  dst | the SDL_Surface structure that is the blit target.
  dstrect | the SDL_Rect structure representing the target rectangle in the destination surface, or NULL to fill the entire destination surface.
  scaleMode | the SDL_ScaleMode to be used.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

\threadsafety The same destination surface should not be used from two threads at once. It is safe to use the same source surface from multiple threads.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_BlitSurface

## SDL_BlitSurfaceTiled()

bool SDL_BlitSurfaceTiled | ( | SDL_Surface * | src,
|  | const SDL_Rect * | srcrect,
|  | SDL_Surface * | dst,
|  | const SDL_Rect * | dstrect
| ) |  |

extern

Perform a tiled blit to a destination surface, which may be of a different format.

The pixels in `srcrect` will be repeated as many times as needed to completely fill `dstrect`.

Parameters

  src | the SDL_Surface structure to be copied from.
  srcrect | the SDL_Rect structure representing the rectangle to be copied, or NULL to copy the entire surface.
  dst | the SDL_Surface structure that is the blit target.
  dstrect | the SDL_Rect structure representing the target rectangle in the destination surface, or NULL to fill the entire surface.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

\threadsafety The same destination surface should not be used from two threads at once. It is safe to use the same source surface from multiple threads.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_BlitSurface

## SDL_BlitSurfaceTiledWithScale()

bool SDL_BlitSurfaceTiledWithScale | ( | SDL_Surface * | src,
|  | const SDL_Rect * | srcrect,
|  | float | scale,
|  | SDL_ScaleMode | scaleMode,
|  | SDL_Surface * | dst,
|  | const SDL_Rect * | dstrect
| ) |  |

extern

Perform a scaled and tiled blit to a destination surface, which may be of a different format.

The pixels in `srcrect` will be scaled and repeated as many times as needed to completely fill `dstrect`.

Parameters

  src | the SDL_Surface structure to be copied from.
  srcrect | the SDL_Rect structure representing the rectangle to be copied, or NULL to copy the entire surface.
  scale | the scale used to transform srcrect into the destination rectangle, e.g. a 32x32 texture with a scale of 2 would fill 64x64 tiles.
  scaleMode | scale algorithm to be used.
  dst | the SDL_Surface structure that is the blit target.
  dstrect | the SDL_Rect structure representing the target rectangle in the destination surface, or NULL to fill the entire surface.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

\threadsafety The same destination surface should not be used from two threads at once. It is safe to use the same source surface from multiple threads.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_BlitSurface

## SDL_BlitSurfaceUnchecked()

bool SDL_BlitSurfaceUnchecked | ( | SDL_Surface * | src,
|  | const SDL_Rect * | srcrect,
|  | SDL_Surface * | dst,
|  | const SDL_Rect * | dstrect
| ) |  |

extern

Perform low-level surface blitting only.

This is a semi-private blit function and it performs low-level surface blitting, assuming the input rectangles have already been clipped.

Parameters

  src | the SDL_Surface structure to be copied from.
  srcrect | the SDL_Rect structure representing the rectangle to be copied, may not be NULL.
  dst | the SDL_Surface structure that is the blit target.
  dstrect | the SDL_Rect structure representing the target rectangle in the destination surface, may not be NULL.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

\threadsafety The same destination surface should not be used from two threads at once. It is safe to use the same source surface from multiple threads.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_BlitSurface

## SDL_BlitSurfaceUncheckedScaled()

bool SDL_BlitSurfaceUncheckedScaled | ( | SDL_Surface * | src,
|  | const SDL_Rect * | srcrect,
|  | SDL_Surface * | dst,
|  | const SDL_Rect * | dstrect,
|  | SDL_ScaleMode | scaleMode
| ) |  |

extern

Perform low-level surface scaled blitting only.

This is a semi-private function and it performs low-level surface blitting, assuming the input rectangles have already been clipped.

Parameters

  src | the SDL_Surface structure to be copied from.
  srcrect | the SDL_Rect structure representing the rectangle to be copied, may not be NULL.
  dst | the SDL_Surface structure that is the blit target.
  dstrect | the SDL_Rect structure representing the target rectangle in the destination surface, may not be NULL.
  scaleMode | the SDL_ScaleMode to be used.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

\threadsafety The same destination surface should not be used from two threads at once. It is safe to use the same source surface from multiple threads.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_BlitSurfaceScaled

## SDL_ClearSurface()

bool SDL_ClearSurface | ( | SDL_Surface * | surface,
|  | float | r,
|  | float | g,
|  | float | b,
|  | float | a
| ) |  |

extern

Clear a surface with a specific color, with floating point precision.

This function handles all surface formats, and ignores any clip rectangle.

If the surface is YUV, the color is assumed to be in the sRGB colorspace, otherwise the color is assumed to be in the colorspace of the suface.

Parameters

  surface | the SDL_Surface to clear.
  r | the red component of the pixel, normally in the range 0-1.
  g | the green component of the pixel, normally in the range 0-1.
  b | the blue component of the pixel, normally in the range 0-1.
  a | the alpha component of the pixel, normally in the range 0-1.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

## SDL_ConvertPixels()

bool SDL_ConvertPixels | ( | int | width,
|  | int | height,
|  | SDL_PixelFormat | src_format,
|  | const void * | src,
|  | int | src_pitch,
|  | SDL_PixelFormat | dst_format,
|  | void * | dst,
|  | int | dst_pitch
| ) |  |

extern

Copy a block of pixels of one format to another format.

Parameters

  width | the width of the block to copy, in pixels.
  height | the height of the block to copy, in pixels.
  src_format | an SDL_PixelFormat value of the `src` pixels format.
  src | a pointer to the source pixels.
  src_pitch | the pitch of the source pixels, in bytes.
  dst_format | an SDL_PixelFormat value of the `dst` pixels format.
  dst | a pointer to be filled in with new pixel data.
  dst_pitch | the pitch of the destination pixels, in bytes.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_ConvertPixelsAndColorspace

## SDL_ConvertPixelsAndColorspace()

bool SDL_ConvertPixelsAndColorspace | ( | int | width,
|  | int | height,
|  | SDL_PixelFormat | src_format,
|  | SDL_Colorspace | src_colorspace,
|  | SDL_PropertiesID | src_properties,
|  | const void * | src,
|  | int | src_pitch,
|  | SDL_PixelFormat | dst_format,
|  | SDL_Colorspace | dst_colorspace,
|  | SDL_PropertiesID | dst_properties,
|  | void * | dst,
|  | int | dst_pitch
| ) |  |

extern

Copy a block of pixels of one format and colorspace to another format and colorspace.

Parameters

  width | the width of the block to copy, in pixels.
  height | the height of the block to copy, in pixels.
  src_format | an SDL_PixelFormat value of the `src` pixels format.
  src_colorspace | an SDL_Colorspace value describing the colorspace of the `src` pixels.
  src_properties | an SDL_PropertiesID with additional source color properties, or 0.
  src | a pointer to the source pixels.
  src_pitch | the pitch of the source pixels, in bytes.
  dst_format | an SDL_PixelFormat value of the `dst` pixels format.
  dst_colorspace | an SDL_Colorspace value describing the colorspace of the `dst` pixels.
  dst_properties | an SDL_PropertiesID with additional destination color properties, or 0.
  dst | a pointer to be filled in with new pixel data.
  dst_pitch | the pitch of the destination pixels, in bytes.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_ConvertPixels

## SDL_ConvertSurface()

SDL_Surface * SDL_ConvertSurface | ( | SDL_Surface * | surface,
|  | SDL_PixelFormat | format
| ) |  |

extern

Copy an existing surface to a new surface of the specified format.

This function is used to optimize images for faster repeat blitting. This is accomplished by converting the original and storing the result as a new surface. The new, optimized surface can then be used as the source for future blits, making them faster.

If you are converting to an indexed surface and want to map colors to a palette, you can use SDL_ConvertSurfaceAndColorspace() instead.

If the original surface has alternate images, the new surface will have a reference to them as well.

Parameters

  surface | the existing SDL_Surface structure to convert.
  format | the new pixel format.

Returns
  the new SDL_Surface structure that is created or NULL on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_ConvertSurfaceAndColorspace
  SDL_DestroySurface

## SDL_ConvertSurfaceAndColorspace()

SDL_Surface * SDL_ConvertSurfaceAndColorspace | ( | SDL_Surface * | surface,
|  | SDL_PixelFormat | format,
|  | SDL_Palette * | palette,
|  | SDL_Colorspace | colorspace,
|  | SDL_PropertiesID | props
| ) |  |

extern

Copy an existing surface to a new surface of the specified format and colorspace.

This function converts an existing surface to a new format and colorspace and returns the new surface. This will perform any pixel format and colorspace conversion needed.

If the original surface has alternate images, the new surface will have a reference to them as well.

Parameters

  surface | the existing SDL_Surface structure to convert.
  format | the new pixel format.
  palette | an optional palette to use for indexed formats, may be NULL.
  colorspace | the new colorspace.
  props | an SDL_PropertiesID with additional color properties, or 0.

Returns
  the new SDL_Surface structure that is created or NULL on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_ConvertSurface
  SDL_DestroySurface

## SDL_CreateSurface()

SDL_Surface * SDL_CreateSurface | ( | int | width,
|  | int | height,
|  | SDL_PixelFormat | format
| ) |  |

extern

Allocate a new surface with a specific pixel format.

The pixels of the new surface are initialized to zero.

Parameters

  width | the width of the surface.
  height | the height of the surface.
  format | the SDL_PixelFormat for the new surface's pixel format.

Returns
  the new SDL_Surface structure that is created or NULL on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_CreateSurfaceFrom
  SDL_DestroySurface

## SDL_CreateSurfaceFrom()

SDL_Surface * SDL_CreateSurfaceFrom | ( | int | width,
|  | int | height,
|  | SDL_PixelFormat | format,
|  | void * | pixels,
|  | int | pitch
| ) |  |

extern

Allocate a new surface with a specific pixel format and existing pixel data.

No copy is made of the pixel data. Pixel data is not managed automatically; you must free the surface before you free the pixel data.

Pitch is the offset in bytes from one row of pixels to the next, e.g. `width*4` for `SDL_PIXELFORMAT_RGBA8888`.

You may pass NULL for pixels and 0 for pitch to create a surface that you will fill in with valid values later.

Parameters

  width | the width of the surface.
  height | the height of the surface.
  format | the SDL_PixelFormat for the new surface's pixel format.
  pixels | a pointer to existing pixel data.
  pitch | the number of bytes between each row, including padding.

Returns
  the new SDL_Surface structure that is created or NULL on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_CreateSurface
  SDL_DestroySurface

## SDL_CreateSurfacePalette()

SDL_Palette * SDL_CreateSurfacePalette | ( | SDL_Surface * | surface | ) |

extern

Create a palette and associate it with a surface.

This function creates a palette compatible with the provided surface. The palette is then returned for you to modify, and the surface will automatically use the new palette in future operations. You do not need to destroy the returned palette, it will be freed when the reference count reaches 0, usually when the surface is destroyed.

Bitmap surfaces (with format SDL_PIXELFORMAT_INDEX1LSB or SDL_PIXELFORMAT_INDEX1MSB) will have the palette initialized with 0 as white and 1 as black. Other surfaces will get a palette initialized with white in every entry.

If this function is called for a surface that already has a palette, a new palette will be created to replace it.

Parameters

  surface | the SDL_Surface structure to update.

Returns
  a new SDL_Palette structure on success or NULL on failure (e.g. if the surface didn't have an index format); call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_SetPaletteColors

## SDL_DestroySurface()

void SDL_DestroySurface | ( | SDL_Surface * | surface | ) |

extern

Free a surface.

It is safe to pass NULL to this function.

Parameters

  surface | the SDL_Surface to free.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_CreateSurface
  SDL_CreateSurfaceFrom

## SDL_DuplicateSurface()

SDL_Surface * SDL_DuplicateSurface | ( | SDL_Surface * | surface | ) |

extern

Creates a new surface identical to the existing surface.

If the original surface has alternate images, the new surface will have a reference to them as well.

The returned surface should be freed with SDL_DestroySurface().

Parameters

  surface | the surface to duplicate.

Returns
  a copy of the surface or NULL on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_DestroySurface

## SDL_FillSurfaceRect()

bool SDL_FillSurfaceRect | ( | SDL_Surface * | dst,
|  | const SDL_Rect * | rect,
|  | Uint32 | color
| ) |  |

extern

Perform a fast fill of a rectangle with a specific color.

`color` should be a pixel of the format used by the surface, and can be generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an alpha component then the destination is simply filled with that alpha information, no blending takes place.

If there is a clip rectangle set on the destination (set via SDL_SetSurfaceClipRect()), then this function will fill based on the intersection of the clip rectangle and `rect`.

Parameters

  dst | the SDL_Surface structure that is the drawing target.
  rect | the SDL_Rect structure representing the rectangle to fill, or NULL to fill the entire surface.
  color | the color to fill with.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_FillSurfaceRects

## SDL_FillSurfaceRects()

bool SDL_FillSurfaceRects | ( | SDL_Surface * | dst,
|  | const SDL_Rect * | rects,
|  | int | count,
|  | Uint32 | color
| ) |  |

extern

Perform a fast fill of a set of rectangles with a specific color.

`color` should be a pixel of the format used by the surface, and can be generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an alpha component then the destination is simply filled with that alpha information, no blending takes place.

If there is a clip rectangle set on the destination (set via SDL_SetSurfaceClipRect()), then this function will fill based on the intersection of the clip rectangle and `rect`.

Parameters

  dst | the SDL_Surface structure that is the drawing target.
  rects | an array of SDL_Rects representing the rectangles to fill.
  count | the number of rectangles in the array.
  color | the color to fill with.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_FillSurfaceRect

## SDL_FlipSurface()

bool SDL_FlipSurface | ( | SDL_Surface * | surface,
|  | SDL_FlipMode | flip
| ) |  |

extern

Flip a surface vertically or horizontally.

Parameters

  surface | the surface to flip.
  flip | the direction to flip.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

## SDL_GetSurfaceAlphaMod()

bool SDL_GetSurfaceAlphaMod | ( | SDL_Surface * | surface,
|  | Uint8 * | alpha
| ) |  |

extern

Get the additional alpha value used in blit operations.

Parameters

  surface | the SDL_Surface structure to query.
  alpha | a pointer filled in with the current alpha value.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_GetSurfaceColorMod
  SDL_SetSurfaceAlphaMod

## SDL_GetSurfaceBlendMode()

bool SDL_GetSurfaceBlendMode | ( | SDL_Surface * | surface,
|  | SDL_BlendMode * | blendMode
| ) |  |

extern

Get the blend mode used for blit operations.

Parameters

  surface | the SDL_Surface structure to query.
  blendMode | a pointer filled in with the current SDL_BlendMode.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_SetSurfaceBlendMode

## SDL_GetSurfaceClipRect()

bool SDL_GetSurfaceClipRect | ( | SDL_Surface * | surface,
|  | SDL_Rect * | rect
| ) |  |

extern

Get the clipping rectangle for a surface.

When `surface` is the destination of a blit, only the area within the clip rectangle is drawn into.

Parameters

  surface | the SDL_Surface structure representing the surface to be clipped.
  rect | an SDL_Rect structure filled in with the clipping rectangle for the surface.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_SetSurfaceClipRect

## SDL_GetSurfaceColorKey()

bool SDL_GetSurfaceColorKey | ( | SDL_Surface * | surface,
|  | Uint32 * | key
| ) |  |

extern

Get the color key (transparent pixel) for a surface.

The color key is a pixel of the format used by the surface, as generated by SDL_MapRGB().

If the surface doesn't have color key enabled this function returns false.

Parameters

  surface | the SDL_Surface structure to query.
  key | a pointer filled in with the transparent pixel.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_SetSurfaceColorKey
  SDL_SurfaceHasColorKey

## SDL_GetSurfaceColorMod()

bool SDL_GetSurfaceColorMod | ( | SDL_Surface * | surface,
|  | Uint8 * | r,
|  | Uint8 * | g,
|  | Uint8 * | b
| ) |  |

extern

Get the additional color value multiplied into blit operations.

Parameters

  surface | the SDL_Surface structure to query.
  r | a pointer filled in with the current red color value.
  g | a pointer filled in with the current green color value.
  b | a pointer filled in with the current blue color value.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_GetSurfaceAlphaMod
  SDL_SetSurfaceColorMod

## SDL_GetSurfaceColorspace()

SDL_Colorspace SDL_GetSurfaceColorspace | ( | SDL_Surface * | surface | ) |

extern

Get the colorspace used by a surface.

The colorspace defaults to SDL_COLORSPACE_SRGB_LINEAR for floating point formats, SDL_COLORSPACE_HDR10 for 10-bit formats, SDL_COLORSPACE_SRGB for other RGB surfaces and SDL_COLORSPACE_BT709_FULL for YUV textures.

Parameters

  surface | the SDL_Surface structure to query.

Returns
  the colorspace used by the surface, or SDL_COLORSPACE_UNKNOWN if the surface is NULL.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_SetSurfaceColorspace

## SDL_GetSurfaceImages()

SDL_Surface ** SDL_GetSurfaceImages | ( | SDL_Surface * | surface,
|  | int * | count
| ) |  |

extern

Get an array including all versions of a surface.

This returns all versions of a surface, with the surface being queried as the first element in the returned array.

Freeing the array of surfaces does not affect the surfaces in the array. They are still referenced by the surface being queried and will be cleaned up normally.

Parameters

  surface | the SDL_Surface structure to query.
  count | a pointer filled in with the number of surface pointers returned, may be NULL.

Returns
  a NULL terminated array of SDL_Surface pointers or NULL on failure; call SDL_GetError() for more information. This should be freed with SDL_free() when it is no longer needed.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_AddSurfaceAlternateImage
  SDL_RemoveSurfaceAlternateImages
  SDL_SurfaceHasAlternateImages

## SDL_GetSurfacePalette()

SDL_Palette * SDL_GetSurfacePalette | ( | SDL_Surface * | surface | ) |

extern

Get the palette used by a surface.

Parameters

  surface | the SDL_Surface structure to query.

Returns
  a pointer to the palette used by the surface, or NULL if there is no palette used.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_SetSurfacePalette

## SDL_GetSurfaceProperties()

SDL_PropertiesID SDL_GetSurfaceProperties | ( | SDL_Surface * | surface | ) |

extern

Get the properties associated with a surface.

The following properties are understood by SDL:

- `SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating point surfaces, this defines the value of 100% diffuse white, with higher values being displayed in the High Dynamic Range headroom. This defaults to 203 for HDR10 surfaces and 1.0 for floating point surfaces.
- `SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT`: for HDR10 and floating point surfaces, this defines the maximum dynamic range used by the content, in terms of the SDR white point. This defaults to 0.0, which disables tone mapping.
- `SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING`: the tone mapping operator used when compressing from a surface with high dynamic range to another with lower dynamic range. Currently this supports "chrome", which uses the same tone mapping that Chrome uses for HDR content, the form "*=N", where N is a floating point scale factor applied in linear space, and "none", which disables tone mapping. This defaults to "chrome".
- `SDL_PROP_SURFACE_HOTSPOT_X_NUMBER`: the hotspot pixel offset from the left edge of the image, if this surface is being used as a cursor.
- `SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER`: the hotspot pixel offset from the top edge of the image, if this surface is being used as a cursor.

Parameters

  surface | the SDL_Surface structure to query.

Returns
  a valid property ID on success or 0 on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

## SDL_LoadBMP()

SDL_Surface * SDL_LoadBMP | ( | const char * | file | ) |

extern

Load a BMP image from a file.

The new surface should be freed with SDL_DestroySurface(). Not doing so will result in a memory leak.

Parameters

  file | the BMP file to load.

Returns
  a pointer to a new SDL_Surface structure or NULL on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_DestroySurface
  SDL_LoadBMP_IO
  SDL_SaveBMP

## SDL_LoadBMP_IO()

SDL_Surface * SDL_LoadBMP_IO | ( | SDL_IOStream * | src,
|  | bool | closeio
| ) |  |

extern

Load a BMP image from a seekable SDL data stream.

The new surface should be freed with SDL_DestroySurface(). Not doing so will result in a memory leak.

Parameters

  src | the data stream for the surface.
  closeio | if true, calls SDL_CloseIO() on `src` before returning, even in the case of an error.

Returns
  a pointer to a new SDL_Surface structure or NULL on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_DestroySurface
  SDL_LoadBMP
  SDL_SaveBMP_IO

## SDL_LockSurface()

bool SDL_LockSurface | ( | SDL_Surface * | surface | ) |

extern

Set up a surface for directly accessing the pixels.

Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write to and read from `surface->pixels`, using the pixel format stored in `surface->format`. Once you are done accessing the surface, you should use SDL_UnlockSurface() to release it.

Not all surfaces require locking. If `SDL_MUSTLOCK(surface)` evaluates to 0, then you can read and write to the surface at any time, and the pixel format of the surface will not change.

Parameters

  surface | the SDL_Surface structure to be locked.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_MUSTLOCK
  SDL_UnlockSurface

## SDL_MapSurfaceRGB()

Uint32 SDL_MapSurfaceRGB | ( | SDL_Surface * | surface,
|  | Uint8 | r,
|  | Uint8 | g,
|  | Uint8 | b
| ) |  |

extern

Map an RGB triple to an opaque pixel value for a surface.

This function maps the RGB color value to the specified pixel format and returns the pixel value best approximating the given RGB color value for the given pixel format.

If the surface has a palette, the index of the closest matching color in the palette will be returned.

If the surface pixel format has an alpha component it will be returned as all 1 bits (fully opaque).

If the pixel format bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (e.g., with a 16-bpp format the return value can be assigned to a Uint16, and similarly a Uint8 for an 8-bpp format).

Parameters

  surface | the surface to use for the pixel format and palette.
  r | the red component of the pixel in the range 0-255.
  g | the green component of the pixel in the range 0-255.
  b | the blue component of the pixel in the range 0-255.

Returns
  a pixel value.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_MapSurfaceRGBA

## SDL_MapSurfaceRGBA()

Uint32 SDL_MapSurfaceRGBA | ( | SDL_Surface * | surface,
|  | Uint8 | r,
|  | Uint8 | g,
|  | Uint8 | b,
|  | Uint8 | a
| ) |  |

extern

Map an RGBA quadruple to a pixel value for a surface.

This function maps the RGBA color value to the specified pixel format and returns the pixel value best approximating the given RGBA color value for the given pixel format.

If the surface pixel format has no alpha component the alpha value will be ignored (as it will be in formats with a palette).

If the surface has a palette, the index of the closest matching color in the palette will be returned.

If the pixel format bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (e.g., with a 16-bpp format the return value can be assigned to a Uint16, and similarly a Uint8 for an 8-bpp format).

Parameters

  surface | the surface to use for the pixel format and palette.
  r | the red component of the pixel in the range 0-255.
  g | the green component of the pixel in the range 0-255.
  b | the blue component of the pixel in the range 0-255.
  a | the alpha component of the pixel in the range 0-255.

Returns
  a pixel value.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_MapSurfaceRGB

## SDL_PremultiplyAlpha()

bool SDL_PremultiplyAlpha | ( | int | width,
|  | int | height,
|  | SDL_PixelFormat | src_format,
|  | const void * | src,
|  | int | src_pitch,
|  | SDL_PixelFormat | dst_format,
|  | void * | dst,
|  | int | dst_pitch,
|  | bool | linear
| ) |  |

extern

Premultiply the alpha on a block of pixels.

This is safe to use with src == dst, but not for other overlapping areas.

Parameters

  width | the width of the block to convert, in pixels.
  height | the height of the block to convert, in pixels.
  src_format | an SDL_PixelFormat value of the `src` pixels format.
  src | a pointer to the source pixels.
  src_pitch | the pitch of the source pixels, in bytes.
  dst_format | an SDL_PixelFormat value of the `dst` pixels format.
  dst | a pointer to be filled in with premultiplied pixel data.
  dst_pitch | the pitch of the destination pixels, in bytes.
  linear | true to convert from sRGB to linear space for the alpha multiplication, false to do multiplication in sRGB space.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

## SDL_PremultiplySurfaceAlpha()

bool SDL_PremultiplySurfaceAlpha | ( | SDL_Surface * | surface,
|  | bool | linear
| ) |  |

extern

Premultiply the alpha in a surface.

This is safe to use with src == dst, but not for other overlapping areas.

Parameters

  surface | the surface to modify.
  linear | true to convert from sRGB to linear space for the alpha multiplication, false to do multiplication in sRGB space.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

## SDL_ReadSurfacePixel()

bool SDL_ReadSurfacePixel | ( | SDL_Surface * | surface,
|  | int | x,
|  | int | y,
|  | Uint8 * | r,
|  | Uint8 * | g,
|  | Uint8 * | b,
|  | Uint8 * | a
| ) |  |

extern

Retrieves a single pixel from a surface.

This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.

Like SDL_GetRGBA, this uses the entire 0..255 range when converting color components from pixel formats with less than 8 bits per RGB component.

Parameters

  surface | the surface to read.
  x | the horizontal coordinate, 0 <= x < width.
  y | the vertical coordinate, 0 <= y < height.
  r | a pointer filled in with the red channel, 0-255, or NULL to ignore this channel.
  g | a pointer filled in with the green channel, 0-255, or NULL to ignore this channel.
  b | a pointer filled in with the blue channel, 0-255, or NULL to ignore this channel.
  a | a pointer filled in with the alpha channel, 0-255, or NULL to ignore this channel.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

## SDL_ReadSurfacePixelFloat()

bool SDL_ReadSurfacePixelFloat | ( | SDL_Surface * | surface,
|  | int | x,
|  | int | y,
|  | float * | r,
|  | float * | g,
|  | float * | b,
|  | float * | a
| ) |  |

extern

Retrieves a single pixel from a surface.

This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.

Parameters

  surface | the surface to read.
  x | the horizontal coordinate, 0 <= x < width.
  y | the vertical coordinate, 0 <= y < height.
  r | a pointer filled in with the red channel, normally in the range 0-1, or NULL to ignore this channel.
  g | a pointer filled in with the green channel, normally in the range 0-1, or NULL to ignore this channel.
  b | a pointer filled in with the blue channel, normally in the range 0-1, or NULL to ignore this channel.
  a | a pointer filled in with the alpha channel, normally in the range 0-1, or NULL to ignore this channel.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

## SDL_RemoveSurfaceAlternateImages()

void SDL_RemoveSurfaceAlternateImages | ( | SDL_Surface * | surface | ) |

extern

Remove all alternate versions of a surface.

This function removes a reference from all the alternative versions, destroying them if this is the last reference to them.

Parameters

  surface | the SDL_Surface structure to update.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_AddSurfaceAlternateImage
  SDL_GetSurfaceImages
  SDL_SurfaceHasAlternateImages

## SDL_SaveBMP()

bool SDL_SaveBMP | ( | SDL_Surface * | surface,
|  | const char * | file
| ) |  |

extern

Save a surface to a file.

Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the BMP directly. Other RGB formats with 8-bit or higher get converted to a 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit surface before they are saved. YUV and paletted 1-bit and 4-bit formats are not supported.

Parameters

  surface | the SDL_Surface structure containing the image to be saved.
  file | a file to save to.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_LoadBMP
  SDL_SaveBMP_IO

## SDL_SaveBMP_IO()

bool SDL_SaveBMP_IO | ( | SDL_Surface * | surface,
|  | SDL_IOStream * | dst,
|  | bool | closeio
| ) |  |

extern

Save a surface to a seekable SDL data stream in BMP format.

Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the BMP directly. Other RGB formats with 8-bit or higher get converted to a 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit surface before they are saved. YUV and paletted 1-bit and 4-bit formats are not supported.

Parameters

  surface | the SDL_Surface structure containing the image to be saved.
  dst | a data stream to save to.
  closeio | if true, calls SDL_CloseIO() on `dst` before returning, even in the case of an error.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_LoadBMP_IO
  SDL_SaveBMP

## SDL_ScaleSurface()

SDL_Surface * SDL_ScaleSurface | ( | SDL_Surface * | surface,
|  | int | width,
|  | int | height,
|  | SDL_ScaleMode | scaleMode
| ) |  |

extern

Creates a new surface identical to the existing surface, scaled to the desired size.

The returned surface should be freed with SDL_DestroySurface().

Parameters

  surface | the surface to duplicate and scale.
  width | the width of the new surface.
  height | the height of the new surface.
  scaleMode | the SDL_ScaleMode to be used.

Returns
  a copy of the surface or NULL on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_DestroySurface

## SDL_SetSurfaceAlphaMod()

bool SDL_SetSurfaceAlphaMod | ( | SDL_Surface * | surface,
|  | Uint8 | alpha
| ) |  |

extern

Set an additional alpha value used in blit operations.

When this surface is blitted, during the blit operation the source alpha value is modulated by this alpha value according to the following formula:

`srcA = srcA * (alpha / 255)`

Parameters

  surface | the SDL_Surface structure to update.
  alpha | the alpha value multiplied into blit operations.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_GetSurfaceAlphaMod
  SDL_SetSurfaceColorMod

## SDL_SetSurfaceBlendMode()

bool SDL_SetSurfaceBlendMode | ( | SDL_Surface * | surface,
|  | SDL_BlendMode | blendMode
| ) |  |

extern

Set the blend mode used for blit operations.

To copy a surface to another surface (or texture) without blending with the existing data, the blendmode of the SOURCE surface should be set to `SDL_BLENDMODE_NONE`.

Parameters

  surface | the SDL_Surface structure to update.
  blendMode | the SDL_BlendMode to use for blit blending.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_GetSurfaceBlendMode

## SDL_SetSurfaceClipRect()

bool SDL_SetSurfaceClipRect | ( | SDL_Surface * | surface,
|  | const SDL_Rect * | rect
| ) |  |

extern

Set the clipping rectangle for a surface.

When `surface` is the destination of a blit, only the area within the clip rectangle is drawn into.

Note that blits are automatically clipped to the edges of the source and destination surfaces.

Parameters

  surface | the SDL_Surface structure to be clipped.
  rect | the SDL_Rect structure representing the clipping rectangle, or NULL to disable clipping.

Returns
  true if the rectangle intersects the surface, otherwise false and blits will be completely clipped.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_GetSurfaceClipRect

## SDL_SetSurfaceColorKey()

bool SDL_SetSurfaceColorKey | ( | SDL_Surface * | surface,
|  | bool | enabled,
|  | Uint32 | key
| ) |  |

extern

Set the color key (transparent pixel) in a surface.

The color key defines a pixel value that will be treated as transparent in a blit. For example, one can use this to specify that cyan pixels should be considered transparent, and therefore not rendered.

It is a pixel of the format used by the surface, as generated by SDL_MapRGB().

Parameters

  surface | the SDL_Surface structure to update.
  enabled | true to enable color key, false to disable color key.
  key | the transparent pixel.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_GetSurfaceColorKey
  SDL_SetSurfaceRLE
  SDL_SurfaceHasColorKey

## SDL_SetSurfaceColorMod()

bool SDL_SetSurfaceColorMod | ( | SDL_Surface * | surface,
|  | Uint8 | r,
|  | Uint8 | g,
|  | Uint8 | b
| ) |  |

extern

Set an additional color value multiplied into blit operations.

When this surface is blitted, during the blit operation each source color channel is modulated by the appropriate color value according to the following formula:

`srcC = srcC * (color / 255)`

Parameters

  surface | the SDL_Surface structure to update.
  r | the red color value multiplied into blit operations.
  g | the green color value multiplied into blit operations.
  b | the blue color value multiplied into blit operations.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_GetSurfaceColorMod
  SDL_SetSurfaceAlphaMod

## SDL_SetSurfaceColorspace()

bool SDL_SetSurfaceColorspace | ( | SDL_Surface * | surface,
|  | SDL_Colorspace | colorspace
| ) |  |

extern

Set the colorspace used by a surface.

Setting the colorspace doesn't change the pixels, only how they are interpreted in color operations.

Parameters

  surface | the SDL_Surface structure to update.
  colorspace | an SDL_Colorspace value describing the surface colorspace.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_GetSurfaceColorspace

## SDL_SetSurfacePalette()

bool SDL_SetSurfacePalette | ( | SDL_Surface * | surface,
|  | SDL_Palette * | palette
| ) |  |

extern

Set the palette used by a surface.

A single palette can be shared with many surfaces.

Parameters

  surface | the SDL_Surface structure to update.
  palette | the SDL_Palette structure to use.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_CreatePalette
  SDL_GetSurfacePalette

## SDL_SetSurfaceRLE()

bool SDL_SetSurfaceRLE | ( | SDL_Surface * | surface,
|  | bool | enabled
| ) |  |

extern

Set the RLE acceleration hint for a surface.

If RLE is enabled, color key and alpha blending blits are much faster, but the surface must be locked before directly accessing the pixels.

Parameters

  surface | the SDL_Surface structure to optimize.
  enabled | true to enable RLE acceleration, false to disable it.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_BlitSurface
  SDL_LockSurface
  SDL_UnlockSurface

## SDL_StretchSurface()

bool SDL_StretchSurface | ( | SDL_Surface * | src,
|  | const SDL_Rect * | srcrect,
|  | SDL_Surface * | dst,
|  | const SDL_Rect * | dstrect,
|  | SDL_ScaleMode | scaleMode
| ) |  |

extern

Perform a stretched pixel copy from one surface to another.

Parameters

  src | the SDL_Surface structure to be copied from.
  srcrect | the SDL_Rect structure representing the rectangle to be copied, may not be NULL.
  dst | the SDL_Surface structure that is the blit target.
  dstrect | the SDL_Rect structure representing the target rectangle in the destination surface, may not be NULL.
  scaleMode | the SDL_ScaleMode to be used.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

\threadsafety The same destination surface should not be used from two threads at once. It is safe to use the same source surface from multiple threads.

Since
  This function is available since SDL 3.4.0.

See also
  SDL_BlitSurfaceScaled

## SDL_SurfaceHasAlternateImages()

bool SDL_SurfaceHasAlternateImages | ( | SDL_Surface * | surface | ) |

extern

Return whether a surface has alternate versions available.

Parameters

  surface | the SDL_Surface structure to query.

Returns
  true if alternate versions are available or false otherwise.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_AddSurfaceAlternateImage
  SDL_RemoveSurfaceAlternateImages
  SDL_GetSurfaceImages

## SDL_SurfaceHasColorKey()

bool SDL_SurfaceHasColorKey | ( | SDL_Surface * | surface | ) |

extern

Returns whether the surface has a color key.

It is safe to pass a NULL `surface` here; it will return false.

Parameters

  surface | the SDL_Surface structure to query.

Returns
  true if the surface has a color key, false otherwise.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_SetSurfaceColorKey
  SDL_GetSurfaceColorKey

## SDL_SurfaceHasRLE()

bool SDL_SurfaceHasRLE | ( | SDL_Surface * | surface | ) |

extern

Returns whether the surface is RLE enabled.

It is safe to pass a NULL `surface` here; it will return false.

Parameters

  surface | the SDL_Surface structure to query.

Returns
  true if the surface is RLE enabled, false otherwise.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_SetSurfaceRLE

## SDL_UnlockSurface()

void SDL_UnlockSurface | ( | SDL_Surface * | surface | ) |

extern

Release a surface after directly accessing the pixels.

Parameters

  surface | the SDL_Surface structure to be unlocked.

Since
  This function is available since SDL 3.2.0.

See also
  SDL_LockSurface

## SDL_WriteSurfacePixel()

bool SDL_WriteSurfacePixel | ( | SDL_Surface * | surface,
|  | int | x,
|  | int | y,
|  | Uint8 | r,
|  | Uint8 | g,
|  | Uint8 | b,
|  | Uint8 | a
| ) |  |

extern

Writes a single pixel to a surface.

This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.

Like SDL_MapRGBA, this uses the entire 0..255 range when converting color components from pixel formats with less than 8 bits per RGB component.

Parameters

  surface | the surface to write.
  x | the horizontal coordinate, 0 <= x < width.
  y | the vertical coordinate, 0 <= y < height.
  r | the red channel value, 0-255.
  g | the green channel value, 0-255.
  b | the blue channel value, 0-255.
  a | the alpha channel value, 0-255.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.

## SDL_WriteSurfacePixelFloat()

bool SDL_WriteSurfacePixelFloat | ( | SDL_Surface * | surface,
|  | int | x,
|  | int | y,
|  | float | r,
|  | float | g,
|  | float | b,
|  | float | a
| ) |  |

extern

Writes a single pixel to a surface.

This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.

Parameters

  surface | the surface to write.
  x | the horizontal coordinate, 0 <= x < width.
  y | the vertical coordinate, 0 <= y < height.
  r | the red channel value, normally in the range 0-1.
  g | the green channel value, normally in the range 0-1.
  b | the blue channel value, normally in the range 0-1.
  a | the alpha channel value, normally in the range 0-1.

Returns
  true on success or false on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 3.2.0.