SDL 3.0
|
#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>
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" |
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 } |
#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.
Definition at line 76 of file SDL_surface.h.
#define SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT "SDL.surface.HDR_headroom" |
Definition at line 234 of file SDL_surface.h.
#define SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT "SDL.surface.SDR_white_point" |
Definition at line 233 of file SDL_surface.h.
#define SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING "SDL.surface.tonemap" |
Definition at line 235 of file SDL_surface.h.
#define SDL_SURFACE_LOCK_NEEDED 0x00000002u |
Surface needs to be locked to access pixels
Definition at line 67 of file SDL_surface.h.
#define SDL_SURFACE_LOCKED 0x00000004u |
Surface is currently locked
Definition at line 68 of file SDL_surface.h.
#define SDL_SURFACE_PREALLOCATED 0x00000001u |
Surface uses preallocated pixel memory
Definition at line 66 of file SDL_surface.h.
#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 Uint32 SDL_SurfaceFlags |
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.
Definition at line 64 of file SDL_surface.h.
enum SDL_FlipMode |
The flip mode.
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.
enum SDL_ScaleMode |
The scaling mode.
Enumerator | |
---|---|
SDL_SCALEMODE_NEAREST | nearest pixel sampling |
SDL_SCALEMODE_LINEAR | linear filtering |
Definition at line 83 of file SDL_surface.h.
|
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.
surface | the SDL_Surface structure to update. |
image | a pointer to an alternate SDL_Surface to associate with this surface. |
|
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:
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(). |
\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.
|
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.
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. |
\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.
|
extern |
Perform a scaled blit to a destination surface, which may be of a different format.
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. |
\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.
|
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
.
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. |
\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.
|
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
.
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. |
\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.
|
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.
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. |
\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.
|
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.
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. |
\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.
|
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.
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. |
|
extern |
Copy a block of pixels of one format to another format.
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. |
|
extern |
Copy a block of pixels of one format and colorspace to another format and colorspace.
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. |
|
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.
surface | the existing SDL_Surface structure to convert. |
format | the new pixel format. |
|
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.
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. |
|
extern |
Allocate a new surface with a specific pixel format.
The pixels of the new surface are initialized to zero.
width | the width of the surface. |
height | the height of the surface. |
format | the SDL_PixelFormat for the new surface's pixel format. |
|
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.
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. |
|
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.
surface | the SDL_Surface structure to update. |
|
extern |
Free a surface.
It is safe to pass NULL to this function.
surface | the SDL_Surface to free. |
|
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().
surface | the surface to duplicate. |
|
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
.
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. |
|
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
.
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. |
|
extern |
Flip a surface vertically or horizontally.
surface | the surface to flip. |
flip | the direction to flip. |
|
extern |
Get the additional alpha value used in blit operations.
surface | the SDL_Surface structure to query. |
alpha | a pointer filled in with the current alpha value. |
|
extern |
Get the blend mode used for blit operations.
surface | the SDL_Surface structure to query. |
blendMode | a pointer filled in with the current SDL_BlendMode. |
|
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.
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. |
|
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.
surface | the SDL_Surface structure to query. |
key | a pointer filled in with the transparent pixel. |
|
extern |
Get the additional color value multiplied into blit operations.
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. |
|
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.
surface | the SDL_Surface structure to query. |
|
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.
surface | the SDL_Surface structure to query. |
count | a pointer filled in with the number of surface pointers returned, may be NULL. |
|
extern |
Get the palette used by a surface.
surface | the SDL_Surface structure to query. |
|
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".surface | the SDL_Surface structure to query. |
|
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.
file | the BMP file to load. |
|
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.
src | the data stream for the surface. |
closeio | if true, calls SDL_CloseIO() on src before returning, even in the case of an error. |
|
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.
surface | the SDL_Surface structure to be locked. |
|
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).
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. |
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).
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. |
|
extern |
Premultiply the alpha on a block of pixels.
This is safe to use with src == dst, but not for other overlapping areas.
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. |
|
extern |
Premultiply the alpha in a surface.
This is safe to use with src == dst, but not for other overlapping areas.
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. |
|
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.
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. |
|
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.
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. |
|
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.
surface | the SDL_Surface structure to update. |
|
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.
surface | the SDL_Surface structure containing the image to be saved. |
file | a file to save to. |
|
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.
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. |
|
extern |
Creates a new surface identical to the existing surface, scaled to the desired size.
The returned surface should be freed with SDL_DestroySurface().
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. |
|
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)
surface | the SDL_Surface structure to update. |
alpha | the alpha value multiplied into blit operations. |
|
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
.
surface | the SDL_Surface structure to update. |
blendMode | the SDL_BlendMode to use for blit blending. |
|
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.
surface | the SDL_Surface structure to be clipped. |
rect | the SDL_Rect structure representing the clipping rectangle, or NULL to disable clipping. |
|
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().
surface | the SDL_Surface structure to update. |
enabled | true to enable color key, false to disable color key. |
key | the transparent pixel. |
|
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)
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. |
|
extern |
Set the colorspace used by a surface.
Setting the colorspace doesn't change the pixels, only how they are interpreted in color operations.
surface | the SDL_Surface structure to update. |
colorspace | an SDL_Colorspace value describing the surface colorspace. |
|
extern |
Set the palette used by a surface.
A single palette can be shared with many surfaces.
surface | the SDL_Surface structure to update. |
palette | the SDL_Palette structure to use. |
|
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.
surface | the SDL_Surface structure to optimize. |
enabled | true to enable RLE acceleration, false to disable it. |
|
extern |
Perform a stretched pixel copy from one surface to another.
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. |
\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.
|
extern |
Return whether a surface has alternate versions available.
surface | the SDL_Surface structure to query. |
|
extern |
Returns whether the surface has a color key.
It is safe to pass a NULL surface
here; it will return false.
surface | the SDL_Surface structure to query. |
|
extern |
Returns whether the surface is RLE enabled.
It is safe to pass a NULL surface
here; it will return false.
surface | the SDL_Surface structure to query. |
|
extern |
Release a surface after directly accessing the pixels.
surface | the SDL_Surface structure to be unlocked. |
|
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.
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. |
|
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.
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. |