1#ifndef SDL3PP_SURFACE_H_
2#define SDL3PP_SURFACE_H_
4#include <SDL3/SDL_surface.h>
5#include "SDL3pp_blendmode.h"
6#include "SDL3pp_error.h"
7#include "SDL3pp_iostream.h"
8#include "SDL3pp_optionalRef.h"
9#include "SDL3pp_pixels.h"
10#include "SDL3pp_properties.h"
11#include "SDL3pp_rect.h"
12#include "SDL3pp_spanRef.h"
13#include "SDL3pp_strings.h"
14#include "SDL3pp_version.h"
62 constexpr explicit operator bool()
const {
return !!
value; }
98 constexpr explicit operator bool()
const {
return !!
value; }
120 SDL_SURFACE_PREALLOCATED;
123 SDL_SURFACE_LOCK_NEEDED;
145#if SDL_VERSION_ATLEAST(3, 2, 10)
152 SDL_SCALEMODE_NEAREST;
155 SDL_SCALEMODE_LINEAR;
206 constexpr Surface(std::nullptr_t =
nullptr) noexcept
219 : m_resource(resource)
249 : m_resource(
CheckError(SDL_CreateSurface(size.x, size.y, format)))
281 SDL_CreateSurfaceFrom(size.x, size.y, format, pixels, pitch)))
384 ++resource.
value->refcount;
444 std::swap(m_resource, other.m_resource);
458 m_resource =
nullptr;
466 constexpr explicit operator bool() const noexcept {
return !!m_resource; }
469 constexpr operator SurfaceParam() const noexcept {
return {m_resource}; }
792 void SetRLE(
bool enabled);
1474#if SDL_VERSION_ATLEAST(3, 4, 0)
1555 SDL_ScaleMode scaleMode,
1868 return Surface(size, format, pixels, pitch);
1922 return {
CheckError(SDL_GetSurfaceProperties(surface))};
1930namespace prop::Surface {
1932constexpr auto SDR_WHITE_POINT_FLOAT = SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT;
1934constexpr auto HDR_HEADROOM_FLOAT = SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT;
1936constexpr auto TONEMAP_OPERATOR_STRING =
1937 SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING;
1939#if SDL_VERSION_ATLEAST(3, 2, 6)
1941constexpr auto HOTSPOT_X_NUMBER = SDL_PROP_SURFACE_HOTSPOT_X_NUMBER;
1943constexpr auto HOTSPOT_Y_NUMBER = SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER;
1967 CheckError(SDL_SetSurfaceColorspace(surface, colorspace));
1994 return SDL_GetSurfaceColorspace(surface);
2056 CheckError(SDL_SetSurfacePalette(surface, palette));
2113 CheckError(SDL_AddSurfaceAlternateImage(surface, image));
2137 return SDL_SurfaceHasAlternateImages(surface);
2170 auto data = SDL_GetSurfaceImages(surface, &count);
2197 SDL_RemoveSurfaceAlternateImages(surface);
2275 return Surface(SDL_LoadBMP_IO(src, closeio));
2332 bool closeio =
false)
2334 CheckError(SDL_SaveBMP_IO(surface, dst, closeio));
2392 CheckError(SDL_SetSurfaceRLE(surface, enabled));
2416 return SDL_SurfaceHasRLE(surface);
2444 CheckError(SDL_SetSurfaceColorKey(surface, key.has_value(), key.value_or(0)));
2486 return SDL_SurfaceHasColorKey(surface);
2515 if (
Uint32 key; SDL_GetSurfaceColorKey(surface, &key))
return key;
2516 return std::nullopt;
2548 CheckError(SDL_SetSurfaceColorMod(surface, r, g, b));
2577 CheckError(SDL_GetSurfaceColorMod(surface, r, g, b));
2606 CheckError(SDL_SetSurfaceAlphaMod(surface, alpha));
2631 CheckError(SDL_GetSurfaceAlphaMod(surface, &alpha));
2700 CheckError(SDL_SetSurfaceBlendMode(surface, blendMode));
2724 CheckError(SDL_GetSurfaceBlendMode(surface, &blendmode));
2757 return SDL_SetSurfaceClipRect(surface, rect);
2797 CheckError(SDL_GetSurfaceClipRect(surface, &r));
2844 return Surface(SDL_DuplicateSurface(surface));
2874 return Surface(SDL_ScaleSurface(surface, size.x, size.y, scaleMode));
2910 return Surface(SDL_ConvertSurface(surface, format));
2951 return Surface{SDL_ConvertSurfaceAndColorspace(
2952 surface, format, palette, colorspace, props)};
2961 m_resource, format, palette, colorspace, props);
2993 size.x, size.y, src_format, src, src_pitch, dst_format, dst, dst_pitch));
3037 CheckError(SDL_ConvertPixelsAndColorspace(size.x,
3109 CheckError(SDL_PremultiplySurfaceAlpha(surface, linear));
3135 CheckError(SDL_ClearSurface(surface, c.r, c.g, c.b, c.a));
3171 CheckError(SDL_FillSurfaceRect(dst, rect, color));
3307 CheckError(SDL_BlitSurface(src, srcrect, dst, dstrect));
3321 Blit(src, srcrect,
Rect{dstpos, {}});
3396 BlitSurface(src, srcrect, dst, SDL_Rect{dstpos.x, dstpos.y});
3425 CheckError(SDL_BlitSurfaceUnchecked(src, &srcrect, dst, &dstrect));
3462 CheckError(SDL_BlitSurfaceScaled(src, srcrect, dst, dstrect, scaleMode));
3502 SDL_BlitSurfaceUncheckedScaled(src, &srcrect, dst, &dstrect, scaleMode));
3513#if SDL_VERSION_ATLEAST(3, 4, 0)
3541 CheckError(SDL_StretchSurface(src, srcrect, dst, dstrect, scaleMode));
3581 CheckError(SDL_BlitSurfaceTiled(src, srcrect, dst, dstrect));
3620 SDL_ScaleMode scaleMode,
3625 src, srcrect, scale, scaleMode, dst, dstrect));
3631 SDL_ScaleMode scaleMode,
3635 src, srcrect, scale, scaleMode, m_resource, dstrect);
3702 SDL_ScaleMode scaleMode)
3751 return SDL_MapSurfaceRGB(surface, r, g, b);
3789 return SDL_MapSurfaceRGBA(surface, c.r, c.g, c.b, c.a);
3829 CheckError(SDL_ReadSurfacePixel(surface, p.x, p.y, r, g, b, a));
3900 CheckError(SDL_ReadSurfacePixelFloat(surface, p.x, p.y, r, g, b, a));
3962 CheckError(SDL_WriteSurfacePixel(surface, p.x, p.y, c.r, c.g, c.b, c.a));
3989 CheckError(SDL_WriteSurfacePixelFloat(surface, p.x, p.y, c.r, c.g, c.b, c.a));
4022 return Point(surface->w, surface->h);
4035 return surface->pitch;
4048 return surface->format;
4061 return surface->pixels;
Colorspace definitions.
Definition: SDL3pp_pixels.h:1654
Optional-like shim for references.
Definition: SDL3pp_optionalRef.h:20
Base class for SDL memory allocated array wrap.
Definition: SDL3pp_ownPtr.h:44
A set of indexed colors representing a palette.
Definition: SDL3pp_pixels.h:2476
static constexpr Palette Borrow(PaletteParam resource)
Safely borrows the from PaletteParam.
Definition: SDL3pp_pixels.h:2536
span-like for empty-derived structs
Definition: SDL3pp_spanRef.h:24
constexpr T * data() const
Retrieves contained data.
Definition: SDL3pp_spanRef.h:75
constexpr size_t size() const
Retrieves contained size.
Definition: SDL3pp_spanRef.h:69
Helpers to use C++ strings parameters.
Definition: SDL3pp_strings.h:43
A collection of pixels used in software blitting.
Definition: SDL3pp_surface.h:201
constexpr const SurfaceRaw operator->() const noexcept
member access to underlying SurfaceRaw.
Definition: SDL3pp_surface.h:433
Surface(const PointRaw &size, PixelFormat format)
Allocate a new surface with a specific pixel format.
Definition: SDL3pp_surface.h:248
constexpr SurfaceRaw release() noexcept
Retrieves underlying SurfaceRaw and clear this.
Definition: SDL3pp_surface.h:455
constexpr Surface & operator=(Surface &&other) noexcept
Assignment operator.
Definition: SDL3pp_surface.h:442
constexpr Surface(const Surface &other)
Copy constructor.
Definition: SDL3pp_surface.h:224
constexpr SurfaceRaw operator->() noexcept
member access to underlying SurfaceRaw.
Definition: SDL3pp_surface.h:436
constexpr Surface(Surface &&other) noexcept
Move constructor.
Definition: SDL3pp_surface.h:227
constexpr Surface(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_surface.h:206
constexpr Surface(const SurfaceRaw resource) noexcept
Constructs from SurfaceParam.
Definition: SDL3pp_surface.h:218
~Surface()
Destructor.
Definition: SDL3pp_surface.h:439
constexpr auto operator<=>(const Surface &other) const noexcept=default
Comparison.
constexpr Surface & operator=(const Surface &other) noexcept=default
Assignment operator.
Surface(const PointRaw &size, PixelFormat format, void *pixels, int pitch)
Allocate a new surface with a specific pixel format and existing pixel data.
Definition: SDL3pp_surface.h:279
static constexpr Surface Borrow(SurfaceParam resource)
Safely borrows the from SurfaceParam.
Definition: SDL3pp_surface.h:381
constexpr SurfaceRaw get() const noexcept
Retrieves underlying SurfaceRaw.
Definition: SDL3pp_surface.h:452
constexpr bool MustLock() const
Evaluates to true if the surface needs to be locked before access.
Definition: SDL3pp_surface.h:490
Uint32 BlendMode
A set of blend modes used in drawing operations.
Definition: SDL3pp_blendmode.h:35
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition: SDL3pp_error.h:197
SDL_FColor FColorRaw
Alias to raw representation for FColor.
Definition: SDL3pp_pixels.h:89
SDL_Color ColorRaw
Alias to raw representation for Color.
Definition: SDL3pp_pixels.h:83
SDL_Rect RectRaw
Alias to raw representation for Rect.
Definition: SDL3pp_rect.h:34
SDL_Point PointRaw
Alias to raw representation for Point.
Definition: SDL3pp_rect.h:22
Surface LoadBMP(IOStreamParam src)
Load a BMP image directly.
Definition: SDL3pp_image.h:1354
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:341
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition: SDL3pp_stdinc.h:289
void ResetSurfaceClipRect(SurfaceParam surface)
Disable the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:2770
constexpr int GetSurfaceHeight(SurfaceConstParam surface)
Get the height in pixels.
Definition: SDL3pp_surface.h:4010
void BlitSurfaceUnchecked(SurfaceParam src, const RectRaw &srcrect, SurfaceParam dst, const RectRaw &dstrect)
Perform low-level surface blitting only.
Definition: SDL3pp_surface.h:3420
Uint32 MapSurfaceRGBA(SurfaceConstParam surface, ColorRaw c)
Map an RGBA quadruple to a pixel value for a surface.
Definition: SDL3pp_surface.h:3787
Rect GetSurfaceClipRect(SurfaceConstParam surface)
Get the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:2794
Surface ScaleSurface(SurfaceConstParam surface, const PointRaw &size, ScaleMode scaleMode)
Creates a new surface identical to the existing surface, scaled to the desired size.
Definition: SDL3pp_surface.h:2870
Rect GetClipRect() const
Get the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:2801
void ClearSurface(SurfaceParam surface, const FColorRaw &c)
Clear a surface with a specific color, with floating point precision.
Definition: SDL3pp_surface.h:3133
Uint8 GetSurfaceAlphaMod(SurfaceConstParam surface)
Get the additional alpha value used in blit operations.
Definition: SDL3pp_surface.h:2628
Palette CreateSurfacePalette(SurfaceParam surface)
Create a palette and associate it with a surface.
Definition: SDL3pp_surface.h:2028
Palette GetPalette() const
Get the palette used by a surface.
Definition: SDL3pp_surface.h:2082
std::optional< Uint32 > GetColorKey() const
Get the color key (transparent pixel) for a surface.
Definition: SDL3pp_surface.h:2519
void SetSurfaceMod(SurfaceParam surface, Color color)
Set an additional color and alpha value multiplied into blit operations.
Definition: SDL3pp_surface.h:2655
constexpr FlipMode FLIP_VERTICAL
flip vertically
Definition: SDL3pp_surface.h:168
bool SetSurfaceClipRect(SurfaceParam surface, OptionalRef< const RectRaw > rect)
Set the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:2754
constexpr PixelFormat GetFormat() const
Get the pixel format.
Definition: SDL3pp_surface.h:4051
void Destroy()
Free a surface.
Definition: SDL3pp_surface.h:1887
void 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.
Definition: SDL3pp_surface.h:3456
bool SurfaceHasAlternateImages(SurfaceConstParam surface)
Return whether a surface has alternate versions available.
Definition: SDL3pp_surface.h:2135
void FillSurfaceRects(SurfaceParam dst, SpanRef< const RectRaw > rects, Uint32 color)
Perform a fast fill of a set of rectangles with a specific color.
Definition: SDL3pp_surface.h:3220
constexpr SurfaceFlags SURFACE_SIMD_ALIGNED
Surface uses pixel memory allocated with aligned_alloc()
Definition: SDL3pp_surface.h:129
BlendMode GetBlendMode() const
Get the blend mode used for blit operations.
Definition: SDL3pp_surface.h:2728
constexpr SurfaceFlags SURFACE_LOCK_NEEDED
Surface needs to be locked to access pixels.
Definition: SDL3pp_surface.h:122
constexpr void * GetSurfacePixels(SurfaceConstParam surface)
Get the pixels.
Definition: SDL3pp_surface.h:4059
void SetSurfacePalette(SurfaceParam surface, PaletteParam palette)
Set the palette used by a surface.
Definition: SDL3pp_surface.h:2054
void Unlock()
Release a surface after directly accessing the pixels.
Definition: SDL3pp_surface.h:2251
bool SurfaceHasRLE(SurfaceConstParam surface)
Returns whether the surface is RLE enabled.
Definition: SDL3pp_surface.h:2414
void DestroySurface(SurfaceRaw surface)
Free a surface.
Definition: SDL3pp_surface.h:1885
void FillRects(SpanRef< const RectRaw > rects, Uint32 color)
Perform a fast fill of a set of rectangles with a specific color.
Definition: SDL3pp_surface.h:3227
Uint32 MapRGB(Uint8 r, Uint8 g, Uint8 b) const
Map an RGB triple to an opaque pixel value for a surface.
Definition: SDL3pp_surface.h:3754
void BlitSurfaceUncheckedScaled(SurfaceParam src, const RectRaw &srcrect, SurfaceParam dst, const RectRaw &dstrect, ScaleMode scaleMode)
Perform low-level surface scaled blitting only.
Definition: SDL3pp_surface.h:3495
bool HasRLE() const
Returns whether the surface is RLE enabled.
Definition: SDL3pp_surface.h:2419
void 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, float scale=1, SDL_ScaleMode scaleMode=SCALEMODE_NEAREST)
Perform a scaled blit using the 9-grid algorithm to a destination surface, which may be of a differen...
Definition: SDL3pp_surface.h:3671
constexpr int GetHeight() const
Get the height in pixels.
Definition: SDL3pp_surface.h:4012
constexpr FlipMode FLIP_NONE
Do not flip.
Definition: SDL3pp_surface.h:164
void WriteSurfacePixel(SurfaceParam surface, const PointRaw &p, ColorRaw c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:3958
bool SurfaceHasColorKey(SurfaceConstParam surface)
Returns whether the surface has a color key.
Definition: SDL3pp_surface.h:2484
BlendMode GetSurfaceBlendMode(SurfaceConstParam surface)
Get the blend mode used for blit operations.
Definition: SDL3pp_surface.h:2721
constexpr SurfaceFlags SURFACE_PREALLOCATED
Surface uses preallocated pixel memory.
Definition: SDL3pp_surface.h:119
void 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.
Definition: SDL3pp_surface.h:3391
constexpr PixelFormat GetSurfaceFormat(SurfaceConstParam surface)
Get the pixel format.
Definition: SDL3pp_surface.h:4046
bool HasColorKey() const
Returns whether the surface has a color key.
Definition: SDL3pp_surface.h:2489
void BlitUncheckedScaled(SurfaceParam src, const RectRaw &srcrect, const RectRaw &dstrect, ScaleMode scaleMode)
Perform low-level surface scaled blitting only.
Definition: SDL3pp_surface.h:3505
constexpr ScaleMode SCALEMODE_LINEAR
linear filtering
Definition: SDL3pp_surface.h:154
void SetColorKey(std::optional< Uint32 > key)
Set the color key (transparent pixel) in a surface.
Definition: SDL3pp_surface.h:2447
void PremultiplyAlpha(bool linear)
Premultiply the alpha in a surface.
Definition: SDL3pp_surface.h:3112
void SaveBMP(IOStreamParam dst, bool closeio=false) const
Save a surface to a seekable SDL data stream in BMP format.
Definition: SDL3pp_surface.h:2362
Colorspace GetSurfaceColorspace(SurfaceConstParam surface)
Get the colorspace used by a surface.
Definition: SDL3pp_surface.h:1992
Surface DuplicateSurface(SurfaceConstParam surface)
Creates a new surface identical to the existing surface.
Definition: SDL3pp_surface.h:2842
std::optional< Uint32 > GetSurfaceColorKey(SurfaceConstParam surface)
Get the color key (transparent pixel) for a surface.
Definition: SDL3pp_surface.h:2513
Palette CreatePalette()
Create a palette and associate it with a surface.
Definition: SDL3pp_surface.h:2033
void 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.
Definition: SDL3pp_surface.h:3310
void SetSurfaceColorspace(SurfaceParam surface, Colorspace colorspace)
Set the colorspace used by a surface.
Definition: SDL3pp_surface.h:1965
Colorspace GetColorspace() const
Get the colorspace used by a surface.
Definition: SDL3pp_surface.h:1997
void ReadSurfacePixel(SurfaceConstParam surface, const PointRaw &p, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Retrieves a single pixel from a surface.
Definition: SDL3pp_surface.h:3822
constexpr ScaleMode SCALEMODE_NEAREST
nearest pixel sampling
Definition: SDL3pp_surface.h:151
void Flip(FlipMode flip)
Flip a surface vertically or horizontally.
Definition: SDL3pp_surface.h:2822
Surface CreateSurfaceFrom(const PointRaw &size, PixelFormat format, void *pixels, int pitch)
Allocate a new surface with a specific pixel format and existing pixel data.
Definition: SDL3pp_surface.h:1863
void FlipSurface(SurfaceParam surface, FlipMode flip)
Flip a surface vertically or horizontally.
Definition: SDL3pp_surface.h:2817
void ResetClipRect()
Disable the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:2775
PropertiesRef GetProperties() const
Get the properties associated with a surface.
Definition: SDL3pp_surface.h:1925
void 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.
Definition: SDL3pp_surface.h:3628
constexpr SurfaceFlags SURFACE_LOCKED
Surface is currently locked.
Definition: SDL3pp_surface.h:125
Surface ConvertSurface(SurfaceConstParam surface, PixelFormat format)
Copy an existing surface to a new surface of the specified format.
Definition: SDL3pp_surface.h:2908
constexpr Point GetSurfaceSize(SurfaceConstParam surface)
Get the size in pixels.
Definition: SDL3pp_surface.h:4020
constexpr int GetSurfaceWidth(SurfaceConstParam surface)
Get the width in pixels.
Definition: SDL3pp_surface.h:4000
bool HasAlternateImages() const
Return whether a surface has alternate versions available.
Definition: SDL3pp_surface.h:2140
void FillSurface(SurfaceParam dst, Uint32 color)
Perform a fast fill of a rectangle with a specific color.
Definition: SDL3pp_surface.h:3190
SDL_Surface * SurfaceRaw
Alias to raw representation for Surface.
Definition: SDL3pp_surface.h:42
constexpr int GetPitch() const
Get pitch in bytes.
Definition: SDL3pp_surface.h:4038
void 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.
Definition: SDL3pp_surface.h:3617
void SetSurfaceColorMod(SurfaceParam surface, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value multiplied into blit operations.
Definition: SDL3pp_surface.h:2546
Surface 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.
Definition: SDL3pp_surface.h:2945
void RemoveAlternateImages()
Remove all alternate versions of a surface.
Definition: SDL3pp_surface.h:2200
Surface Convert(PixelFormat format) const
Copy an existing surface to a new surface of the specified format.
Definition: SDL3pp_surface.h:2913
void Stretch(SurfaceParam src, OptionalRef< RectRaw > srcrect, OptionalRef< RectRaw > dstrect, ScaleMode scaleMode)
Perform a stretched pixel copy from one surface to another.
Definition: SDL3pp_surface.h:3544
constexpr Point GetSize() const
Get the size in pixels.
Definition: SDL3pp_surface.h:4025
void SetSurfaceAlphaMod(SurfaceParam surface, Uint8 alpha)
Set an additional alpha value used in blit operations.
Definition: SDL3pp_surface.h:2604
Uint8 GetAlphaMod() const
Get the additional alpha value used in blit operations.
Definition: SDL3pp_surface.h:2635
constexpr bool MustLock(SurfaceConstParam S)
Evaluates to true if the surface needs to be locked before access.
Definition: SDL3pp_surface.h:136
Surface Duplicate() const
Creates a new surface identical to the existing surface.
Definition: SDL3pp_surface.h:2847
static Surface LoadBMP(IOStreamParam src, bool closeio=false)
Load a BMP image from a seekable SDL data stream.
Definition: SDL3pp_surface.h:2298
void Clear(const FColorRaw &c)
Clear a surface with a specific color, with floating point precision.
Definition: SDL3pp_surface.h:3138
void 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.
Definition: SDL3pp_surface.h:3576
void SetSurfaceColorKey(SurfaceParam surface, std::optional< Uint32 > key)
Set the color key (transparent pixel) in a surface.
Definition: SDL3pp_surface.h:2442
void SetSurfaceRLE(SurfaceParam surface, bool enabled)
Set the RLE acceleration hint for a surface.
Definition: SDL3pp_surface.h:2390
void SetMod(Color color)
Set an additional color and alpha value multiplied into blit operations.
Definition: SDL3pp_surface.h:2661
SDL_FlipMode FlipMode
The flip mode.
Definition: SDL3pp_surface.h:162
Uint32 MapSurfaceRGB(SurfaceConstParam surface, Uint8 r, Uint8 g, Uint8 b)
Map an RGB triple to an opaque pixel value for a surface.
Definition: SDL3pp_surface.h:3746
void GetColorMod(Uint8 *r, Uint8 *g, Uint8 *b) const
Get the additional color value multiplied into blit operations.
Definition: SDL3pp_surface.h:2580
constexpr ScaleMode SCALEMODE_INVALID
INVALID.
Definition: SDL3pp_surface.h:147
constexpr int GetWidth() const
Get the width in pixels.
Definition: SDL3pp_surface.h:4002
void UnlockSurface(SurfaceParam surface)
Release a surface after directly accessing the pixels.
Definition: SDL3pp_surface.h:2249
void PremultiplySurfaceAlpha(SurfaceParam surface, bool linear)
Premultiply the alpha in a surface.
Definition: SDL3pp_surface.h:3107
void SetColorMod(Uint8 r, Uint8 g, Uint8 b)
Set an additional color value multiplied into blit operations.
Definition: SDL3pp_surface.h:2551
void 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.
Definition: SDL3pp_surface.h:3073
void BlitAt(SurfaceParam src, OptionalRef< const RectRaw > srcrect, const PointRaw &dstpos)
Performs a fast blit from the source surface to the destination surface with clipping.
Definition: SDL3pp_surface.h:3317
void SetBlendMode(BlendMode blendMode)
Set the blend mode used for blit operations.
Definition: SDL3pp_surface.h:2703
OwnArray< SurfaceRaw > GetImages() const
Get an array including all versions of a surface.
Definition: SDL3pp_surface.h:2174
Surface CreateSurface(const PointRaw &size, PixelFormat format)
Allocate a new surface with a specific pixel format.
Definition: SDL3pp_surface.h:1832
OwnArray< SurfaceRaw > GetSurfaceImages(SurfaceConstParam surface)
Get an array including all versions of a surface.
Definition: SDL3pp_surface.h:2167
constexpr int GetSurfacePitch(SurfaceConstParam surface)
Get pitch in bytes.
Definition: SDL3pp_surface.h:4033
constexpr FlipMode FLIP_HORIZONTAL
flip horizontally
Definition: SDL3pp_surface.h:166
void 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.
Definition: SDL3pp_surface.h:3465
void ReadPixel(const PointRaw &p, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) const
Retrieves a single pixel from a surface.
Definition: SDL3pp_surface.h:3857
void ReadSurfacePixelFloat(SurfaceConstParam surface, const PointRaw &p, float *r, float *g, float *b, float *a)
Retrieves a single pixel from a surface.
Definition: SDL3pp_surface.h:3893
Palette GetSurfacePalette(SurfaceConstParam surface)
Get the palette used by a surface.
Definition: SDL3pp_surface.h:2077
void StretchSurface(SurfaceParam src, OptionalRef< RectRaw > srcrect, SurfaceParam dst, OptionalRef< RectRaw > dstrect, ScaleMode scaleMode)
Perform a stretched pixel copy from one surface to another.
Definition: SDL3pp_surface.h:3535
void FillSurfaceRect(SurfaceParam dst, OptionalRef< const RectRaw > rect, Uint32 color)
Perform a fast fill of a rectangle with a specific color.
Definition: SDL3pp_surface.h:3167
Color GetSurfaceMod(SurfaceConstParam surface)
Get the additional color and alpha value multiplied into blit operations.
Definition: SDL3pp_surface.h:2671
void Fill(Uint32 color)
Perform a fast fill of a rectangle with a specific color.
Definition: SDL3pp_surface.h:3195
Uint32 MapRGBA(ColorRaw c) const
Map an RGBA quadruple to a pixel value for a surface.
Definition: SDL3pp_surface.h:3792
Surface Scale(const PointRaw &size, ScaleMode scaleMode) const
Creates a new surface identical to the existing surface, scaled to the desired size.
Definition: SDL3pp_surface.h:2877
void 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.
Definition: SDL3pp_surface.h:3025
void SetColorspace(Colorspace colorspace)
Set the colorspace used by a surface.
Definition: SDL3pp_surface.h:1970
void 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.
Definition: SDL3pp_surface.h:3584
void SaveBMP(SurfaceConstParam surface, IOStreamParam dst, bool closeio=false)
Save a surface to a seekable SDL data stream in BMP format.
Definition: SDL3pp_surface.h:2330
void ClearColorKey()
Unset the color key (transparent pixel) in a surface.
Definition: SDL3pp_surface.h:2467
void AddSurfaceAlternateImage(SurfaceParam surface, SurfaceParam image)
Add an alternate version of a surface.
Definition: SDL3pp_surface.h:2111
Uint32 SurfaceFlags
The flags on an Surface.
Definition: SDL3pp_surface.h:117
void WritePixel(const PointRaw &p, ColorRaw c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:3965
PropertiesRef GetSurfaceProperties(SurfaceConstParam surface)
Get the properties associated with a surface.
Definition: SDL3pp_surface.h:1920
void 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.
Definition: SDL3pp_surface.h:3302
void FillRect(OptionalRef< const RectRaw > rect, Uint32 color)
Perform a fast fill of a rectangle with a specific color.
Definition: SDL3pp_surface.h:3174
void Lock()
Set up a surface for directly accessing the pixels.
Definition: SDL3pp_surface.h:2234
void ReadPixelFloat(const PointRaw &p, float *r, float *g, float *b, float *a) const
Retrieves a single pixel from a surface.
Definition: SDL3pp_surface.h:3926
void GetSurfaceColorMod(SurfaceConstParam surface, Uint8 *r, Uint8 *g, Uint8 *b)
Get the additional color value multiplied into blit operations.
Definition: SDL3pp_surface.h:2572
void SetAlphaMod(Uint8 alpha)
Set an additional alpha value used in blit operations.
Definition: SDL3pp_surface.h:2609
constexpr void * GetPixels() const
Get the pixels.
Definition: SDL3pp_surface.h:4064
SDL_ScaleMode ScaleMode
The scaling mode.
Definition: SDL3pp_surface.h:143
void SetRLE(bool enabled)
Set the RLE acceleration hint for a surface.
Definition: SDL3pp_surface.h:2395
void BlitUnchecked(SurfaceParam src, const RectRaw &srcrect, const RectRaw &dstrect)
Perform low-level surface blitting only.
Definition: SDL3pp_surface.h:3428
void 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.
Definition: SDL3pp_surface.h:2984
void ClearSurfaceColorKey(SurfaceParam surface)
Unset the color key (transparent pixel) in a surface.
Definition: SDL3pp_surface.h:2462
void WriteSurfacePixelFloat(SurfaceParam surface, const PointRaw &p, const FColorRaw &c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:3985
void SetPalette(PaletteParam palette)
Set the palette used by a surface.
Definition: SDL3pp_surface.h:2059
Color GetMod() const
Get the additional color and alpha value multiplied into blit operations.
Definition: SDL3pp_surface.h:2679
void LockSurface(SurfaceParam surface)
Set up a surface for directly accessing the pixels.
Definition: SDL3pp_surface.h:2229
void SetSurfaceBlendMode(SurfaceParam surface, BlendMode blendMode)
Set the blend mode used for blit operations.
Definition: SDL3pp_surface.h:2698
bool SetClipRect(OptionalRef< const RectRaw > rect)
Set the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:2760
void AddAlternateImage(SurfaceParam image)
Add an alternate version of a surface.
Definition: SDL3pp_surface.h:2116
void WritePixelFloat(const PointRaw &p, const FColorRaw &c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:3992
void RemoveSurfaceAlternateImages(SurfaceParam surface)
Remove all alternate versions of a surface.
Definition: SDL3pp_surface.h:2195
void Blit9Grid(SurfaceParam src, OptionalRef< const RectRaw > srcrect, int left_width, int right_width, int top_height, int bottom_height, OptionalRef< const RectRaw > dstrect, float scale=1, SDL_ScaleMode scaleMode=SCALEMODE_NEAREST)
Perform a scaled blit using the 9-grid algorithm to a destination surface, which may be of a differen...
Definition: SDL3pp_surface.h:3694
Main include header for the SDL3pp library.
A structure that represents a color as RGBA components.
Definition: SDL3pp_pixels.h:2189
The bits of this structure can be directly reinterpreted as a float-packed color which uses the PIXEL...
Definition: SDL3pp_pixels.h:2362
Safely wrap IOStream for non owning parameters.
Definition: SDL3pp_iostream.h:34
Safely wrap Palette for non owning parameters.
Definition: SDL3pp_pixels.h:102
The structure that defines a point (using integers).
Definition: SDL3pp_rect.h:83
Safely wrap Properties for non owning parameters.
Definition: SDL3pp_properties.h:52
Semi-safe reference for Properties.
Definition: SDL3pp_properties.h:708
A rectangle, with the origin at the upper left (using integers).
Definition: SDL3pp_rect.h:845
Safely wrap Surface for non owning const parameters.
Definition: SDL3pp_surface.h:76
constexpr SurfaceConstParam(const SurfaceRaw value)
Constructs from SurfaceRaw.
Definition: SDL3pp_surface.h:80
constexpr SurfaceConstParam(SurfaceParam value)
Constructs from SurfaceParam.
Definition: SDL3pp_surface.h:86
const SurfaceRaw value
parameter's const SurfaceRaw
Definition: SDL3pp_surface.h:77
constexpr auto operator<=>(const SurfaceConstParam &other) const =default
Comparison.
constexpr auto operator->()
member access to underlying SurfaceRaw.
Definition: SDL3pp_surface.h:107
constexpr SurfaceConstParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_surface.h:92
Safely wrap Surface for non owning parameters.
Definition: SDL3pp_surface.h:46
SurfaceRaw value
parameter's SurfaceRaw
Definition: SDL3pp_surface.h:47
constexpr auto operator->()
member access to underlying SurfaceRaw.
Definition: SDL3pp_surface.h:71
constexpr SurfaceParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_surface.h:56
constexpr SurfaceParam(SurfaceRaw value)
Constructs from SurfaceRaw.
Definition: SDL3pp_surface.h:50
constexpr auto operator<=>(const SurfaceParam &other) const =default
Comparison.