Set up a surface for directly accessing the pixels.
More...
|
| | SurfaceLock (SurfaceRef resource) |
| | Set up a surface for directly accessing the pixels. More...
|
| |
|
| SurfaceLock (const SurfaceLock &other)=delete |
| | Copy constructor.
|
| |
|
constexpr | SurfaceLock (SurfaceLock &&other) noexcept |
| | Move constructor.
|
| |
| | ~SurfaceLock () |
| | Release a surface after directly accessing the pixels. More...
|
| |
|
SurfaceLock & | operator= (const SurfaceLock &other)=delete |
| |
|
SurfaceLock & | operator= (SurfaceLock &&other) noexcept |
| | Assignment operator.
|
| |
|
constexpr | operator bool () const |
| | True if not locked.
|
| |
| void | ReadPixel (const PointRaw &p, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) const |
| | Retrieves a single pixel from a surface. More...
|
| |
| Color | ReadPixel (const PointRaw &p) const |
| | Retrieves a single pixel from a surface. More...
|
| |
| void | ReadPixelFloat (const PointRaw &p, float *r, float *g, float *b, float *a) const |
| | Retrieves a single pixel from a surface. More...
|
| |
| FColor | ReadPixelFloat (const PointRaw &p) const |
| | Retrieves a single pixel from a surface. More...
|
| |
| void | WritePixel (const PointRaw &p, ColorRaw c) |
| | Writes a single pixel to a surface. More...
|
| |
| void | WritePixelFloat (const PointRaw &p, const FColorRaw &c) |
| | Writes a single pixel to a surface. More...
|
| |
|
constexpr int | GetWidth () const |
| | Get the width in pixels.
|
| |
|
constexpr int | GetHeight () const |
| | Get the height in pixels.
|
| |
|
constexpr Point | GetSize () const |
| | Get the size in pixels.
|
| |
|
constexpr int | GetPitch () const |
| | Get pitch in bytes.
|
| |
|
constexpr PixelFormat | GetFormat () const |
| | Get the pixel format.
|
| |
|
constexpr void * | GetPixels () const |
| | Get the pixels.
|
| |
| void | reset () |
| | Release a surface after directly accessing the pixels. More...
|
| |
|
SurfaceRef | get () |
| | Get the reference to locked resource.
|
| |
|
void | release () |
| | Releases the lock without unlocking.
|
| |
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(surface) evaluates to 0, then you can read and write to the surface at any time, and the pixel format of the surface will not change.
- Since
- This function is available since SDL 3.2.0.
- See also
- Surface.MustLock
-
Surface.Unlock
◆ ~SurfaceLock()
| SDL::SurfaceLock::~SurfaceLock |
( |
| ) |
|
|
inline |
- Thread safety:
- This function is not thread safe. The locking referred to by this function is making the pixels available for direct access, not thread-safe locking.
- Since
- This function is available since SDL 3.2.0.
- See also
- Surface.Lock
◆ ReadPixel() [1/2]
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.
- Parameters
-
| p | the coordinates, 0 <= x < width and 0 <= y < height. |
- Returns
- color on success.
- Exceptions
-
- Thread safety:
- This function can be called on different threads with different surfaces.
- Since
- This function is available since SDL 3.2.0.
◆ ReadPixel() [2/2]
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.
- Parameters
-
| 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. |
- Exceptions
-
- Thread safety:
- This function can be called on different threads with different surfaces.
- Since
- This function is available since SDL 3.2.0.
◆ ReadPixelFloat() [1/2]
This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.
- Parameters
-
| p | the coordinates, 0 <= x < width and 0 <= y < height. |
- Returns
- color on success.
- Exceptions
-
- Thread safety:
- This function can be called on different threads with different surfaces.
- Since
- This function is available since SDL 3.2.0.
◆ ReadPixelFloat() [2/2]
| void SDL::SurfaceLock::ReadPixelFloat |
( |
const PointRaw & |
p, |
|
|
float * |
r, |
|
|
float * |
g, |
|
|
float * |
b, |
|
|
float * |
a |
|
) |
| const |
|
inline |
This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.
- Parameters
-
| 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. |
- Exceptions
-
- Thread safety:
- This function can be called on different threads with different surfaces.
- Since
- This function is available since SDL 3.2.0.
◆ WritePixel()
This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.
Like MapColor, this uses the entire 0..255 range when converting color components from pixel formats with less than 8 bits per RGB component.
- Parameters
-
| p | the coordinates, 0 <= x < width, 0 <= y < height. |
| c | the color channels value, 0-255. |
- Exceptions
-
- Thread safety:
- This function can be called on different threads with different surfaces.
- Since
- This function is available since SDL 3.2.0.
◆ WritePixelFloat()
This function prioritizes correctness over speed: it is suitable for unit tests, but is not intended for use in a game engine.
- Parameters
-
| p | the coordinates, 0 <= x < width, 0 <= y < height. |
| c | the color channels values, normally in the range 0-1. |
- Exceptions
-
- Thread safety:
- This function can be called on different threads with different surfaces.
- Since
- This function is available since SDL 3.2.0.
The documentation for this class was generated from the following file: