SDL3pp
A slim C++ wrapper for SDL3
|
SDL surfaces are buffers of pixels in system RAM. More...
Classes | |
struct | SDL::SurfaceParam |
Safely wrap Surface for non owning parameters. More... | |
struct | SDL::SurfaceConstParam |
Safely wrap Surface for non owning const parameters. More... | |
class | SDL::Surface |
A collection of pixels used in software blitting. More... | |
Typedefs | |
using | SDL::SurfaceRaw = SDL_Surface * |
Alias to raw representation for Surface. | |
using | SDL::SurfaceFlags = Uint32 |
The flags on an Surface. More... | |
using | SDL::ScaleMode = SDL_ScaleMode |
The scaling mode. More... | |
using | SDL::FlipMode = SDL_FlipMode |
The flip mode. More... | |
Functions | |
constexpr bool | SDL::MUSTLOCK (SurfaceConstParam S) |
Evaluates to true if the surface needs to be locked before access. More... | |
Surface | SDL::CreateSurface (const PointRaw &size, PixelFormat format) |
Allocate a new surface with a specific pixel format. More... | |
Surface | SDL::CreateSurfaceFrom (const PointRaw &size, PixelFormat format, void *pixels, int pitch) |
Allocate a new surface with a specific pixel format and existing pixel data. More... | |
void | SDL::DestroySurface (SurfaceRaw surface) |
Free a surface. More... | |
PropertiesRef | SDL::GetSurfaceProperties (SurfaceConstParam surface) |
Get the properties associated with a surface. More... | |
void | SDL::SetSurfaceColorspace (SurfaceParam surface, Colorspace colorspace) |
Set the colorspace used by a surface. More... | |
Colorspace | SDL::GetSurfaceColorspace (SurfaceConstParam surface) |
Get the colorspace used by a surface. More... | |
Palette | SDL::CreateSurfacePalette (SurfaceParam surface) |
Create a palette and associate it with a surface. More... | |
void | SDL::SetSurfacePalette (SurfaceParam surface, PaletteParam palette) |
Set the palette used by a surface. More... | |
Palette | SDL::GetSurfacePalette (SurfaceConstParam surface) |
Get the palette used by a surface. More... | |
void | SDL::AddSurfaceAlternateImage (SurfaceParam surface, SurfaceParam image) |
Add an alternate version of a surface. More... | |
bool | SDL::SurfaceHasAlternateImages (SurfaceConstParam surface) |
Return whether a surface has alternate versions available. More... | |
OwnArray< SurfaceRaw > | SDL::GetSurfaceImages (SurfaceConstParam surface) |
Get an array including all versions of a surface. More... | |
void | SDL::RemoveSurfaceAlternateImages (SurfaceParam surface) |
Remove all alternate versions of a surface. More... | |
void | SDL::LockSurface (SurfaceParam surface) |
Set up a surface for directly accessing the pixels. More... | |
void | SDL::UnlockSurface (SurfaceParam surface) |
Release a surface after directly accessing the pixels. More... | |
Surface | SDL::LoadBMP (IOStreamParam src, bool closeio=false) |
Load a BMP image from a seekable SDL data stream. More... | |
Surface | SDL::LoadBMP (StringParam file) |
Load a BMP image from a file. More... | |
void | SDL::SaveBMP (SurfaceConstParam surface, IOStreamParam dst, bool closeio=false) |
Save a surface to a seekable SDL data stream in BMP format. More... | |
void | SDL::SaveBMP (SurfaceConstParam surface, StringParam file) |
Save a surface to a file. More... | |
void | SDL::SetSurfaceRLE (SurfaceParam surface, bool enabled) |
Set the RLE acceleration hint for a surface. More... | |
bool | SDL::SurfaceHasRLE (SurfaceConstParam surface) |
Returns whether the surface is RLE enabled. More... | |
void | SDL::SetSurfaceColorKey (SurfaceParam surface, std::optional< Uint32 > key) |
Set the color key (transparent pixel) in a surface. More... | |
bool | SDL::SurfaceHasColorKey (SurfaceConstParam surface) |
Returns whether the surface has a color key. More... | |
std::optional< Uint32 > | SDL::GetSurfaceColorKey (SurfaceConstParam surface) |
Get the color key (transparent pixel) for a surface. More... | |
void | SDL::SetSurfaceColorMod (SurfaceParam surface, Uint8 r, Uint8 g, Uint8 b) |
Set an additional color value multiplied into blit operations. More... | |
void | SDL::GetSurfaceColorMod (SurfaceConstParam surface, Uint8 *r, Uint8 *g, Uint8 *b) |
Get the additional color value multiplied into blit operations. More... | |
void | SDL::SetSurfaceAlphaMod (SurfaceParam surface, Uint8 alpha) |
Set an additional alpha value used in blit operations. More... | |
Uint8 | SDL::GetSurfaceAlphaMod (SurfaceConstParam surface) |
Get the additional alpha value used in blit operations. More... | |
void | SDL::SetSurfaceBlendMode (SurfaceParam surface, BlendMode blendMode) |
Set the blend mode used for blit operations. More... | |
BlendMode | SDL::GetSurfaceBlendMode (SurfaceConstParam surface) |
Get the blend mode used for blit operations. More... | |
bool | SDL::SetSurfaceClipRect (SurfaceParam surface, OptionalRef< const RectRaw > rect) |
Set the clipping rectangle for a surface. More... | |
Rect | SDL::GetSurfaceClipRect (SurfaceConstParam surface) |
Get the clipping rectangle for a surface. More... | |
void | SDL::FlipSurface (SurfaceParam surface, FlipMode flip) |
Flip a surface vertically or horizontally. More... | |
Surface | SDL::DuplicateSurface (SurfaceConstParam surface) |
Creates a new surface identical to the existing surface. More... | |
Surface | SDL::ScaleSurface (SurfaceConstParam surface, const PointRaw &size, ScaleMode scaleMode) |
Creates a new surface identical to the existing surface, scaled to the desired size. More... | |
Surface | SDL::ConvertSurface (SurfaceConstParam surface, PixelFormat format) |
Copy an existing surface to a new surface of the specified format. More... | |
Surface | SDL::ConvertSurfaceAndColorspace (SurfaceConstParam surface, PixelFormat format, PaletteParam palette, Colorspace colorspace, PropertiesParam props) |
Copy an existing surface to a new surface of the specified format and colorspace. More... | |
void | SDL::ConvertPixels (const PointRaw &size, PixelFormat src_format, const void *src, int src_pitch, PixelFormat dst_format, void *dst, int dst_pitch) |
Copy a block of pixels of one format to another format. More... | |
void | SDL::ConvertPixelsAndColorspace (const PointRaw &size, PixelFormat src_format, Colorspace src_colorspace, PropertiesParam src_properties, const void *src, int src_pitch, PixelFormat dst_format, Colorspace dst_colorspace, PropertiesParam dst_properties, void *dst, int dst_pitch) |
Copy a block of pixels of one format and colorspace to another format and colorspace. More... | |
void | SDL::PremultiplyAlpha (const PointRaw &size, PixelFormat src_format, const void *src, int src_pitch, PixelFormat dst_format, void *dst, int dst_pitch, bool linear) |
Premultiply the alpha on a block of pixels. More... | |
void | SDL::PremultiplySurfaceAlpha (SurfaceParam surface, bool linear) |
Premultiply the alpha in a surface. More... | |
void | SDL::ClearSurface (SurfaceParam surface, const FColorRaw &color) |
Clear a surface with a specific color, with floating point precision. More... | |
void | SDL::FillSurfaceRect (SurfaceParam dst, OptionalRef< const RectRaw > rect, Uint32 color) |
Perform a fast fill of a rectangle with a specific color. More... | |
void | SDL::FillSurfaceRects (SurfaceParam dst, SpanRef< const RectRaw > rects, Uint32 color) |
Perform a fast fill of a set of rectangles with a specific color. More... | |
void | SDL::BlitSurface (SurfaceParam src, OptionalRef< const RectRaw > srcrect, SurfaceParam dst, OptionalRef< const RectRaw > dstrect) |
Performs a fast blit from the source surface to the destination surface with clipping. More... | |
void | SDL::BlitSurfaceAt (SurfaceParam src, OptionalRef< const RectRaw > srcrect, SurfaceParam dst, const PointRaw &dstpos) |
Performs a fast blit from the source surface to the destination surface with clipping. More... | |
void | SDL::BlitSurfaceUnchecked (SurfaceParam src, const RectRaw &srcrect, SurfaceParam dst, const RectRaw &dstrect) |
Perform low-level surface blitting only. More... | |
void | SDL::BlitSurfaceScaled (SurfaceParam src, OptionalRef< const RectRaw > srcrect, SurfaceParam dst, OptionalRef< const RectRaw > dstrect, ScaleMode scaleMode) |
Perform a scaled blit to a destination surface, which may be of a different format. More... | |
void | SDL::BlitSurfaceUncheckedScaled (SurfaceParam src, const RectRaw &srcrect, SurfaceParam dst, const RectRaw &dstrect, ScaleMode scaleMode) |
Perform low-level surface scaled blitting only. More... | |
void | SDL::StretchSurface (SurfaceParam src, OptionalRef< RectRaw > srcrect, SurfaceParam dst, OptionalRef< RectRaw > dstrect, ScaleMode scaleMode) |
Perform a stretched pixel copy from one surface to another. More... | |
void | SDL::BlitSurfaceTiled (SurfaceParam src, OptionalRef< const RectRaw > srcrect, SurfaceParam dst, OptionalRef< const RectRaw > dstrect) |
Perform a tiled blit to a destination surface, which may be of a different format. More... | |
void | SDL::BlitSurfaceTiledWithScale (SurfaceParam src, OptionalRef< const RectRaw > srcrect, float scale, SDL_ScaleMode scaleMode, SurfaceParam dst, OptionalRef< const RectRaw > dstrect) |
Perform a scaled and tiled blit to a destination surface, which may be of a different format. More... | |
void | SDL::BlitSurface9Grid (SurfaceParam src, OptionalRef< const RectRaw > srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, SDL_ScaleMode scaleMode, SurfaceParam dst, OptionalRef< const RectRaw > dstrect) |
Perform a scaled blit using the 9-grid algorithm to a destination surface, which may be of a different format. More... | |
void | SDL::BlitSurface9Grid (SurfaceParam src, OptionalRef< const RectRaw > srcrect, int left_width, int right_width, int top_height, int bottom_height, SurfaceParam dst, OptionalRef< const RectRaw > dstrect) |
Perform a scaled blit using the 9-grid algorithm to a destination surface, which may be of a different format. More... | |
Uint32 | SDL::MapSurfaceRGB (SurfaceConstParam surface, Uint8 r, Uint8 g, Uint8 b) |
Map an RGB triple to an opaque pixel value for a surface. More... | |
Uint32 | SDL::MapSurfaceRGBA (SurfaceConstParam surface, ColorRaw c) |
Map an RGBA quadruple to a pixel value for a surface. More... | |
void | SDL::ReadSurfacePixel (SurfaceConstParam surface, const PointRaw &p, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) |
Retrieves a single pixel from a surface. More... | |
void | SDL::ReadSurfacePixelFloat (SurfaceConstParam surface, const PointRaw &p, float *r, float *g, float *b, float *a) |
Retrieves a single pixel from a surface. More... | |
void | SDL::WriteSurfacePixel (SurfaceParam surface, const PointRaw &p, ColorRaw c) |
Writes a single pixel to a surface. More... | |
void | SDL::WriteSurfacePixelFloat (SurfaceParam surface, const PointRaw &p, const FColorRaw &c) |
Writes a single pixel to a surface. More... | |
void | SDL::Surface::Destroy () |
Free a surface. More... | |
PropertiesRef | SDL::Surface::GetProperties () const |
Get the properties associated with a surface. More... | |
void | SDL::Surface::SetColorspace (Colorspace colorspace) |
Set the colorspace used by a surface. More... | |
Colorspace | SDL::Surface::GetColorspace () const |
Get the colorspace used by a surface. More... | |
Palette | SDL::Surface::CreatePalette () |
Create a palette and associate it with a surface. More... | |
void | SDL::Surface::SetPalette (PaletteParam palette) |
Set the palette used by a surface. More... | |
Palette | SDL::Surface::GetPalette () const |
Get the palette used by a surface. More... | |
void | SDL::Surface::AddAlternateImage (SurfaceParam image) |
Add an alternate version of a surface. More... | |
bool | SDL::Surface::HasAlternateImages () const |
Return whether a surface has alternate versions available. More... | |
OwnArray< SurfaceRaw > | SDL::Surface::GetImages () const |
Get an array including all versions of a surface. More... | |
void | SDL::Surface::RemoveAlternateImages () |
Remove all alternate versions of a surface. More... | |
void | SDL::Surface::Lock () |
Set up a surface for directly accessing the pixels. More... | |
void | SDL::Surface::Unlock () |
Release a surface after directly accessing the pixels. More... | |
static Surface | SDL::Surface::LoadBMP (IOStreamParam src, bool closeio=false) |
Load a BMP image from a seekable SDL data stream. More... | |
static Surface | SDL::Surface::LoadBMP (StringParam file) |
Load a BMP image from a file. More... | |
void | SDL::Surface::SaveBMP (IOStreamParam dst, bool closeio=false) const |
Save a surface to a seekable SDL data stream in BMP format. More... | |
void | SDL::Surface::SaveBMP (StringParam file) const |
Save a surface to a file. More... | |
void | SDL::Surface::SetRLE (bool enabled) |
Set the RLE acceleration hint for a surface. More... | |
bool | SDL::Surface::HasRLE () const |
Returns whether the surface is RLE enabled. More... | |
void | SDL::Surface::SetColorKey (std::optional< Uint32 > key) |
Set the color key (transparent pixel) in a surface. More... | |
bool | SDL::Surface::HasColorKey () const |
Returns whether the surface has a color key. More... | |
std::optional< Uint32 > | SDL::Surface::GetColorKey () const |
Get the color key (transparent pixel) for a surface. More... | |
void | SDL::Surface::SetColorMod (Uint8 r, Uint8 g, Uint8 b) |
Set an additional color value multiplied into blit operations. More... | |
void | SDL::Surface::GetColorMod (Uint8 *r, Uint8 *g, Uint8 *b) const |
Get the additional color value multiplied into blit operations. More... | |
void | SDL::Surface::SetAlphaMod (Uint8 alpha) |
Set an additional alpha value used in blit operations. More... | |
Uint8 | SDL::Surface::GetAlphaMod () const |
Get the additional alpha value used in blit operations. More... | |
void | SDL::Surface::SetBlendMode (BlendMode blendMode) |
Set the blend mode used for blit operations. More... | |
BlendMode | SDL::Surface::GetBlendMode () const |
Get the blend mode used for blit operations. More... | |
bool | SDL::Surface::SetClipRect (OptionalRef< const RectRaw > rect) |
Set the clipping rectangle for a surface. More... | |
Rect | SDL::Surface::GetClipRect () const |
Get the clipping rectangle for a surface. More... | |
void | SDL::Surface::Flip (FlipMode flip) |
Flip a surface vertically or horizontally. More... | |
Surface | SDL::Surface::Duplicate () const |
Creates a new surface identical to the existing surface. More... | |
Surface | SDL::Surface::Scale (const PointRaw &size, ScaleMode scaleMode) const |
Creates a new surface identical to the existing surface, scaled to the desired size. More... | |
Surface | SDL::Surface::Convert (PixelFormat format) const |
Copy an existing surface to a new surface of the specified format. More... | |
Surface | SDL::Surface::Convert (PixelFormat format, PaletteParam palette, Colorspace colorspace, PropertiesParam props) const |
Copy an existing surface to a new surface of the specified format and colorspace. More... | |
void | SDL::Surface::PremultiplyAlpha (bool linear) |
Premultiply the alpha in a surface. More... | |
void | SDL::Surface::Clear (const FColorRaw &color) |
Clear a surface with a specific color, with floating point precision. More... | |
void | SDL::Surface::FillRect (OptionalRef< const RectRaw > rect, Uint32 color) |
Perform a fast fill of a rectangle with a specific color. More... | |
void | SDL::Surface::FillRects (SpanRef< const RectRaw > rects, Uint32 color) |
Perform a fast fill of a set of rectangles with a specific color. More... | |
void | SDL::Surface::Blit (SurfaceParam src, OptionalRef< const RectRaw > srcrect, OptionalRef< const RectRaw > dstrect) |
Performs a fast blit from the source surface to the destination surface with clipping. More... | |
void | SDL::Surface::BlitUnchecked (SurfaceParam src, const RectRaw &srcrect, const RectRaw &dstrect) |
Perform low-level surface blitting only. More... | |
void | SDL::Surface::BlitScaled (SurfaceParam src, OptionalRef< const RectRaw > srcrect, OptionalRef< const RectRaw > dstrect, ScaleMode scaleMode) |
Perform a scaled blit to a destination surface, which may be of a different format. More... | |
void | SDL::Surface::BlitUncheckedScaled (SurfaceParam src, const RectRaw &srcrect, const RectRaw &dstrect, ScaleMode scaleMode) |
Perform low-level surface scaled blitting only. More... | |
void | SDL::Surface::Stretch (SurfaceParam src, OptionalRef< RectRaw > srcrect, OptionalRef< RectRaw > dstrect, ScaleMode scaleMode) |
Perform a stretched pixel copy from one surface to another. More... | |
void | SDL::Surface::BlitTiled (SurfaceParam src, OptionalRef< const RectRaw > srcrect, OptionalRef< const RectRaw > dstrect) |
Perform a tiled blit to a destination surface, which may be of a different format. More... | |
void | SDL::Surface::BlitTiledWithScale (SurfaceParam src, OptionalRef< const RectRaw > srcrect, float scale, SDL_ScaleMode scaleMode, OptionalRef< const RectRaw > dstrect) |
Perform a scaled and tiled blit to a destination surface, which may be of a different format. More... | |
void | SDL::Surface::Blit9Grid (SurfaceParam src, OptionalRef< const RectRaw > srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, SDL_ScaleMode scaleMode, OptionalRef< const RectRaw > dstrect) |
Perform a scaled blit using the 9-grid algorithm to a destination surface, which may be of a different format. More... | |
Uint32 | SDL::Surface::MapRGB (Uint8 r, Uint8 g, Uint8 b) const |
Map an RGB triple to an opaque pixel value for a surface. More... | |
Uint32 | SDL::Surface::MapRGBA (ColorRaw c) const |
Map an RGBA quadruple to a pixel value for a surface. More... | |
void | SDL::Surface::ReadPixel (const PointRaw &p, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) const |
Retrieves a single pixel from a surface. More... | |
void | SDL::Surface::ReadPixelFloat (const PointRaw &p, float *r, float *g, float *b, float *a) const |
Retrieves a single pixel from a surface. More... | |
void | SDL::Surface::WritePixel (const PointRaw &p, ColorRaw c) |
Writes a single pixel to a surface. More... | |
void | SDL::Surface::WritePixelFloat (const PointRaw &p, const FColorRaw &c) |
Writes a single pixel to a surface. More... | |
Variables | |
constexpr SurfaceFlags | SDL::SURFACE_PREALLOCATED |
Surface uses preallocated pixel memory. More... | |
constexpr SurfaceFlags | SDL::SURFACE_LOCK_NEEDED |
Surface needs to be locked to access pixels. More... | |
constexpr SurfaceFlags | SDL::SURFACE_LOCKED |
Surface is currently locked. More... | |
constexpr SurfaceFlags | SDL::SURFACE_SIMD_ALIGNED = SDL_SURFACE_SIMD_ALIGNED |
Surface uses pixel memory allocated with aligned_alloc() | |
constexpr ScaleMode | SDL::SCALEMODE_INVALID = SDL_SCALEMODE_INVALID |
INVALID. | |
constexpr ScaleMode | SDL::SCALEMODE_NEAREST |
nearest pixel sampling More... | |
constexpr ScaleMode | SDL::SCALEMODE_LINEAR |
linear filtering More... | |
constexpr FlipMode | SDL::FLIP_NONE = SDL_FLIP_NONE |
Do not flip. | |
constexpr FlipMode | SDL::FLIP_HORIZONTAL = SDL_FLIP_HORIZONTAL |
flip horizontally | |
constexpr FlipMode | SDL::FLIP_VERTICAL = SDL_FLIP_VERTICAL |
flip vertically | |
These are useful for passing around and manipulating images that are not stored in GPU memory.
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, Surface.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
using SDL::FlipMode = typedef SDL_FlipMode |
using SDL::ScaleMode = typedef SDL_ScaleMode |
using SDL::SurfaceFlags = typedef Uint32 |
These are generally considered read-only.
|
inline |
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 Surface.Destroy() on the image after this call.
image | an alternate Surface to associate with this surface. |
Error | on failure. |
|
inline |
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 Surface.Destroy() on the image after this call.
surface | the Surface structure to update. |
image | a pointer to an alternate Surface to associate with this surface. |
Error | on failure. |
|
inline |
If either srcrect
or dstrect
are nullptr, the entire surface (src
or dst
) is copied while ensuring clipping to dst->clip_rect
.
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 SurfaceRaw structure to be copied from. |
srcrect | the Rect structure representing the rectangle to be copied, or nullptr to copy the entire surface. |
dstrect | the Rect structure representing the x and y position in the destination surface, or nullptr 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 Surface.BlitScaled(). |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
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 Rect structure representing the rectangle to be used for the 9-grid, or nullptr 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. |
dstrect | the Rect structure representing the target rectangle in the destination surface, or nullptr to fill the entire surface. |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
src | the Surface structure to be copied from. |
srcrect | the Rect structure representing the rectangle to be copied, or nullptr to copy the entire surface. |
dstrect | the Rect structure representing the target rectangle in the destination surface, or nullptr to fill the entire destination surface. |
scaleMode | the ScaleMode to be used. |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
If either srcrect
or dstrect
are nullptr, the entire surface (src
or dst
) is copied while ensuring clipping to dst->clip_rect
.
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 Surface structure to be copied from. |
srcrect | the Rect structure representing the rectangle to be copied, or nullptr to copy the entire surface. |
dst | the Surface structure that is the blit target. |
dstrect | the Rect structure representing the x and y position in the destination surface, or nullptr 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 Surface.BlitScaled(). |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
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 Surface structure to be copied from. |
srcrect | the Rect structure representing the rectangle to be used for the 9-grid, or nullptr 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 Surface structure that is the blit target. |
dstrect | the Rect structure representing the target rectangle in the destination surface, or nullptr to fill the entire surface. |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
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 Surface structure to be copied from. |
srcrect | the Rect structure representing the rectangle to be used for the 9-grid, or nullptr 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 . |
dst | the Surface structure that is the blit target. |
dstrect | the Rect structure representing the target rectangle in the destination surface, or nullptr to fill the entire surface. |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
If either srcrect
or dstrect
are nullptr, the entire surface (src
or dst
) is copied while ensuring clipping to dst->clip_rect
.
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 Surface structure to be copied from. |
srcrect | the Rect structure representing the rectangle to be copied, or nullptr to copy the entire surface. |
dst | the Surface structure that is the blit target. |
dstpos | the Point structure representing the x and y position in the destination surface. |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
src | the Surface structure to be copied from. |
srcrect | the Rect structure representing the rectangle to be copied, or nullptr to copy the entire surface. |
dst | the Surface structure that is the blit target. |
dstrect | the Rect structure representing the target rectangle in the destination surface, or nullptr to fill the entire destination surface. |
scaleMode | the ScaleMode to be used. |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
The pixels in srcrect
will be repeated as many times as needed to completely fill dstrect
.
src | the Surface structure to be copied from. |
srcrect | the Rect structure representing the rectangle to be copied, or nullptr to copy the entire surface. |
dst | the Surface structure that is the blit target. |
dstrect | the Rect structure representing the target rectangle in the destination surface, or nullptr to fill the entire surface. |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
The pixels in srcrect
will be scaled and repeated as many times as needed to completely fill dstrect
.
src | the Surface structure to be copied from. |
srcrect | the Rect structure representing the rectangle to be copied, or nullptr 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 Surface structure that is the blit target. |
dstrect | the Rect structure representing the target rectangle in the destination surface, or nullptr to fill the entire surface. |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
This is a semi-private blit function and it performs low-level surface blitting, assuming the input rectangles have already been clipped.
src | the Surface structure to be copied from. |
srcrect | the Rect structure representing the rectangle to be copied, may not be nullptr. |
dst | the Surface structure that is the blit target. |
dstrect | the Rect structure representing the target rectangle in the destination surface, may not be nullptr. |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
This is a semi-private function and it performs low-level surface blitting, assuming the input rectangles have already been clipped.
src | the Surface structure to be copied from. |
srcrect | the Rect structure representing the rectangle to be copied, may not be nullptr. |
dst | the Surface structure that is the blit target. |
dstrect | the Rect structure representing the target rectangle in the destination surface, may not be nullptr. |
scaleMode | the ScaleMode to be used. |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
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 Rect structure representing the rectangle to be copied, or nullptr to copy the entire surface. |
dstrect | the Rect structure representing the target rectangle in the destination surface, or nullptr to fill the entire surface. |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
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 Rect structure representing the rectangle to be copied, or nullptr 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. |
dstrect | the Rect structure representing the target rectangle in the destination surface, or nullptr to fill the entire surface. |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
This is a semi-private blit function and it performs low-level surface blitting, assuming the input rectangles have already been clipped.
src | the Surface structure to be copied from. |
srcrect | the Rect structure representing the rectangle to be copied, may not be nullptr. |
dstrect | the Rect structure representing the target rectangle in the destination surface, may not be nullptr. |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
This is a semi-private function and it performs low-level surface blitting, assuming the input rectangles have already been clipped.
src | the Surface structure to be copied from. |
srcrect | the Rect structure representing the rectangle to be copied, may not be nullptr. |
dstrect | the Rect structure representing the target rectangle in the destination surface, may not be nullptr. |
scaleMode | the ScaleMode to be used. |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
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 surface.
color | the color components of the pixel, normally in the range 0-1. |
Error | on failure. |
|
inline |
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 Surface to clear. |
color | the color components of the pixel, normally in the range 0-1. |
Error | on failure. |
|
inline |
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 Surface.Convert() instead.
If the original surface has alternate images, the new surface will have a reference to them as well.
format | the new pixel format. |
|
inline |
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.
format | the new pixel format. |
palette | an optional palette to use for indexed formats, may be nullptr. |
colorspace | the new colorspace. |
props | an Properties with additional color properties, or 0. |
|
inline |
size | the width and height of the surface. |
src_format | an 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 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. |
Error | on failure. |
|
inline |
size | the width and height of the block to copy, in pixels. |
src_format | an PixelFormat value of the src pixels format. |
src_colorspace | an Colorspace value describing the colorspace of the src pixels. |
src_properties | an Properties 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 PixelFormat value of the dst pixels format. |
dst_colorspace | an Colorspace value describing the colorspace of the dst pixels. |
dst_properties | an Properties 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. |
Error | on failure. |
|
inline |
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 Surface.Convert() instead.
If the original surface has alternate images, the new surface will have a reference to them as well.
surface | the existing Surface structure to convert. |
format | the new pixel format. |
|
inline |
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 Surface structure to convert. |
format | the new pixel format. |
palette | an optional palette to use for indexed formats, may be nullptr. |
colorspace | the new colorspace. |
props | an Properties with additional color properties, or 0. |
|
inline |
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 PIXELFORMAT_INDEX1LSB or 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.
Error | on failure. |
|
inline |
The pixels of the new surface are initialized to zero.
size | the width and height of the surface. |
format | the PixelFormat for the new surface's pixel format. |
|
inline |
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 PIXELFORMAT_RGBA8888
.
You may pass nullptr for pixels and 0 for pitch to create a surface that you will fill in with valid values later.
size | the width and height of the surface. |
format | the 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. |
|
inline |
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 PIXELFORMAT_INDEX1LSB or 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 Surface structure to update. |
Error | on failure. |
|
inline |
It is safe to pass nullptr to this function.
|
inline |
It is safe to pass nullptr to this function.
surface | the Surface to free. |
|
inline |
If the original surface has alternate images, the new surface will have a reference to them as well.
|
inline |
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 Surface.Destroy().
surface | the surface to duplicate. |
|
inline |
color
should be a pixel of the format used by the surface, and can be generated by MapRGB() or 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 Surface.SetClipRect()), then this function will fill based on the intersection of the clip rectangle and rect
.
rect | the Rect structure representing the rectangle to fill, or nullptr to fill the entire surface. |
color | the color to fill with. |
Error | on failure. |
color
should be a pixel of the format used by the surface, and can be generated by MapRGB() or 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 Surface.SetClipRect()), then this function will fill based on the intersection of the clip rectangle and rect
.
rects | an array of SDL_Rects representing the rectangles to fill. |
color | the color to fill with. |
Error | on failure. |
|
inline |
color
should be a pixel of the format used by the surface, and can be generated by MapRGB() or 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 Surface.SetClipRect()), then this function will fill based on the intersection of the clip rectangle and rect
.
dst | the Surface structure that is the drawing target. |
rect | the Rect structure representing the rectangle to fill, or nullptr to fill the entire surface. |
color | the color to fill with. |
Error | on failure. |
|
inline |
color
should be a pixel of the format used by the surface, and can be generated by MapRGB() or 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 Surface.SetClipRect()), then this function will fill based on the intersection of the clip rectangle and rect
.
dst | the Surface structure that is the drawing target. |
rects | an array of SDL_Rects representing the rectangles to fill. |
color | the color to fill with. |
Error | on failure. |
|
inline |
|
inline |
|
inline |
|
inline |
Error | on failure. |
|
inline |
When surface
is the destination of a blit, only the area within the clip rectangle is drawn into.
Error | on failure. |
|
inline |
The color key is a pixel of the format used by the surface, as generated by MapRGB().
If the surface doesn't have color key enabled this function returns false.
Error | on failure. |
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. |
Error | on failure. |
|
inline |
The colorspace defaults to COLORSPACE_SRGB_LINEAR for floating point formats, COLORSPACE_HDR10 for 10-bit formats, COLORSPACE_SRGB for other RGB surfaces and COLORSPACE_BT709_FULL for YUV textures.
|
inline |
This returns all versions of a surface, with the surface being queried as the first element in the returned array.
|
inline |
|
inline |
The following properties are understood by 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.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.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".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.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.Error | on failure. |
|
inline |
|
inline |
surface | the Surface structure to query. |
Error | on failure. |
|
inline |
When surface
is the destination of a blit, only the area within the clip rectangle is drawn into.
surface | the Surface structure representing the surface to be clipped. |
Error | on failure. |
|
inline |
The color key is a pixel of the format used by the surface, as generated by MapRGB().
If the surface doesn't have color key enabled this function returns false.
surface | the Surface structure to query. |
Error | on failure. |
|
inline |
surface | the 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. |
Error | on failure. |
|
inline |
The colorspace defaults to COLORSPACE_SRGB_LINEAR for floating point formats, COLORSPACE_HDR10 for 10-bit formats, COLORSPACE_SRGB for other RGB surfaces and COLORSPACE_BT709_FULL for YUV textures.
surface | the Surface structure to query. |
|
inline |
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 Surface structure to query. |
|
inline |
surface | the Surface structure to query. |
|
inline |
The following properties are understood by 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.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.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".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.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.surface | the Surface structure to query. |
Error | on failure. |
|
inline |
|
inline |
|
inline |
It is safe to pass a nullptr surface
here; it will return false.
|
inlinestatic |
The new surface should be freed with Surface.Destroy(). Not doing so will result in a memory leak.
src | the data stream for the surface. |
closeio | if true, calls IOStream.Close() on src before returning, even in the case of an error. |
|
inline |
The new surface should be freed with Surface.Destroy(). Not doing so will result in a memory leak.
src | the data stream for the surface. |
closeio | if true, calls IOStream.Close() on src before returning, even in the case of an error. |
|
inlinestatic |
The new surface should be freed with Surface.Destroy(). Not doing so will result in a memory leak.
file | the BMP file to load. |
|
inline |
The new surface should be freed with Surface.Destroy(). Not doing so will result in a memory leak.
file | the BMP file to load. |
|
inline |
Between calls to Surface.Lock() / Surface.Unlock(), 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 Surface.Unlock() to release it.
Not all surfaces require locking. If Surface.MustLock()
evaluates to false, then you can read and write to the surface at any time, and the pixel format of the surface will not change.
Error | on failure. |
|
inline |
Between calls to Surface.Lock() / Surface.Unlock(), 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 Surface.Unlock() to release it.
Not all surfaces require locking. If Surface.MustLock()
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 Surface structure to be locked. |
Error | on failure. |
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).
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. |
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).
c | the color components of the pixel in the range 0-255. |
|
inline |
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. |
|
inline |
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. |
c | the color components of the pixel in the range 0-255. |
|
constexpr |
|
inline |
This is safe to use with src == dst, but not for other overlapping areas.
linear | true to convert from sRGB to linear space for the alpha multiplication, false to do multiplication in sRGB space. |
Error | on failure. |
|
inline |
This is safe to use with src == dst, but not for other overlapping areas.
size | the width and height of the surface. |
src_format | an 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 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. |
Error | on failure. |
|
inline |
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. |
Error | on failure. |
|
inline |
This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.
Like GetRGBA, this uses the entire 0..255 range when converting color components from pixel formats with less than 8 bits per RGB component.
p | the coordinates, 0 <= x < width and 0 <= y < height. |
r | a pointer filled in with the red channel, 0-255, or nullptr to ignore this channel. |
g | a pointer filled in with the green channel, 0-255, or nullptr to ignore this channel. |
b | a pointer filled in with the blue channel, 0-255, or nullptr to ignore this channel. |
a | a pointer filled in with the alpha channel, 0-255, or nullptr to ignore this channel. |
Error | on failure. |
|
inline |
This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.
p | the coordinates, 0 <= x < width and 0 <= y < height. |
r | a pointer filled in with the red channel, normally in the range 0-1, or nullptr to ignore this channel. |
g | a pointer filled in with the green channel, normally in the range 0-1, or nullptr to ignore this channel. |
b | a pointer filled in with the blue channel, normally in the range 0-1, or nullptr to ignore this channel. |
a | a pointer filled in with the alpha channel, normally in the range 0-1, or nullptr to ignore this channel. |
Error | on failure. |
|
inline |
This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.
Like 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. |
p | the coordinates, 0 <= x < width and 0 <= y < height. |
r | a pointer filled in with the red channel, 0-255, or nullptr to ignore this channel. |
g | a pointer filled in with the green channel, 0-255, or nullptr to ignore this channel. |
b | a pointer filled in with the blue channel, 0-255, or nullptr to ignore this channel. |
a | a pointer filled in with the alpha channel, 0-255, or nullptr to ignore this channel. |
Error | on failure. |
|
inline |
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. |
p | the coordinates, 0 <= x < width and 0 <= y < height. |
r | a pointer filled in with the red channel, normally in the range 0-1, or nullptr to ignore this channel. |
g | a pointer filled in with the green channel, normally in the range 0-1, or nullptr to ignore this channel. |
b | a pointer filled in with the blue channel, normally in the range 0-1, or nullptr to ignore this channel. |
a | a pointer filled in with the alpha channel, normally in the range 0-1, or nullptr to ignore this channel. |
Error | on failure. |
|
inline |
This function removes a reference from all the alternative versions, destroying them if this is the last reference to them.
|
inline |
|
inline |
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.
dst | a data stream to save to. |
closeio | if true, calls IOStream.Close() on dst before returning, even in the case of an error. |
Error | on failure. |
|
inline |
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.
file | a file to save to. |
Error | on failure. |
|
inline |
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 Surface structure containing the image to be saved. |
dst | a data stream to save to. |
closeio | if true, calls IOStream.Close() on dst before returning, even in the case of an error. |
Error | on failure. |
|
inline |
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 Surface structure containing the image to be saved. |
file | a file to save to. |
Error | on failure. |
size | the width and height of the new surface. |
scaleMode | the ScaleMode to be used. |
|
inline |
The returned surface should be freed with Surface.Destroy().
surface | the surface to duplicate and scale. |
size | the width and height of the surface. |
scaleMode | the ScaleMode to be used. |
|
inline |
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)
alpha | the alpha value multiplied into blit operations. |
Error | on failure. |
|
inline |
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 BLENDMODE_NONE
.
blendMode | the BlendMode to use for blit blending. |
Error | on failure. |
|
inline |
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.
rect | the Rect structure representing the clipping rectangle, or nullptr to disable clipping. |
|
inline |
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 MapRGB().
key | the transparent pixel or std::nullopt to disable it. |
Error | on failure. |
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)
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. |
Error | on failure. |
|
inline |
Setting the colorspace doesn't change the pixels, only how they are interpreted in color operations.
colorspace | a Colorspace value describing the surface colorspace. |
Error | on failure. |
|
inline |
A single palette can be shared with many surfaces.
palette | the Palette structure to use. |
Error | on failure. |
|
inline |
If RLE is enabled, color key and alpha blending blits are much faster, but the surface must be locked before directly accessing the pixels.
enabled | true to enable RLE acceleration, false to disable it. |
Error | on failure. |
|
inline |
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 Surface structure to update. |
alpha | the alpha value multiplied into blit operations. |
Error | on failure. |
|
inline |
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 BLENDMODE_NONE
.
surface | the Surface structure to update. |
blendMode | the BlendMode to use for blit blending. |
Error | on failure. |
|
inline |
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 Surface structure to be clipped. |
rect | the Rect structure representing the clipping rectangle, or nullptr to disable clipping. |
|
inline |
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 MapRGB().
surface | the Surface structure to update. |
key | the transparent pixel or std::nullopt to disable it. |
Error | on failure. |
|
inline |
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 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. |
Error | on failure. |
|
inline |
Setting the colorspace doesn't change the pixels, only how they are interpreted in color operations.
surface | the Surface structure to update. |
colorspace | an Colorspace value describing the surface colorspace. |
Error | on failure. |
|
inline |
A single palette can be shared with many surfaces.
Error | on failure. |
|
inline |
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 Surface structure to optimize. |
enabled | true to enable RLE acceleration, false to disable it. |
Error | on failure. |
|
inline |
src | the Surface structure to be copied from. |
srcrect | the Rect structure representing the rectangle to be copied, or nullptr to copy the entire surface. |
dstrect | the Rect structure representing the target rectangle in the destination surface, or nullptr to fill the entire destination surface. |
scaleMode | the ScaleMode to be used. |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
src | the Surface structure to be copied from. |
srcrect | the Rect structure representing the rectangle to be copied, or nullptr to copy the entire surface. |
dst | the Surface structure that is the blit target. |
dstrect | the Rect structure representing the target rectangle in the destination surface, or nullptr to fill the entire destination surface. |
scaleMode | the ScaleMode to be used. |
Error | on failure. |
src
and dst
surfaces at any given time.
|
inline |
|
inline |
|
inline |
It is safe to pass a nullptr surface
here; it will return false.
surface | the Surface structure to query. |
|
inline |
|
inline |
surface | the Surface structure to be unlocked. |
This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.
Like MapRGBA, this uses the entire 0..255 range when converting color components from pixel formats with less than 8 bits per RGB component.
p | the coordinates, 0 <= x < width and 0 <= y < height. |
c | the color values, 0-255. |
Error | on failure. |
This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.
p | the coordinates, 0 <= x < width and 0 <= y < height. |
c | the color values, normally in the range 0-1. |
Error | on failure. |
|
inline |
This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.
Like 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. |
p | the coordinates, 0 <= x < width, 0 <= y < height. |
c | the color channels value, 0-255. |
Error | on failure. |
|
inline |
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. |
p | the coordinates, 0 <= x < width, 0 <= y < height. |
c | the color channels values, normally in the range 0-1. |
Error | on failure. |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |