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;
216 : m_resource(resource)
246 : m_resource(
CheckError(SDL_CreateSurface(size.x, size.y, format)))
278 SDL_CreateSurfaceFrom(size.x, size.y, format, pixels, pitch)))
383 ++resource.
value->refcount;
443 std::swap(m_resource, other.m_resource);
454 m_resource =
nullptr;
462 constexpr bool operator==(std::nullptr_t _)
const {
return !m_resource; }
465 constexpr explicit operator bool()
const {
return !!m_resource; }
794 void SetRLE(
bool enabled);
1477#if SDL_VERSION_ATLEAST(3, 4, 0)
1560 SDL_ScaleMode scaleMode,
1875 return Surface(size, format, pixels, pitch);
1930 return {
CheckError(SDL_GetSurfaceProperties(surface))};
1938namespace prop::Surface {
1940constexpr auto SDR_WHITE_POINT_FLOAT = SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT;
1942constexpr auto HDR_HEADROOM_FLOAT = SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT;
1944constexpr auto TONEMAP_OPERATOR_STRING =
1945 SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING;
1947#if SDL_VERSION_ATLEAST(3, 2, 6)
1949constexpr auto HOTSPOT_X_NUMBER = SDL_PROP_SURFACE_HOTSPOT_X_NUMBER;
1951constexpr auto HOTSPOT_Y_NUMBER = SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER;
1976 CheckError(SDL_SetSurfaceColorspace(surface, colorspace));
2003 return SDL_GetSurfaceColorspace(surface);
2066 CheckError(SDL_SetSurfacePalette(surface, palette));
2123 CheckError(SDL_AddSurfaceAlternateImage(surface, image));
2147 return SDL_SurfaceHasAlternateImages(surface);
2180 auto data = SDL_GetSurfaceImages(surface, &count);
2207 SDL_RemoveSurfaceAlternateImages(surface);
2285 return Surface(SDL_LoadBMP_IO(src, closeio));
2342 bool closeio =
false)
2344 CheckError(SDL_SaveBMP_IO(surface, dst, closeio));
2402 CheckError(SDL_SetSurfaceRLE(surface, enabled));
2426 return SDL_SurfaceHasRLE(surface);
2455 CheckError(SDL_SetSurfaceColorKey(surface, key.has_value(), key.value_or(0)));
2497 return SDL_SurfaceHasColorKey(surface);
2526 if (
Uint32 key; SDL_GetSurfaceColorKey(surface, &key))
return key;
2527 return std::nullopt;
2559 CheckError(SDL_SetSurfaceColorMod(surface, r, g, b));
2588 CheckError(SDL_GetSurfaceColorMod(surface, r, g, b));
2617 CheckError(SDL_SetSurfaceAlphaMod(surface, alpha));
2642 CheckError(SDL_GetSurfaceAlphaMod(surface, &alpha));
2711 CheckError(SDL_SetSurfaceBlendMode(surface, blendMode));
2735 CheckError(SDL_GetSurfaceBlendMode(surface, &blendmode));
2768 return SDL_SetSurfaceClipRect(surface, rect);
2809 CheckError(SDL_GetSurfaceClipRect(surface, &r));
2856 return Surface(SDL_DuplicateSurface(surface));
2886 return Surface(SDL_ScaleSurface(surface, size.x, size.y, scaleMode));
2922 return Surface(SDL_ConvertSurface(surface, format));
2963 return Surface{SDL_ConvertSurfaceAndColorspace(
2964 surface, format, palette, colorspace, props)};
2973 m_resource, format, palette, colorspace, props);
3005 size.x, size.y, src_format, src, src_pitch, dst_format, dst, dst_pitch));
3049 CheckError(SDL_ConvertPixelsAndColorspace(size.x,
3121 CheckError(SDL_PremultiplySurfaceAlpha(surface, linear));
3147 CheckError(SDL_ClearSurface(surface, c.r, c.g, c.b, c.a));
3183 CheckError(SDL_FillSurfaceRect(dst, rect, color));
3319 CheckError(SDL_BlitSurface(src, srcrect, dst, dstrect));
3333 Blit(src, srcrect,
Rect{dstpos, {}});
3408 BlitSurface(src, srcrect, dst, SDL_Rect{dstpos.x, dstpos.y});
3437 CheckError(SDL_BlitSurfaceUnchecked(src, &srcrect, dst, &dstrect));
3474 CheckError(SDL_BlitSurfaceScaled(src, srcrect, dst, dstrect, scaleMode));
3514 SDL_BlitSurfaceUncheckedScaled(src, &srcrect, dst, &dstrect, scaleMode));
3525#if SDL_VERSION_ATLEAST(3, 4, 0)
3553 CheckError(SDL_StretchSurface(src, srcrect, dst, dstrect, scaleMode));
3594 CheckError(SDL_BlitSurfaceTiled(src, srcrect, dst, dstrect));
3634 SDL_ScaleMode scaleMode,
3639 src, srcrect, scale, scaleMode, dst, dstrect));
3645 SDL_ScaleMode scaleMode,
3649 src, srcrect, scale, scaleMode, m_resource, dstrect);
3717 SDL_ScaleMode scaleMode)
3766 return SDL_MapSurfaceRGB(surface, r, g, b);
3804 return SDL_MapSurfaceRGBA(surface, c.r, c.g, c.b, c.a);
3844 CheckError(SDL_ReadSurfacePixel(surface, p.x, p.y, r, g, b, a));
3915 CheckError(SDL_ReadSurfacePixelFloat(surface, p.x, p.y, r, g, b, a));
3977 CheckError(SDL_WriteSurfacePixel(surface, p.x, p.y, c.r, c.g, c.b, c.a));
4004 CheckError(SDL_WriteSurfacePixelFloat(surface, p.x, p.y, c.r, c.g, c.b, c.a));
4037 return Point(surface->w, surface->h);
4050 return surface->pitch;
4063 return surface->format;
4076 return surface->pixels;
Colorspace definitions.
Definition: SDL3pp_pixels.h:1660
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:2484
static constexpr Palette Borrow(PaletteParam resource)
Safely borrows the from PaletteParam.
Definition: SDL3pp_pixels.h:2541
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
Surface(const PointRaw &size, PixelFormat format)
Allocate a new surface with a specific pixel format.
Definition: SDL3pp_surface.h:245
Surface & operator=(Surface other)
Assignment operator.
Definition: SDL3pp_surface.h:441
constexpr const SurfaceRaw operator->() const
member access to underlying SurfaceRaw.
Definition: SDL3pp_surface.h:432
constexpr Surface(const Surface &other)
Copy constructor.
Definition: SDL3pp_surface.h:221
constexpr Surface()=default
Default ctor.
~Surface()
Destructor.
Definition: SDL3pp_surface.h:438
constexpr Surface(const SurfaceRaw resource)
Constructs from SurfaceParam.
Definition: SDL3pp_surface.h:215
constexpr bool operator==(std::nullptr_t _) const
Comparison.
Definition: SDL3pp_surface.h:462
constexpr Surface(Surface &&other)
Move constructor.
Definition: SDL3pp_surface.h:224
constexpr SurfaceRaw get() const
Retrieves underlying SurfaceRaw.
Definition: SDL3pp_surface.h:448
constexpr SurfaceRaw release()
Retrieves underlying SurfaceRaw and clear this.
Definition: SDL3pp_surface.h:451
constexpr auto operator<=>(const Surface &other) const =default
Comparison.
constexpr SurfaceRaw operator->()
member access to underlying SurfaceRaw.
Definition: SDL3pp_surface.h:435
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:276
static constexpr Surface Borrow(SurfaceParam resource)
Safely borrows the from SurfaceParam.
Definition: SDL3pp_surface.h:380
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:198
SDL_FColor FColorRaw
Alias to raw representation for FColor.
Definition: SDL3pp_pixels.h:90
SDL_Color ColorRaw
Alias to raw representation for Color.
Definition: SDL3pp_pixels.h:84
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:1389
Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:328
Uint8 Uint8
An unsigned 8-bit integer type.
Definition: SDL3pp_stdinc.h:260
void ResetSurfaceClipRect(SurfaceParam surface)
Disable the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:2781
constexpr int GetSurfaceHeight(SurfaceConstParam surface)
Get the height in pixels.
Definition: SDL3pp_surface.h:4025
void BlitSurfaceUnchecked(SurfaceParam src, const RectRaw &srcrect, SurfaceParam dst, const RectRaw &dstrect)
Perform low-level surface blitting only.
Definition: SDL3pp_surface.h:3432
Uint32 MapSurfaceRGBA(SurfaceConstParam surface, ColorRaw c)
Map an RGBA quadruple to a pixel value for a surface.
Definition: SDL3pp_surface.h:3802
Rect GetSurfaceClipRect(SurfaceConstParam surface)
Get the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:2806
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:2882
Rect GetClipRect() const
Get the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:2813
void ClearSurface(SurfaceParam surface, const FColorRaw &c)
Clear a surface with a specific color, with floating point precision.
Definition: SDL3pp_surface.h:3145
Uint8 GetSurfaceAlphaMod(SurfaceConstParam surface)
Get the additional alpha value used in blit operations.
Definition: SDL3pp_surface.h:2639
Palette CreateSurfacePalette(SurfaceParam surface)
Create a palette and associate it with a surface.
Definition: SDL3pp_surface.h:2038
Palette GetPalette() const
Get the palette used by a surface.
Definition: SDL3pp_surface.h:2092
std::optional< Uint32 > GetColorKey() const
Get the color key (transparent pixel) for a surface.
Definition: SDL3pp_surface.h:2530
void SetSurfaceMod(SurfaceParam surface, Color color)
Set an additional color and alpha value multiplied into blit operations.
Definition: SDL3pp_surface.h:2666
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:2765
constexpr PixelFormat GetFormat() const
Get the pixel format.
Definition: SDL3pp_surface.h:4066
void Destroy()
Free a surface.
Definition: SDL3pp_surface.h:1894
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:3468
bool SurfaceHasAlternateImages(SurfaceConstParam surface)
Return whether a surface has alternate versions available.
Definition: SDL3pp_surface.h:2145
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:3232
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:2739
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:4074
void SetSurfacePalette(SurfaceParam surface, PaletteParam palette)
Set the palette used by a surface.
Definition: SDL3pp_surface.h:2064
void Unlock()
Release a surface after directly accessing the pixels.
Definition: SDL3pp_surface.h:2261
bool SurfaceHasRLE(SurfaceConstParam surface)
Returns whether the surface is RLE enabled.
Definition: SDL3pp_surface.h:2424
void DestroySurface(SurfaceRaw surface)
Free a surface.
Definition: SDL3pp_surface.h:1892
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:3239
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:3769
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:3507
bool HasRLE() const
Returns whether the surface is RLE enabled.
Definition: SDL3pp_surface.h:2429
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:3686
constexpr int GetHeight() const
Get the height in pixels.
Definition: SDL3pp_surface.h:4027
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:3973
bool SurfaceHasColorKey(SurfaceConstParam surface)
Returns whether the surface has a color key.
Definition: SDL3pp_surface.h:2495
BlendMode GetSurfaceBlendMode(SurfaceConstParam surface)
Get the blend mode used for blit operations.
Definition: SDL3pp_surface.h:2732
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:3403
constexpr PixelFormat GetSurfaceFormat(SurfaceConstParam surface)
Get the pixel format.
Definition: SDL3pp_surface.h:4061
bool HasColorKey() const
Returns whether the surface has a color key.
Definition: SDL3pp_surface.h:2500
void BlitUncheckedScaled(SurfaceParam src, const RectRaw &srcrect, const RectRaw &dstrect, ScaleMode scaleMode)
Perform low-level surface scaled blitting only.
Definition: SDL3pp_surface.h:3517
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:2458
void PremultiplyAlpha(bool linear)
Premultiply the alpha in a surface.
Definition: SDL3pp_surface.h:3124
void SaveBMP(IOStreamParam dst, bool closeio=false) const
Save a surface to a seekable SDL data stream in BMP format.
Definition: SDL3pp_surface.h:2372
Colorspace GetSurfaceColorspace(SurfaceConstParam surface)
Get the colorspace used by a surface.
Definition: SDL3pp_surface.h:2001
Surface DuplicateSurface(SurfaceConstParam surface)
Creates a new surface identical to the existing surface.
Definition: SDL3pp_surface.h:2854
std::optional< Uint32 > GetSurfaceColorKey(SurfaceConstParam surface)
Get the color key (transparent pixel) for a surface.
Definition: SDL3pp_surface.h:2524
Palette CreatePalette()
Create a palette and associate it with a surface.
Definition: SDL3pp_surface.h:2043
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:3322
void SetSurfaceColorspace(SurfaceParam surface, Colorspace colorspace)
Set the colorspace used by a surface.
Definition: SDL3pp_surface.h:1974
Colorspace GetColorspace() const
Get the colorspace used by a surface.
Definition: SDL3pp_surface.h:2006
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:3837
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:2834
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:1870
void FlipSurface(SurfaceParam surface, FlipMode flip)
Flip a surface vertically or horizontally.
Definition: SDL3pp_surface.h:2829
void ResetClipRect()
Disable the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:2786
PropertiesRef GetProperties() const
Get the properties associated with a surface.
Definition: SDL3pp_surface.h:1933
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:3642
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:2920
constexpr Point GetSurfaceSize(SurfaceConstParam surface)
Get the size in pixels.
Definition: SDL3pp_surface.h:4035
constexpr int GetSurfaceWidth(SurfaceConstParam surface)
Get the width in pixels.
Definition: SDL3pp_surface.h:4015
bool HasAlternateImages() const
Return whether a surface has alternate versions available.
Definition: SDL3pp_surface.h:2150
void FillSurface(SurfaceParam dst, Uint32 color)
Perform a fast fill of a rectangle with a specific color.
Definition: SDL3pp_surface.h:3202
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:4053
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:3631
void SetSurfaceColorMod(SurfaceParam surface, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value multiplied into blit operations.
Definition: SDL3pp_surface.h:2557
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:2957
void RemoveAlternateImages()
Remove all alternate versions of a surface.
Definition: SDL3pp_surface.h:2210
Surface Convert(PixelFormat format) const
Copy an existing surface to a new surface of the specified format.
Definition: SDL3pp_surface.h:2925
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:3556
constexpr Point GetSize() const
Get the size in pixels.
Definition: SDL3pp_surface.h:4040
void SetSurfaceAlphaMod(SurfaceParam surface, Uint8 alpha)
Set an additional alpha value used in blit operations.
Definition: SDL3pp_surface.h:2615
Uint8 GetAlphaMod() const
Get the additional alpha value used in blit operations.
Definition: SDL3pp_surface.h:2646
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:2859
static Surface LoadBMP(IOStreamParam src, bool closeio=false)
Load a BMP image from a seekable SDL data stream.
Definition: SDL3pp_surface.h:2308
void Clear(const FColorRaw &c)
Clear a surface with a specific color, with floating point precision.
Definition: SDL3pp_surface.h:3150
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:3589
void SetSurfaceColorKey(SurfaceParam surface, std::optional< Uint32 > key)
Set the color key (transparent pixel) in a surface.
Definition: SDL3pp_surface.h:2453
void SetSurfaceRLE(SurfaceParam surface, bool enabled)
Set the RLE acceleration hint for a surface.
Definition: SDL3pp_surface.h:2400
void SetMod(Color color)
Set an additional color and alpha value multiplied into blit operations.
Definition: SDL3pp_surface.h:2672
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:3761
void GetColorMod(Uint8 *r, Uint8 *g, Uint8 *b) const
Get the additional color value multiplied into blit operations.
Definition: SDL3pp_surface.h:2591
constexpr ScaleMode SCALEMODE_INVALID
INVALID.
Definition: SDL3pp_surface.h:147
constexpr int GetWidth() const
Get the width in pixels.
Definition: SDL3pp_surface.h:4017
void UnlockSurface(SurfaceParam surface)
Release a surface after directly accessing the pixels.
Definition: SDL3pp_surface.h:2259
void PremultiplySurfaceAlpha(SurfaceParam surface, bool linear)
Premultiply the alpha in a surface.
Definition: SDL3pp_surface.h:3119
void SetColorMod(Uint8 r, Uint8 g, Uint8 b)
Set an additional color value multiplied into blit operations.
Definition: SDL3pp_surface.h:2562
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:3085
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:3329
void SetBlendMode(BlendMode blendMode)
Set the blend mode used for blit operations.
Definition: SDL3pp_surface.h:2714
OwnArray< SurfaceRaw > GetImages() const
Get an array including all versions of a surface.
Definition: SDL3pp_surface.h:2184
Surface CreateSurface(const PointRaw &size, PixelFormat format)
Allocate a new surface with a specific pixel format.
Definition: SDL3pp_surface.h:1838
OwnArray< SurfaceRaw > GetSurfaceImages(SurfaceConstParam surface)
Get an array including all versions of a surface.
Definition: SDL3pp_surface.h:2177
constexpr int GetSurfacePitch(SurfaceConstParam surface)
Get pitch in bytes.
Definition: SDL3pp_surface.h:4048
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:3477
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:3872
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:3908
Palette GetSurfacePalette(SurfaceConstParam surface)
Get the palette used by a surface.
Definition: SDL3pp_surface.h:2087
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:3547
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:3179
Color GetSurfaceMod(SurfaceConstParam surface)
Get the additional color and alpha value multiplied into blit operations.
Definition: SDL3pp_surface.h:2682
void Fill(Uint32 color)
Perform a fast fill of a rectangle with a specific color.
Definition: SDL3pp_surface.h:3207
Uint32 MapRGBA(ColorRaw c) const
Map an RGBA quadruple to a pixel value for a surface.
Definition: SDL3pp_surface.h:3807
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:2889
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:3037
void SetColorspace(Colorspace colorspace)
Set the colorspace used by a surface.
Definition: SDL3pp_surface.h:1979
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:3597
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:2340
void ClearColorKey()
Unset the color key (transparent pixel) in a surface.
Definition: SDL3pp_surface.h:2478
void AddSurfaceAlternateImage(SurfaceParam surface, SurfaceParam image)
Add an alternate version of a surface.
Definition: SDL3pp_surface.h:2121
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:3980
PropertiesRef GetSurfaceProperties(SurfaceConstParam surface)
Get the properties associated with a surface.
Definition: SDL3pp_surface.h:1928
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:3314
void FillRect(OptionalRef< const RectRaw > rect, Uint32 color)
Perform a fast fill of a rectangle with a specific color.
Definition: SDL3pp_surface.h:3186
void Lock()
Set up a surface for directly accessing the pixels.
Definition: SDL3pp_surface.h:2244
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:3941
void GetSurfaceColorMod(SurfaceConstParam surface, Uint8 *r, Uint8 *g, Uint8 *b)
Get the additional color value multiplied into blit operations.
Definition: SDL3pp_surface.h:2583
void SetAlphaMod(Uint8 alpha)
Set an additional alpha value used in blit operations.
Definition: SDL3pp_surface.h:2620
constexpr void * GetPixels() const
Get the pixels.
Definition: SDL3pp_surface.h:4079
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:2405
void BlitUnchecked(SurfaceParam src, const RectRaw &srcrect, const RectRaw &dstrect)
Perform low-level surface blitting only.
Definition: SDL3pp_surface.h:3440
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:2996
void ClearSurfaceColorKey(SurfaceParam surface)
Unset the color key (transparent pixel) in a surface.
Definition: SDL3pp_surface.h:2473
void WriteSurfacePixelFloat(SurfaceParam surface, const PointRaw &p, const FColorRaw &c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:4000
void SetPalette(PaletteParam palette)
Set the palette used by a surface.
Definition: SDL3pp_surface.h:2069
Color GetMod() const
Get the additional color and alpha value multiplied into blit operations.
Definition: SDL3pp_surface.h:2690
void LockSurface(SurfaceParam surface)
Set up a surface for directly accessing the pixels.
Definition: SDL3pp_surface.h:2239
void SetSurfaceBlendMode(SurfaceParam surface, BlendMode blendMode)
Set the blend mode used for blit operations.
Definition: SDL3pp_surface.h:2709
bool SetClipRect(OptionalRef< const RectRaw > rect)
Set the clipping rectangle for a surface.
Definition: SDL3pp_surface.h:2771
void AddAlternateImage(SurfaceParam image)
Add an alternate version of a surface.
Definition: SDL3pp_surface.h:2126
void WritePixelFloat(const PointRaw &p, const FColorRaw &c)
Writes a single pixel to a surface.
Definition: SDL3pp_surface.h:4007
void RemoveSurfaceAlternateImages(SurfaceParam surface)
Remove all alternate versions of a surface.
Definition: SDL3pp_surface.h:2205
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:3709
Main include header for the SDL3pp library.
A structure that represents a color as RGBA components.
Definition: SDL3pp_pixels.h:2197
The bits of this structure can be directly reinterpreted as a float-packed color which uses the PIXEL...
Definition: SDL3pp_pixels.h:2370
Safely wrap IOStream for non owning parameters.
Definition: SDL3pp_iostream.h:34
Safely wrap Palette for non owning parameters.
Definition: SDL3pp_pixels.h:103
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:701
A rectangle, with the origin at the upper left (using integers).
Definition: SDL3pp_rect.h:839
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.