SDL 3.0
SDL_surface.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22/**
23 * # CategorySurface
24 *
25 * SDL surfaces are buffers of pixels in system RAM. These are useful for
26 * passing around and manipulating images that are not stored in GPU memory.
27 *
28 * SDL_Surface makes serious efforts to manage images in various formats, and
29 * provides a reasonable toolbox for transforming the data, including copying
30 * between surfaces, filling rectangles in the image data, etc.
31 *
32 * There is also a simple .bmp loader, SDL_LoadBMP(). SDL itself does not
33 * provide loaders for various other file formats, but there are several
34 * excellent external libraries that do, including its own satellite library,
35 * [SDL_image](https://wiki.libsdl.org/SDL3_image)
36 * :
37 *
38 * https://github.com/libsdl-org/SDL_image
39 */
40
41#ifndef SDL_surface_h_
42#define SDL_surface_h_
43
44#include <SDL3/SDL_stdinc.h>
45#include <SDL3/SDL_error.h>
46#include <SDL3/SDL_blendmode.h>
47#include <SDL3/SDL_pixels.h>
48#include <SDL3/SDL_properties.h>
49#include <SDL3/SDL_rect.h>
50#include <SDL3/SDL_iostream.h>
51
52#include <SDL3/SDL_begin_code.h>
53/* Set up for C function definitions, even when using C++ */
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58/**
59 * The flags on an SDL_Surface.
60 *
61 * These are generally considered read-only.
62 *
63 * \since This datatype is available since SDL 3.2.0.
64 */
66
67#define SDL_SURFACE_PREALLOCATED 0x00000001u /**< Surface uses preallocated pixel memory */
68#define SDL_SURFACE_LOCK_NEEDED 0x00000002u /**< Surface needs to be locked to access pixels */
69#define SDL_SURFACE_LOCKED 0x00000004u /**< Surface is currently locked */
70#define SDL_SURFACE_SIMD_ALIGNED 0x00000008u /**< Surface uses pixel memory allocated with SDL_aligned_alloc() */
71
72/**
73 * Evaluates to true if the surface needs to be locked before access.
74 *
75 * \since This macro is available since SDL 3.2.0.
76 */
77#define SDL_MUSTLOCK(S) (((S)->flags & SDL_SURFACE_LOCK_NEEDED) == SDL_SURFACE_LOCK_NEEDED)
78
79/**
80 * The scaling mode.
81 *
82 * \since This enum is available since SDL 3.2.0.
83 */
84typedef enum SDL_ScaleMode
85{
87 SDL_SCALEMODE_NEAREST, /**< nearest pixel sampling */
88 SDL_SCALEMODE_LINEAR, /**< linear filtering */
89 SDL_SCALEMODE_PIXELART /**< nearest pixel sampling with improved scaling for pixel art */
91
92/**
93 * The flip mode.
94 *
95 * \since This enum is available since SDL 3.2.0.
96 */
97typedef enum SDL_FlipMode
98{
99 SDL_FLIP_NONE, /**< Do not flip */
100 SDL_FLIP_HORIZONTAL, /**< flip horizontally */
101 SDL_FLIP_VERTICAL /**< flip vertically */
103
104#ifndef SDL_INTERNAL
105
106/**
107 * A collection of pixels used in software blitting.
108 *
109 * Pixels are arranged in memory in rows, with the top row first. Each row
110 * occupies an amount of memory given by the pitch (sometimes known as the row
111 * stride in non-SDL APIs).
112 *
113 * Within each row, pixels are arranged from left to right until the width is
114 * reached. Each pixel occupies a number of bits appropriate for its format,
115 * with most formats representing each pixel as one or more whole bytes (in
116 * some indexed formats, instead multiple pixels are packed into each byte),
117 * and a byte order given by the format. After encoding all pixels, any
118 * remaining bytes to reach the pitch are used as padding to reach a desired
119 * alignment, and have undefined contents.
120 *
121 * When a surface holds YUV format data, the planes are assumed to be
122 * contiguous without padding between them, e.g. a 32x32 surface in NV12
123 * format with a pitch of 32 would consist of 32x32 bytes of Y plane followed
124 * by 32x16 bytes of UV plane.
125 *
126 * When a surface holds MJPG format data, pixels points at the compressed JPEG
127 * image and pitch is the length of that data.
128 *
129 * \since This struct is available since SDL 3.2.0.
130 *
131 * \sa SDL_CreateSurface
132 * \sa SDL_DestroySurface
133 */
135{
136 SDL_SurfaceFlags flags; /**< The flags of the surface, read-only */
137 SDL_PixelFormat format; /**< The format of the surface, read-only */
138 int w; /**< The width of the surface, read-only. */
139 int h; /**< The height of the surface, read-only. */
140 int pitch; /**< The distance in bytes between rows of pixels, read-only */
141 void *pixels; /**< A pointer to the pixels of the surface, the pixels are writeable if non-NULL */
142
143 int refcount; /**< Application reference count, used when freeing surface */
144
145 void *reserved; /**< Reserved for internal use */
146};
147#endif /* !SDL_INTERNAL */
148
149typedef struct SDL_Surface SDL_Surface;
150
151/**
152 * Allocate a new surface with a specific pixel format.
153 *
154 * The pixels of the new surface are initialized to zero.
155 *
156 * \param width the width of the surface.
157 * \param height the height of the surface.
158 * \param format the SDL_PixelFormat for the new surface's pixel format.
159 * \returns the new SDL_Surface structure that is created or NULL on failure;
160 * call SDL_GetError() for more information.
161 *
162 * \threadsafety It is safe to call this function from any thread.
163 *
164 * \since This function is available since SDL 3.2.0.
165 *
166 * \sa SDL_CreateSurfaceFrom
167 * \sa SDL_DestroySurface
168 */
169extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_CreateSurface(int width, int height, SDL_PixelFormat format);
170
171/**
172 * Allocate a new surface with a specific pixel format and existing pixel
173 * data.
174 *
175 * No copy is made of the pixel data. Pixel data is not managed automatically;
176 * you must free the surface before you free the pixel data.
177 *
178 * Pitch is the offset in bytes from one row of pixels to the next, e.g.
179 * `width*4` for `SDL_PIXELFORMAT_RGBA8888`.
180 *
181 * You may pass NULL for pixels and 0 for pitch to create a surface that you
182 * will fill in with valid values later.
183 *
184 * \param width the width of the surface.
185 * \param height the height of the surface.
186 * \param format the SDL_PixelFormat for the new surface's pixel format.
187 * \param pixels a pointer to existing pixel data.
188 * \param pitch the number of bytes between each row, including padding.
189 * \returns the new SDL_Surface structure that is created or NULL on failure;
190 * call SDL_GetError() for more information.
191 *
192 * \threadsafety It is safe to call this function from any thread.
193 *
194 * \since This function is available since SDL 3.2.0.
195 *
196 * \sa SDL_CreateSurface
197 * \sa SDL_DestroySurface
198 */
199extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_CreateSurfaceFrom(int width, int height, SDL_PixelFormat format, void *pixels, int pitch);
200
201/**
202 * Free a surface.
203 *
204 * It is safe to pass NULL to this function.
205 *
206 * \param surface the SDL_Surface to free.
207 *
208 * \threadsafety No other thread should be using the surface when it is freed.
209 *
210 * \since This function is available since SDL 3.2.0.
211 *
212 * \sa SDL_CreateSurface
213 * \sa SDL_CreateSurfaceFrom
214 */
215extern SDL_DECLSPEC void SDLCALL SDL_DestroySurface(SDL_Surface *surface);
216
217/**
218 * Get the properties associated with a surface.
219 *
220 * The following properties are understood by SDL:
221 *
222 * - `SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating point
223 * surfaces, this defines the value of 100% diffuse white, with higher
224 * values being displayed in the High Dynamic Range headroom. This defaults
225 * to 203 for HDR10 surfaces and 1.0 for floating point surfaces.
226 * - `SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT`: for HDR10 and floating point
227 * surfaces, this defines the maximum dynamic range used by the content, in
228 * terms of the SDR white point. This defaults to 0.0, which disables tone
229 * mapping.
230 * - `SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING`: the tone mapping operator
231 * used when compressing from a surface with high dynamic range to another
232 * with lower dynamic range. Currently this supports "chrome", which uses
233 * the same tone mapping that Chrome uses for HDR content, the form "*=N",
234 * where N is a floating point scale factor applied in linear space, and
235 * "none", which disables tone mapping. This defaults to "chrome".
236 * - `SDL_PROP_SURFACE_HOTSPOT_X_NUMBER`: the hotspot pixel offset from the
237 * left edge of the image, if this surface is being used as a cursor.
238 * - `SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER`: the hotspot pixel offset from the
239 * top edge of the image, if this surface is being used as a cursor.
240 *
241 * \param surface the SDL_Surface structure to query.
242 * \returns a valid property ID on success or 0 on failure; call
243 * SDL_GetError() for more information.
244 *
245 * \threadsafety It is safe to call this function from any thread.
246 *
247 * \since This function is available since SDL 3.2.0.
248 */
249extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSurfaceProperties(SDL_Surface *surface);
250
251#define SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT "SDL.surface.SDR_white_point"
252#define SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT "SDL.surface.HDR_headroom"
253#define SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING "SDL.surface.tonemap"
254#define SDL_PROP_SURFACE_HOTSPOT_X_NUMBER "SDL.surface.hotspot.x"
255#define SDL_PROP_SURFACE_HOTSPOT_Y_NUMBER "SDL.surface.hotspot.y"
256
257/**
258 * Set the colorspace used by a surface.
259 *
260 * Setting the colorspace doesn't change the pixels, only how they are
261 * interpreted in color operations.
262 *
263 * \param surface the SDL_Surface structure to update.
264 * \param colorspace an SDL_Colorspace value describing the surface
265 * colorspace.
266 * \returns true on success or false on failure; call SDL_GetError() for more
267 * information.
268 *
269 * \threadsafety This function is not thread safe.
270 *
271 * \since This function is available since SDL 3.2.0.
272 *
273 * \sa SDL_GetSurfaceColorspace
274 */
275extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorspace(SDL_Surface *surface, SDL_Colorspace colorspace);
276
277/**
278 * Get the colorspace used by a surface.
279 *
280 * The colorspace defaults to SDL_COLORSPACE_SRGB_LINEAR for floating point
281 * formats, SDL_COLORSPACE_HDR10 for 10-bit formats, SDL_COLORSPACE_SRGB for
282 * other RGB surfaces and SDL_COLORSPACE_BT709_FULL for YUV textures.
283 *
284 * \param surface the SDL_Surface structure to query.
285 * \returns the colorspace used by the surface, or SDL_COLORSPACE_UNKNOWN if
286 * the surface is NULL.
287 *
288 * \threadsafety This function is not thread safe.
289 *
290 * \since This function is available since SDL 3.2.0.
291 *
292 * \sa SDL_SetSurfaceColorspace
293 */
294extern SDL_DECLSPEC SDL_Colorspace SDLCALL SDL_GetSurfaceColorspace(SDL_Surface *surface);
295
296/**
297 * Create a palette and associate it with a surface.
298 *
299 * This function creates a palette compatible with the provided surface. The
300 * palette is then returned for you to modify, and the surface will
301 * automatically use the new palette in future operations. You do not need to
302 * destroy the returned palette, it will be freed when the reference count
303 * reaches 0, usually when the surface is destroyed.
304 *
305 * Bitmap surfaces (with format SDL_PIXELFORMAT_INDEX1LSB or
306 * SDL_PIXELFORMAT_INDEX1MSB) will have the palette initialized with 0 as
307 * white and 1 as black. Other surfaces will get a palette initialized with
308 * white in every entry.
309 *
310 * If this function is called for a surface that already has a palette, a new
311 * palette will be created to replace it.
312 *
313 * \param surface the SDL_Surface structure to update.
314 * \returns a new SDL_Palette structure on success or NULL on failure (e.g. if
315 * the surface didn't have an index format); call SDL_GetError() for
316 * more information.
317 *
318 * \threadsafety This function is not thread safe.
319 *
320 * \since This function is available since SDL 3.2.0.
321 *
322 * \sa SDL_SetPaletteColors
323 */
324extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreateSurfacePalette(SDL_Surface *surface);
325
326/**
327 * Set the palette used by a surface.
328 *
329 * A single palette can be shared with many surfaces.
330 *
331 * \param surface the SDL_Surface structure to update.
332 * \param palette the SDL_Palette structure to use.
333 * \returns true on success or false on failure; call SDL_GetError() for more
334 * information.
335 *
336 * \threadsafety This function is not thread safe.
337 *
338 * \since This function is available since SDL 3.2.0.
339 *
340 * \sa SDL_CreatePalette
341 * \sa SDL_GetSurfacePalette
342 */
343extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette);
344
345/**
346 * Get the palette used by a surface.
347 *
348 * \param surface the SDL_Surface structure to query.
349 * \returns a pointer to the palette used by the surface, or NULL if there is
350 * no palette used.
351 *
352 * \threadsafety It is safe to call this function from any thread.
353 *
354 * \since This function is available since SDL 3.2.0.
355 *
356 * \sa SDL_SetSurfacePalette
357 */
358extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_GetSurfacePalette(SDL_Surface *surface);
359
360/**
361 * Add an alternate version of a surface.
362 *
363 * This function adds an alternate version of this surface, usually used for
364 * content with high DPI representations like cursors or icons. The size,
365 * format, and content do not need to match the original surface, and these
366 * alternate versions will not be updated when the original surface changes.
367 *
368 * This function adds a reference to the alternate version, so you should call
369 * SDL_DestroySurface() on the image after this call.
370 *
371 * \param surface the SDL_Surface structure to update.
372 * \param image a pointer to an alternate SDL_Surface to associate with this
373 * surface.
374 * \returns true on success or false on failure; call SDL_GetError() for more
375 * information.
376 *
377 * \threadsafety This function is not thread safe.
378 *
379 * \since This function is available since SDL 3.2.0.
380 *
381 * \sa SDL_RemoveSurfaceAlternateImages
382 * \sa SDL_GetSurfaceImages
383 * \sa SDL_SurfaceHasAlternateImages
384 */
385extern SDL_DECLSPEC bool SDLCALL SDL_AddSurfaceAlternateImage(SDL_Surface *surface, SDL_Surface *image);
386
387/**
388 * Return whether a surface has alternate versions available.
389 *
390 * \param surface the SDL_Surface structure to query.
391 * \returns true if alternate versions are available or false otherwise.
392 *
393 * \threadsafety It is safe to call this function from any thread.
394 *
395 * \since This function is available since SDL 3.2.0.
396 *
397 * \sa SDL_AddSurfaceAlternateImage
398 * \sa SDL_RemoveSurfaceAlternateImages
399 * \sa SDL_GetSurfaceImages
400 */
401extern SDL_DECLSPEC bool SDLCALL SDL_SurfaceHasAlternateImages(SDL_Surface *surface);
402
403/**
404 * Get an array including all versions of a surface.
405 *
406 * This returns all versions of a surface, with the surface being queried as
407 * the first element in the returned array.
408 *
409 * Freeing the array of surfaces does not affect the surfaces in the array.
410 * They are still referenced by the surface being queried and will be cleaned
411 * up normally.
412 *
413 * \param surface the SDL_Surface structure to query.
414 * \param count a pointer filled in with the number of surface pointers
415 * returned, may be NULL.
416 * \returns a NULL terminated array of SDL_Surface pointers or NULL on
417 * failure; call SDL_GetError() for more information. This should be
418 * freed with SDL_free() when it is no longer needed.
419 *
420 * \threadsafety This function is not thread safe.
421 *
422 * \since This function is available since SDL 3.2.0.
423 *
424 * \sa SDL_AddSurfaceAlternateImage
425 * \sa SDL_RemoveSurfaceAlternateImages
426 * \sa SDL_SurfaceHasAlternateImages
427 */
428extern SDL_DECLSPEC SDL_Surface ** SDLCALL SDL_GetSurfaceImages(SDL_Surface *surface, int *count);
429
430/**
431 * Remove all alternate versions of a surface.
432 *
433 * This function removes a reference from all the alternative versions,
434 * destroying them if this is the last reference to them.
435 *
436 * \param surface the SDL_Surface structure to update.
437 *
438 * \threadsafety This function is not thread safe.
439 *
440 * \since This function is available since SDL 3.2.0.
441 *
442 * \sa SDL_AddSurfaceAlternateImage
443 * \sa SDL_GetSurfaceImages
444 * \sa SDL_SurfaceHasAlternateImages
445 */
446extern SDL_DECLSPEC void SDLCALL SDL_RemoveSurfaceAlternateImages(SDL_Surface *surface);
447
448/**
449 * Set up a surface for directly accessing the pixels.
450 *
451 * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write to
452 * and read from `surface->pixels`, using the pixel format stored in
453 * `surface->format`. Once you are done accessing the surface, you should use
454 * SDL_UnlockSurface() to release it.
455 *
456 * Not all surfaces require locking. If `SDL_MUSTLOCK(surface)` evaluates to
457 * 0, then you can read and write to the surface at any time, and the pixel
458 * format of the surface will not change.
459 *
460 * \param surface the SDL_Surface structure to be locked.
461 * \returns true on success or false on failure; call SDL_GetError() for more
462 * information.
463 *
464 * \threadsafety This function is not thread safe. The locking referred to by
465 * this function is making the pixels available for direct
466 * access, not thread-safe locking.
467 *
468 * \since This function is available since SDL 3.2.0.
469 *
470 * \sa SDL_MUSTLOCK
471 * \sa SDL_UnlockSurface
472 */
473extern SDL_DECLSPEC bool SDLCALL SDL_LockSurface(SDL_Surface *surface);
474
475/**
476 * Release a surface after directly accessing the pixels.
477 *
478 * \param surface the SDL_Surface structure to be unlocked.
479 *
480 * \threadsafety This function is not thread safe. The locking referred to by
481 * this function is making the pixels available for direct
482 * access, not thread-safe locking.
483 *
484 * \since This function is available since SDL 3.2.0.
485 *
486 * \sa SDL_LockSurface
487 */
488extern SDL_DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface);
489
490/**
491 * Load a BMP image from a seekable SDL data stream.
492 *
493 * The new surface should be freed with SDL_DestroySurface(). Not doing so
494 * will result in a memory leak.
495 *
496 * \param src the data stream for the surface.
497 * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even
498 * in the case of an error.
499 * \returns a pointer to a new SDL_Surface structure or NULL on failure; call
500 * SDL_GetError() for more information.
501 *
502 * \threadsafety It is safe to call this function from any thread.
503 *
504 * \since This function is available since SDL 3.2.0.
505 *
506 * \sa SDL_DestroySurface
507 * \sa SDL_LoadBMP
508 * \sa SDL_SaveBMP_IO
509 */
510extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP_IO(SDL_IOStream *src, bool closeio);
511
512/**
513 * Load a BMP image from a file.
514 *
515 * The new surface should be freed with SDL_DestroySurface(). Not doing so
516 * will result in a memory leak.
517 *
518 * \param file the BMP file to load.
519 * \returns a pointer to a new SDL_Surface structure or NULL on failure; call
520 * SDL_GetError() for more information.
521 *
522 * \threadsafety It is safe to call this function from any thread.
523 *
524 * \since This function is available since SDL 3.2.0.
525 *
526 * \sa SDL_DestroySurface
527 * \sa SDL_LoadBMP_IO
528 * \sa SDL_SaveBMP
529 */
530extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP(const char *file);
531
532/**
533 * Save a surface to a seekable SDL data stream in BMP format.
534 *
535 * Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the
536 * BMP directly. Other RGB formats with 8-bit or higher get converted to a
537 * 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit
538 * surface before they are saved. YUV and paletted 1-bit and 4-bit formats are
539 * not supported.
540 *
541 * \param surface the SDL_Surface structure containing the image to be saved.
542 * \param dst a data stream to save to.
543 * \param closeio if true, calls SDL_CloseIO() on `dst` before returning, even
544 * in the case of an error.
545 * \returns true on success or false on failure; call SDL_GetError() for more
546 * information.
547 *
548 * \threadsafety This function is not thread safe.
549 *
550 * \since This function is available since SDL 3.2.0.
551 *
552 * \sa SDL_LoadBMP_IO
553 * \sa SDL_SaveBMP
554 */
555extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio);
556
557/**
558 * Save a surface to a file.
559 *
560 * Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the
561 * BMP directly. Other RGB formats with 8-bit or higher get converted to a
562 * 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit
563 * surface before they are saved. YUV and paletted 1-bit and 4-bit formats are
564 * not supported.
565 *
566 * \param surface the SDL_Surface structure containing the image to be saved.
567 * \param file a file to save to.
568 * \returns true on success or false on failure; call SDL_GetError() for more
569 * information.
570 *
571 * \threadsafety This function is not thread safe.
572 *
573 * \since This function is available since SDL 3.2.0.
574 *
575 * \sa SDL_LoadBMP
576 * \sa SDL_SaveBMP_IO
577 */
578extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP(SDL_Surface *surface, const char *file);
579
580/**
581 * Set the RLE acceleration hint for a surface.
582 *
583 * If RLE is enabled, color key and alpha blending blits are much faster, but
584 * the surface must be locked before directly accessing the pixels.
585 *
586 * \param surface the SDL_Surface structure to optimize.
587 * \param enabled true to enable RLE acceleration, false to disable it.
588 * \returns true on success or false on failure; call SDL_GetError() for more
589 * information.
590 *
591 * \threadsafety This function is not thread safe.
592 *
593 * \since This function is available since SDL 3.2.0.
594 *
595 * \sa SDL_BlitSurface
596 * \sa SDL_LockSurface
597 * \sa SDL_UnlockSurface
598 */
599extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface, bool enabled);
600
601/**
602 * Returns whether the surface is RLE enabled.
603 *
604 * It is safe to pass a NULL `surface` here; it will return false.
605 *
606 * \param surface the SDL_Surface structure to query.
607 * \returns true if the surface is RLE enabled, false otherwise.
608 *
609 * \threadsafety It is safe to call this function from any thread.
610 *
611 * \since This function is available since SDL 3.2.0.
612 *
613 * \sa SDL_SetSurfaceRLE
614 */
615extern SDL_DECLSPEC bool SDLCALL SDL_SurfaceHasRLE(SDL_Surface *surface);
616
617/**
618 * Set the color key (transparent pixel) in a surface.
619 *
620 * The color key defines a pixel value that will be treated as transparent in
621 * a blit. For example, one can use this to specify that cyan pixels should be
622 * considered transparent, and therefore not rendered.
623 *
624 * It is a pixel of the format used by the surface, as generated by
625 * SDL_MapRGB().
626 *
627 * \param surface the SDL_Surface structure to update.
628 * \param enabled true to enable color key, false to disable color key.
629 * \param key the transparent pixel.
630 * \returns true on success or false on failure; call SDL_GetError() for more
631 * information.
632 *
633 * \threadsafety This function is not thread safe.
634 *
635 * \since This function is available since SDL 3.2.0.
636 *
637 * \sa SDL_GetSurfaceColorKey
638 * \sa SDL_SetSurfaceRLE
639 * \sa SDL_SurfaceHasColorKey
640 */
641extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorKey(SDL_Surface *surface, bool enabled, Uint32 key);
642
643/**
644 * Returns whether the surface has a color key.
645 *
646 * It is safe to pass a NULL `surface` here; it will return false.
647 *
648 * \param surface the SDL_Surface structure to query.
649 * \returns true if the surface has a color key, false otherwise.
650 *
651 * \threadsafety It is safe to call this function from any thread.
652 *
653 * \since This function is available since SDL 3.2.0.
654 *
655 * \sa SDL_SetSurfaceColorKey
656 * \sa SDL_GetSurfaceColorKey
657 */
658extern SDL_DECLSPEC bool SDLCALL SDL_SurfaceHasColorKey(SDL_Surface *surface);
659
660/**
661 * Get the color key (transparent pixel) for a surface.
662 *
663 * The color key is a pixel of the format used by the surface, as generated by
664 * SDL_MapRGB().
665 *
666 * If the surface doesn't have color key enabled this function returns false.
667 *
668 * \param surface the SDL_Surface structure to query.
669 * \param key a pointer filled in with the transparent pixel.
670 * \returns true on success or false on failure; call SDL_GetError() for more
671 * information.
672 *
673 * \threadsafety It is safe to call this function from any thread.
674 *
675 * \since This function is available since SDL 3.2.0.
676 *
677 * \sa SDL_SetSurfaceColorKey
678 * \sa SDL_SurfaceHasColorKey
679 */
680extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceColorKey(SDL_Surface *surface, Uint32 *key);
681
682/**
683 * Set an additional color value multiplied into blit operations.
684 *
685 * When this surface is blitted, during the blit operation each source color
686 * channel is modulated by the appropriate color value according to the
687 * following formula:
688 *
689 * `srcC = srcC * (color / 255)`
690 *
691 * \param surface the SDL_Surface structure to update.
692 * \param r the red color value multiplied into blit operations.
693 * \param g the green color value multiplied into blit operations.
694 * \param b the blue color value multiplied into blit operations.
695 * \returns true on success or false on failure; call SDL_GetError() for more
696 * information.
697 *
698 * \threadsafety This function is not thread safe.
699 *
700 * \since This function is available since SDL 3.2.0.
701 *
702 * \sa SDL_GetSurfaceColorMod
703 * \sa SDL_SetSurfaceAlphaMod
704 */
705extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b);
706
707
708/**
709 * Get the additional color value multiplied into blit operations.
710 *
711 * \param surface the SDL_Surface structure to query.
712 * \param r a pointer filled in with the current red color value.
713 * \param g a pointer filled in with the current green color value.
714 * \param b a pointer filled in with the current blue color value.
715 * \returns true on success or false on failure; call SDL_GetError() for more
716 * information.
717 *
718 * \threadsafety This function is not thread safe.
719 *
720 * \since This function is available since SDL 3.2.0.
721 *
722 * \sa SDL_GetSurfaceAlphaMod
723 * \sa SDL_SetSurfaceColorMod
724 */
725extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b);
726
727/**
728 * Set an additional alpha value used in blit operations.
729 *
730 * When this surface is blitted, during the blit operation the source alpha
731 * value is modulated by this alpha value according to the following formula:
732 *
733 * `srcA = srcA * (alpha / 255)`
734 *
735 * \param surface the SDL_Surface structure to update.
736 * \param alpha the alpha value multiplied into blit operations.
737 * \returns true on success or false on failure; call SDL_GetError() for more
738 * information.
739 *
740 * \threadsafety This function is not thread safe.
741 *
742 * \since This function is available since SDL 3.2.0.
743 *
744 * \sa SDL_GetSurfaceAlphaMod
745 * \sa SDL_SetSurfaceColorMod
746 */
747extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha);
748
749/**
750 * Get the additional alpha value used in blit operations.
751 *
752 * \param surface the SDL_Surface structure to query.
753 * \param alpha a pointer filled in with the current alpha value.
754 * \returns true on success or false on failure; call SDL_GetError() for more
755 * information.
756 *
757 * \threadsafety It is safe to call this function from any thread.
758 *
759 * \since This function is available since SDL 3.2.0.
760 *
761 * \sa SDL_GetSurfaceColorMod
762 * \sa SDL_SetSurfaceAlphaMod
763 */
764extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha);
765
766/**
767 * Set the blend mode used for blit operations.
768 *
769 * To copy a surface to another surface (or texture) without blending with the
770 * existing data, the blendmode of the SOURCE surface should be set to
771 * `SDL_BLENDMODE_NONE`.
772 *
773 * \param surface the SDL_Surface structure to update.
774 * \param blendMode the SDL_BlendMode to use for blit blending.
775 * \returns true on success or false on failure; call SDL_GetError() for more
776 * information.
777 *
778 * \threadsafety This function is not thread safe.
779 *
780 * \since This function is available since SDL 3.2.0.
781 *
782 * \sa SDL_GetSurfaceBlendMode
783 */
784extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode);
785
786/**
787 * Get the blend mode used for blit operations.
788 *
789 * \param surface the SDL_Surface structure to query.
790 * \param blendMode a pointer filled in with the current SDL_BlendMode.
791 * \returns true on success or false on failure; call SDL_GetError() for more
792 * information.
793 *
794 * \threadsafety It is safe to call this function from any thread.
795 *
796 * \since This function is available since SDL 3.2.0.
797 *
798 * \sa SDL_SetSurfaceBlendMode
799 */
800extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode);
801
802/**
803 * Set the clipping rectangle for a surface.
804 *
805 * When `surface` is the destination of a blit, only the area within the clip
806 * rectangle is drawn into.
807 *
808 * Note that blits are automatically clipped to the edges of the source and
809 * destination surfaces.
810 *
811 * \param surface the SDL_Surface structure to be clipped.
812 * \param rect the SDL_Rect structure representing the clipping rectangle, or
813 * NULL to disable clipping.
814 * \returns true if the rectangle intersects the surface, otherwise false and
815 * blits will be completely clipped.
816 *
817 * \threadsafety This function is not thread safe.
818 *
819 * \since This function is available since SDL 3.2.0.
820 *
821 * \sa SDL_GetSurfaceClipRect
822 */
823extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceClipRect(SDL_Surface *surface, const SDL_Rect *rect);
824
825/**
826 * Get the clipping rectangle for a surface.
827 *
828 * When `surface` is the destination of a blit, only the area within the clip
829 * rectangle is drawn into.
830 *
831 * \param surface the SDL_Surface structure representing the surface to be
832 * clipped.
833 * \param rect an SDL_Rect structure filled in with the clipping rectangle for
834 * the surface.
835 * \returns true on success or false on failure; call SDL_GetError() for more
836 * information.
837 *
838 * \threadsafety This function is not thread safe.
839 *
840 * \since This function is available since SDL 3.2.0.
841 *
842 * \sa SDL_SetSurfaceClipRect
843 */
844extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceClipRect(SDL_Surface *surface, SDL_Rect *rect);
845
846/**
847 * Flip a surface vertically or horizontally.
848 *
849 * \param surface the surface to flip.
850 * \param flip the direction to flip.
851 * \returns true on success or false on failure; call SDL_GetError() for more
852 * information.
853 *
854 * \threadsafety This function is not thread safe.
855 *
856 * \since This function is available since SDL 3.2.0.
857 */
858extern SDL_DECLSPEC bool SDLCALL SDL_FlipSurface(SDL_Surface *surface, SDL_FlipMode flip);
859
860/**
861 * Creates a new surface identical to the existing surface.
862 *
863 * If the original surface has alternate images, the new surface will have a
864 * reference to them as well.
865 *
866 * The returned surface should be freed with SDL_DestroySurface().
867 *
868 * \param surface the surface to duplicate.
869 * \returns a copy of the surface or NULL on failure; call SDL_GetError() for
870 * more information.
871 *
872 * \threadsafety This function is not thread safe.
873 *
874 * \since This function is available since SDL 3.2.0.
875 *
876 * \sa SDL_DestroySurface
877 */
878extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_DuplicateSurface(SDL_Surface *surface);
879
880/**
881 * Creates a new surface identical to the existing surface, scaled to the
882 * desired size.
883 *
884 * The returned surface should be freed with SDL_DestroySurface().
885 *
886 * \param surface the surface to duplicate and scale.
887 * \param width the width of the new surface.
888 * \param height the height of the new surface.
889 * \param scaleMode the SDL_ScaleMode to be used.
890 * \returns a copy of the surface or NULL on failure; call SDL_GetError() for
891 * more information.
892 *
893 * \threadsafety This function is not thread safe.
894 *
895 * \since This function is available since SDL 3.2.0.
896 *
897 * \sa SDL_DestroySurface
898 */
899extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ScaleSurface(SDL_Surface *surface, int width, int height, SDL_ScaleMode scaleMode);
900
901/**
902 * Copy an existing surface to a new surface of the specified format.
903 *
904 * This function is used to optimize images for faster *repeat* blitting. This
905 * is accomplished by converting the original and storing the result as a new
906 * surface. The new, optimized surface can then be used as the source for
907 * future blits, making them faster.
908 *
909 * If you are converting to an indexed surface and want to map colors to a
910 * palette, you can use SDL_ConvertSurfaceAndColorspace() instead.
911 *
912 * If the original surface has alternate images, the new surface will have a
913 * reference to them as well.
914 *
915 * \param surface the existing SDL_Surface structure to convert.
916 * \param format the new pixel format.
917 * \returns the new SDL_Surface structure that is created or NULL on failure;
918 * call SDL_GetError() for more information.
919 *
920 * \threadsafety This function is not thread safe.
921 *
922 * \since This function is available since SDL 3.2.0.
923 *
924 * \sa SDL_ConvertSurfaceAndColorspace
925 * \sa SDL_DestroySurface
926 */
927extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface(SDL_Surface *surface, SDL_PixelFormat format);
928
929/**
930 * Copy an existing surface to a new surface of the specified format and
931 * colorspace.
932 *
933 * This function converts an existing surface to a new format and colorspace
934 * and returns the new surface. This will perform any pixel format and
935 * colorspace conversion needed.
936 *
937 * If the original surface has alternate images, the new surface will have a
938 * reference to them as well.
939 *
940 * \param surface the existing SDL_Surface structure to convert.
941 * \param format the new pixel format.
942 * \param palette an optional palette to use for indexed formats, may be NULL.
943 * \param colorspace the new colorspace.
944 * \param props an SDL_PropertiesID with additional color properties, or 0.
945 * \returns the new SDL_Surface structure that is created or NULL on failure;
946 * call SDL_GetError() for more information.
947 *
948 * \threadsafety This function is not thread safe.
949 *
950 * \since This function is available since SDL 3.2.0.
951 *
952 * \sa SDL_ConvertSurface
953 * \sa SDL_DestroySurface
954 */
956
957/**
958 * Copy a block of pixels of one format to another format.
959 *
960 * \param width the width of the block to copy, in pixels.
961 * \param height the height of the block to copy, in pixels.
962 * \param src_format an SDL_PixelFormat value of the `src` pixels format.
963 * \param src a pointer to the source pixels.
964 * \param src_pitch the pitch of the source pixels, in bytes.
965 * \param dst_format an SDL_PixelFormat value of the `dst` pixels format.
966 * \param dst a pointer to be filled in with new pixel data.
967 * \param dst_pitch the pitch of the destination pixels, in bytes.
968 * \returns true on success or false on failure; call SDL_GetError() for more
969 * information.
970 *
971 * \threadsafety The same destination pixels should not be used from two
972 * threads at once. It is safe to use the same source pixels
973 * from multiple threads.
974 *
975 * \since This function is available since SDL 3.2.0.
976 *
977 * \sa SDL_ConvertPixelsAndColorspace
978 */
979extern SDL_DECLSPEC bool SDLCALL SDL_ConvertPixels(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch);
980
981/**
982 * Copy a block of pixels of one format and colorspace to another format and
983 * colorspace.
984 *
985 * \param width the width of the block to copy, in pixels.
986 * \param height the height of the block to copy, in pixels.
987 * \param src_format an SDL_PixelFormat value of the `src` pixels format.
988 * \param src_colorspace an SDL_Colorspace value describing the colorspace of
989 * the `src` pixels.
990 * \param src_properties an SDL_PropertiesID with additional source color
991 * properties, or 0.
992 * \param src a pointer to the source pixels.
993 * \param src_pitch the pitch of the source pixels, in bytes.
994 * \param dst_format an SDL_PixelFormat value of the `dst` pixels format.
995 * \param dst_colorspace an SDL_Colorspace value describing the colorspace of
996 * the `dst` pixels.
997 * \param dst_properties an SDL_PropertiesID with additional destination color
998 * properties, or 0.
999 * \param dst a pointer to be filled in with new pixel data.
1000 * \param dst_pitch the pitch of the destination pixels, in bytes.
1001 * \returns true on success or false on failure; call SDL_GetError() for more
1002 * information.
1003 *
1004 * \threadsafety The same destination pixels should not be used from two
1005 * threads at once. It is safe to use the same source pixels
1006 * from multiple threads.
1007 *
1008 * \since This function is available since SDL 3.2.0.
1009 *
1010 * \sa SDL_ConvertPixels
1011 */
1012extern SDL_DECLSPEC bool SDLCALL SDL_ConvertPixelsAndColorspace(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
1013
1014/**
1015 * Premultiply the alpha on a block of pixels.
1016 *
1017 * This is safe to use with src == dst, but not for other overlapping areas.
1018 *
1019 * \param width the width of the block to convert, in pixels.
1020 * \param height the height of the block to convert, in pixels.
1021 * \param src_format an SDL_PixelFormat value of the `src` pixels format.
1022 * \param src a pointer to the source pixels.
1023 * \param src_pitch the pitch of the source pixels, in bytes.
1024 * \param dst_format an SDL_PixelFormat value of the `dst` pixels format.
1025 * \param dst a pointer to be filled in with premultiplied pixel data.
1026 * \param dst_pitch the pitch of the destination pixels, in bytes.
1027 * \param linear true to convert from sRGB to linear space for the alpha
1028 * multiplication, false to do multiplication in sRGB space.
1029 * \returns true on success or false on failure; call SDL_GetError() for more
1030 * information.
1031 *
1032 * \threadsafety The same destination pixels should not be used from two
1033 * threads at once. It is safe to use the same source pixels
1034 * from multiple threads.
1035 *
1036 * \since This function is available since SDL 3.2.0.
1037 */
1038extern SDL_DECLSPEC bool SDLCALL SDL_PremultiplyAlpha(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch, bool linear);
1039
1040/**
1041 * Premultiply the alpha in a surface.
1042 *
1043 * This is safe to use with src == dst, but not for other overlapping areas.
1044 *
1045 * \param surface the surface to modify.
1046 * \param linear true to convert from sRGB to linear space for the alpha
1047 * multiplication, false to do multiplication in sRGB space.
1048 * \returns true on success or false on failure; call SDL_GetError() for more
1049 * information.
1050 *
1051 * \threadsafety This function is not thread safe.
1052 *
1053 * \since This function is available since SDL 3.2.0.
1054 */
1055extern SDL_DECLSPEC bool SDLCALL SDL_PremultiplySurfaceAlpha(SDL_Surface *surface, bool linear);
1056
1057/**
1058 * Clear a surface with a specific color, with floating point precision.
1059 *
1060 * This function handles all surface formats, and ignores any clip rectangle.
1061 *
1062 * If the surface is YUV, the color is assumed to be in the sRGB colorspace,
1063 * otherwise the color is assumed to be in the colorspace of the suface.
1064 *
1065 * \param surface the SDL_Surface to clear.
1066 * \param r the red component of the pixel, normally in the range 0-1.
1067 * \param g the green component of the pixel, normally in the range 0-1.
1068 * \param b the blue component of the pixel, normally in the range 0-1.
1069 * \param a the alpha component of the pixel, normally in the range 0-1.
1070 * \returns true on success or false on failure; call SDL_GetError() for more
1071 * information.
1072 *
1073 * \threadsafety This function is not thread safe.
1074 *
1075 * \since This function is available since SDL 3.2.0.
1076 */
1077extern SDL_DECLSPEC bool SDLCALL SDL_ClearSurface(SDL_Surface *surface, float r, float g, float b, float a);
1078
1079/**
1080 * Perform a fast fill of a rectangle with a specific color.
1081 *
1082 * `color` should be a pixel of the format used by the surface, and can be
1083 * generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an
1084 * alpha component then the destination is simply filled with that alpha
1085 * information, no blending takes place.
1086 *
1087 * If there is a clip rectangle set on the destination (set via
1088 * SDL_SetSurfaceClipRect()), then this function will fill based on the
1089 * intersection of the clip rectangle and `rect`.
1090 *
1091 * \param dst the SDL_Surface structure that is the drawing target.
1092 * \param rect the SDL_Rect structure representing the rectangle to fill, or
1093 * NULL to fill the entire surface.
1094 * \param color the color to fill with.
1095 * \returns true on success or false on failure; call SDL_GetError() for more
1096 * information.
1097 *
1098 * \threadsafety This function is not thread safe.
1099 *
1100 * \since This function is available since SDL 3.2.0.
1101 *
1102 * \sa SDL_FillSurfaceRects
1103 */
1104extern SDL_DECLSPEC bool SDLCALL SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color);
1105
1106/**
1107 * Perform a fast fill of a set of rectangles with a specific color.
1108 *
1109 * `color` should be a pixel of the format used by the surface, and can be
1110 * generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an
1111 * alpha component then the destination is simply filled with that alpha
1112 * information, no blending takes place.
1113 *
1114 * If there is a clip rectangle set on the destination (set via
1115 * SDL_SetSurfaceClipRect()), then this function will fill based on the
1116 * intersection of the clip rectangle and `rect`.
1117 *
1118 * \param dst the SDL_Surface structure that is the drawing target.
1119 * \param rects an array of SDL_Rects representing the rectangles to fill.
1120 * \param count the number of rectangles in the array.
1121 * \param color the color to fill with.
1122 * \returns true on success or false on failure; call SDL_GetError() for more
1123 * information.
1124 *
1125 * \threadsafety This function is not thread safe.
1126 *
1127 * \since This function is available since SDL 3.2.0.
1128 *
1129 * \sa SDL_FillSurfaceRect
1130 */
1131extern SDL_DECLSPEC bool SDLCALL SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color);
1132
1133/**
1134 * Performs a fast blit from the source surface to the destination surface
1135 * with clipping.
1136 *
1137 * If either `srcrect` or `dstrect` are NULL, the entire surface (`src` or
1138 * `dst`) is copied while ensuring clipping to `dst->clip_rect`.
1139 *
1140 * The blit function should not be called on a locked surface.
1141 *
1142 * The blit semantics for surfaces with and without blending and colorkey are
1143 * defined as follows:
1144 *
1145 * ```
1146 * RGBA->RGB:
1147 * Source surface blend mode set to SDL_BLENDMODE_BLEND:
1148 * alpha-blend (using the source alpha-channel and per-surface alpha)
1149 * SDL_SRCCOLORKEY ignored.
1150 * Source surface blend mode set to SDL_BLENDMODE_NONE:
1151 * copy RGB.
1152 * if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
1153 * RGB values of the source color key, ignoring alpha in the
1154 * comparison.
1155 *
1156 * RGB->RGBA:
1157 * Source surface blend mode set to SDL_BLENDMODE_BLEND:
1158 * alpha-blend (using the source per-surface alpha)
1159 * Source surface blend mode set to SDL_BLENDMODE_NONE:
1160 * copy RGB, set destination alpha to source per-surface alpha value.
1161 * both:
1162 * if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
1163 * source color key.
1164 *
1165 * RGBA->RGBA:
1166 * Source surface blend mode set to SDL_BLENDMODE_BLEND:
1167 * alpha-blend (using the source alpha-channel and per-surface alpha)
1168 * SDL_SRCCOLORKEY ignored.
1169 * Source surface blend mode set to SDL_BLENDMODE_NONE:
1170 * copy all of RGBA to the destination.
1171 * if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
1172 * RGB values of the source color key, ignoring alpha in the
1173 * comparison.
1174 *
1175 * RGB->RGB:
1176 * Source surface blend mode set to SDL_BLENDMODE_BLEND:
1177 * alpha-blend (using the source per-surface alpha)
1178 * Source surface blend mode set to SDL_BLENDMODE_NONE:
1179 * copy RGB.
1180 * both:
1181 * if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
1182 * source color key.
1183 * ```
1184 *
1185 * \param src the SDL_Surface structure to be copied from.
1186 * \param srcrect the SDL_Rect structure representing the rectangle to be
1187 * copied, or NULL to copy the entire surface.
1188 * \param dst the SDL_Surface structure that is the blit target.
1189 * \param dstrect the SDL_Rect structure representing the x and y position in
1190 * the destination surface, or NULL for (0,0). The width and
1191 * height are ignored, and are copied from `srcrect`. If you
1192 * want a specific width and height, you should use
1193 * SDL_BlitSurfaceScaled().
1194 * \returns true on success or false on failure; call SDL_GetError() for more
1195 * information.
1196 *
1197 * \threadsafety Only one thread should be using the `src` and `dst` surfaces
1198 * at any given time.
1199 *
1200 * \since This function is available since SDL 3.2.0.
1201 *
1202 * \sa SDL_BlitSurfaceScaled
1203 */
1204extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
1205
1206/**
1207 * Perform low-level surface blitting only.
1208 *
1209 * This is a semi-private blit function and it performs low-level surface
1210 * blitting, assuming the input rectangles have already been clipped.
1211 *
1212 * \param src the SDL_Surface structure to be copied from.
1213 * \param srcrect the SDL_Rect structure representing the rectangle to be
1214 * copied, may not be NULL.
1215 * \param dst the SDL_Surface structure that is the blit target.
1216 * \param dstrect the SDL_Rect structure representing the target rectangle in
1217 * the destination surface, may not be NULL.
1218 * \returns true on success or false on failure; call SDL_GetError() for more
1219 * information.
1220 *
1221 * \threadsafety Only one thread should be using the `src` and `dst` surfaces
1222 * at any given time.
1223 *
1224 * \since This function is available since SDL 3.2.0.
1225 *
1226 * \sa SDL_BlitSurface
1227 */
1228extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceUnchecked(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
1229
1230/**
1231 * Perform a scaled blit to a destination surface, which may be of a different
1232 * format.
1233 *
1234 * \param src the SDL_Surface structure to be copied from.
1235 * \param srcrect the SDL_Rect structure representing the rectangle to be
1236 * copied, or NULL to copy the entire surface.
1237 * \param dst the SDL_Surface structure that is the blit target.
1238 * \param dstrect the SDL_Rect structure representing the target rectangle in
1239 * the destination surface, or NULL to fill the entire
1240 * destination surface.
1241 * \param scaleMode the SDL_ScaleMode to be used.
1242 * \returns true on success or false on failure; call SDL_GetError() for more
1243 * information.
1244 *
1245 * \threadsafety Only one thread should be using the `src` and `dst` surfaces
1246 * at any given time.
1247 *
1248 * \since This function is available since SDL 3.2.0.
1249 *
1250 * \sa SDL_BlitSurface
1251 */
1252extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
1253
1254/**
1255 * Perform low-level surface scaled blitting only.
1256 *
1257 * This is a semi-private function and it performs low-level surface blitting,
1258 * assuming the input rectangles have already been clipped.
1259 *
1260 * \param src the SDL_Surface structure to be copied from.
1261 * \param srcrect the SDL_Rect structure representing the rectangle to be
1262 * copied, may not be NULL.
1263 * \param dst the SDL_Surface structure that is the blit target.
1264 * \param dstrect the SDL_Rect structure representing the target rectangle in
1265 * the destination surface, may not be NULL.
1266 * \param scaleMode the SDL_ScaleMode to be used.
1267 * \returns true on success or false on failure; call SDL_GetError() for more
1268 * information.
1269 *
1270 * \threadsafety Only one thread should be using the `src` and `dst` surfaces
1271 * at any given time.
1272 *
1273 * \since This function is available since SDL 3.2.0.
1274 *
1275 * \sa SDL_BlitSurfaceScaled
1276 */
1277extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
1278
1279/**
1280 * Perform a stretched pixel copy from one surface to another.
1281 *
1282 * \param src the SDL_Surface structure to be copied from.
1283 * \param srcrect the SDL_Rect structure representing the rectangle to be
1284 * copied, or NULL to copy the entire surface.
1285 * \param dst the SDL_Surface structure that is the blit target.
1286 * \param dstrect the SDL_Rect structure representing the target rectangle in
1287 * the destination surface, or NULL to fill the entire
1288 * destination surface.
1289 * \param scaleMode the SDL_ScaleMode to be used.
1290 * \returns true on success or false on failure; call SDL_GetError() for more
1291 * information.
1292 *
1293 * \threadsafety Only one thread should be using the `src` and `dst` surfaces
1294 * at any given time.
1295 *
1296 * \since This function is available since SDL 3.4.0.
1297 *
1298 * \sa SDL_BlitSurfaceScaled
1299 */
1300extern SDL_DECLSPEC bool SDLCALL SDL_StretchSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
1301
1302/**
1303 * Perform a tiled blit to a destination surface, which may be of a different
1304 * format.
1305 *
1306 * The pixels in `srcrect` will be repeated as many times as needed to
1307 * completely fill `dstrect`.
1308 *
1309 * \param src the SDL_Surface structure to be copied from.
1310 * \param srcrect the SDL_Rect structure representing the rectangle to be
1311 * copied, or NULL to copy the entire surface.
1312 * \param dst the SDL_Surface structure that is the blit target.
1313 * \param dstrect the SDL_Rect structure representing the target rectangle in
1314 * the destination surface, or NULL to fill the entire surface.
1315 * \returns true on success or false on failure; call SDL_GetError() for more
1316 * information.
1317 *
1318 * \threadsafety Only one thread should be using the `src` and `dst` surfaces
1319 * at any given time.
1320 *
1321 * \since This function is available since SDL 3.2.0.
1322 *
1323 * \sa SDL_BlitSurface
1324 */
1325extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
1326
1327/**
1328 * Perform a scaled and tiled blit to a destination surface, which may be of a
1329 * different format.
1330 *
1331 * The pixels in `srcrect` will be scaled and repeated as many times as needed
1332 * to completely fill `dstrect`.
1333 *
1334 * \param src the SDL_Surface structure to be copied from.
1335 * \param srcrect the SDL_Rect structure representing the rectangle to be
1336 * copied, or NULL to copy the entire surface.
1337 * \param scale the scale used to transform srcrect into the destination
1338 * rectangle, e.g. a 32x32 texture with a scale of 2 would fill
1339 * 64x64 tiles.
1340 * \param scaleMode scale algorithm to be used.
1341 * \param dst the SDL_Surface structure that is the blit target.
1342 * \param dstrect the SDL_Rect structure representing the target rectangle in
1343 * the destination surface, or NULL to fill the entire surface.
1344 * \returns true on success or false on failure; call SDL_GetError() for more
1345 * information.
1346 *
1347 * \threadsafety Only one thread should be using the `src` and `dst` surfaces
1348 * at any given time.
1349 *
1350 * \since This function is available since SDL 3.2.0.
1351 *
1352 * \sa SDL_BlitSurface
1353 */
1354extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceTiledWithScale(SDL_Surface *src, const SDL_Rect *srcrect, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect);
1355
1356/**
1357 * Perform a scaled blit using the 9-grid algorithm to a destination surface,
1358 * which may be of a different format.
1359 *
1360 * The pixels in the source surface are split into a 3x3 grid, using the
1361 * different corner sizes for each corner, and the sides and center making up
1362 * the remaining pixels. The corners are then scaled using `scale` and fit
1363 * into the corners of the destination rectangle. The sides and center are
1364 * then stretched into place to cover the remaining destination rectangle.
1365 *
1366 * \param src the SDL_Surface structure to be copied from.
1367 * \param srcrect the SDL_Rect structure representing the rectangle to be used
1368 * for the 9-grid, or NULL to use the entire surface.
1369 * \param left_width the width, in pixels, of the left corners in `srcrect`.
1370 * \param right_width the width, in pixels, of the right corners in `srcrect`.
1371 * \param top_height the height, in pixels, of the top corners in `srcrect`.
1372 * \param bottom_height the height, in pixels, of the bottom corners in
1373 * `srcrect`.
1374 * \param scale the scale used to transform the corner of `srcrect` into the
1375 * corner of `dstrect`, or 0.0f for an unscaled blit.
1376 * \param scaleMode scale algorithm to be used.
1377 * \param dst the SDL_Surface structure that is the blit target.
1378 * \param dstrect the SDL_Rect structure representing the target rectangle in
1379 * the destination surface, or NULL to fill the entire surface.
1380 * \returns true on success or false on failure; call SDL_GetError() for more
1381 * information.
1382 *
1383 * \threadsafety Only one thread should be using the `src` and `dst` surfaces
1384 * at any given time.
1385 *
1386 * \since This function is available since SDL 3.2.0.
1387 *
1388 * \sa SDL_BlitSurface
1389 */
1390extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface9Grid(SDL_Surface *src, const SDL_Rect *srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect);
1391
1392/**
1393 * Map an RGB triple to an opaque pixel value for a surface.
1394 *
1395 * This function maps the RGB color value to the specified pixel format and
1396 * returns the pixel value best approximating the given RGB color value for
1397 * the given pixel format.
1398 *
1399 * If the surface has a palette, the index of the closest matching color in
1400 * the palette will be returned.
1401 *
1402 * If the surface pixel format has an alpha component it will be returned as
1403 * all 1 bits (fully opaque).
1404 *
1405 * If the pixel format bpp (color depth) is less than 32-bpp then the unused
1406 * upper bits of the return value can safely be ignored (e.g., with a 16-bpp
1407 * format the return value can be assigned to a Uint16, and similarly a Uint8
1408 * for an 8-bpp format).
1409 *
1410 * \param surface the surface to use for the pixel format and palette.
1411 * \param r the red component of the pixel in the range 0-255.
1412 * \param g the green component of the pixel in the range 0-255.
1413 * \param b the blue component of the pixel in the range 0-255.
1414 * \returns a pixel value.
1415 *
1416 * \threadsafety It is safe to call this function from any thread.
1417 *
1418 * \since This function is available since SDL 3.2.0.
1419 *
1420 * \sa SDL_MapSurfaceRGBA
1421 */
1422extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapSurfaceRGB(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b);
1423
1424/**
1425 * Map an RGBA quadruple to a pixel value for a surface.
1426 *
1427 * This function maps the RGBA color value to the specified pixel format and
1428 * returns the pixel value best approximating the given RGBA color value for
1429 * the given pixel format.
1430 *
1431 * If the surface pixel format has no alpha component the alpha value will be
1432 * ignored (as it will be in formats with a palette).
1433 *
1434 * If the surface has a palette, the index of the closest matching color in
1435 * the palette will be returned.
1436 *
1437 * If the pixel format bpp (color depth) is less than 32-bpp then the unused
1438 * upper bits of the return value can safely be ignored (e.g., with a 16-bpp
1439 * format the return value can be assigned to a Uint16, and similarly a Uint8
1440 * for an 8-bpp format).
1441 *
1442 * \param surface the surface to use for the pixel format and palette.
1443 * \param r the red component of the pixel in the range 0-255.
1444 * \param g the green component of the pixel in the range 0-255.
1445 * \param b the blue component of the pixel in the range 0-255.
1446 * \param a the alpha component of the pixel in the range 0-255.
1447 * \returns a pixel value.
1448 *
1449 * \threadsafety It is safe to call this function from any thread.
1450 *
1451 * \since This function is available since SDL 3.2.0.
1452 *
1453 * \sa SDL_MapSurfaceRGB
1454 */
1455extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapSurfaceRGBA(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
1456
1457/**
1458 * Retrieves a single pixel from a surface.
1459 *
1460 * This function prioritizes correctness over speed: it is suitable for unit
1461 * tests, but is not intended for use in a game engine.
1462 *
1463 * Like SDL_GetRGBA, this uses the entire 0..255 range when converting color
1464 * components from pixel formats with less than 8 bits per RGB component.
1465 *
1466 * \param surface the surface to read.
1467 * \param x the horizontal coordinate, 0 <= x < width.
1468 * \param y the vertical coordinate, 0 <= y < height.
1469 * \param r a pointer filled in with the red channel, 0-255, or NULL to ignore
1470 * this channel.
1471 * \param g a pointer filled in with the green channel, 0-255, or NULL to
1472 * ignore this channel.
1473 * \param b a pointer filled in with the blue channel, 0-255, or NULL to
1474 * ignore this channel.
1475 * \param a a pointer filled in with the alpha channel, 0-255, or NULL to
1476 * ignore this channel.
1477 * \returns true on success or false on failure; call SDL_GetError() for more
1478 * information.
1479 *
1480 * \threadsafety This function is not thread safe.
1481 *
1482 * \since This function is available since SDL 3.2.0.
1483 */
1484extern SDL_DECLSPEC bool SDLCALL SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
1485
1486/**
1487 * Retrieves a single pixel from a surface.
1488 *
1489 * This function prioritizes correctness over speed: it is suitable for unit
1490 * tests, but is not intended for use in a game engine.
1491 *
1492 * \param surface the surface to read.
1493 * \param x the horizontal coordinate, 0 <= x < width.
1494 * \param y the vertical coordinate, 0 <= y < height.
1495 * \param r a pointer filled in with the red channel, normally in the range
1496 * 0-1, or NULL to ignore this channel.
1497 * \param g a pointer filled in with the green channel, normally in the range
1498 * 0-1, or NULL to ignore this channel.
1499 * \param b a pointer filled in with the blue channel, normally in the range
1500 * 0-1, or NULL to ignore this channel.
1501 * \param a a pointer filled in with the alpha channel, normally in the range
1502 * 0-1, or NULL to ignore this channel.
1503 * \returns true on success or false on failure; call SDL_GetError() for more
1504 * information.
1505 *
1506 * \threadsafety This function is not thread safe.
1507 *
1508 * \since This function is available since SDL 3.2.0.
1509 */
1510extern SDL_DECLSPEC bool SDLCALL SDL_ReadSurfacePixelFloat(SDL_Surface *surface, int x, int y, float *r, float *g, float *b, float *a);
1511
1512/**
1513 * Writes a single pixel to a surface.
1514 *
1515 * This function prioritizes correctness over speed: it is suitable for unit
1516 * tests, but is not intended for use in a game engine.
1517 *
1518 * Like SDL_MapRGBA, this uses the entire 0..255 range when converting color
1519 * components from pixel formats with less than 8 bits per RGB component.
1520 *
1521 * \param surface the surface to write.
1522 * \param x the horizontal coordinate, 0 <= x < width.
1523 * \param y the vertical coordinate, 0 <= y < height.
1524 * \param r the red channel value, 0-255.
1525 * \param g the green channel value, 0-255.
1526 * \param b the blue channel value, 0-255.
1527 * \param a the alpha channel value, 0-255.
1528 * \returns true on success or false on failure; call SDL_GetError() for more
1529 * information.
1530 *
1531 * \threadsafety This function is not thread safe.
1532 *
1533 * \since This function is available since SDL 3.2.0.
1534 */
1535extern SDL_DECLSPEC bool SDLCALL SDL_WriteSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
1536
1537/**
1538 * Writes a single pixel to a surface.
1539 *
1540 * This function prioritizes correctness over speed: it is suitable for unit
1541 * tests, but is not intended for use in a game engine.
1542 *
1543 * \param surface the surface to write.
1544 * \param x the horizontal coordinate, 0 <= x < width.
1545 * \param y the vertical coordinate, 0 <= y < height.
1546 * \param r the red channel value, normally in the range 0-1.
1547 * \param g the green channel value, normally in the range 0-1.
1548 * \param b the blue channel value, normally in the range 0-1.
1549 * \param a the alpha channel value, normally in the range 0-1.
1550 * \returns true on success or false on failure; call SDL_GetError() for more
1551 * information.
1552 *
1553 * \threadsafety This function is not thread safe.
1554 *
1555 * \since This function is available since SDL 3.2.0.
1556 */
1557extern SDL_DECLSPEC bool SDLCALL SDL_WriteSurfacePixelFloat(SDL_Surface *surface, int x, int y, float r, float g, float b, float a);
1558
1559/* Ends C function definitions when using C++ */
1560#ifdef __cplusplus
1561}
1562#endif
1563#include <SDL3/SDL_close_code.h>
1564
1565#endif /* SDL_surface_h_ */
Uint32 SDL_BlendMode
struct SDL_IOStream SDL_IOStream
SDL_Colorspace
SDL_PixelFormat
Definition SDL_pixels.h:549
Uint32 SDL_PropertiesID
uint8_t Uint8
Definition SDL_stdinc.h:425
uint32_t Uint32
Definition SDL_stdinc.h:461
bool SDL_GetSurfaceColorKey(SDL_Surface *surface, Uint32 *key)
SDL_PropertiesID SDL_GetSurfaceProperties(SDL_Surface *surface)
bool SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha)
bool SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette)
bool SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color)
bool SDL_PremultiplyAlpha(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch, bool linear)
bool SDL_PremultiplySurfaceAlpha(SDL_Surface *surface, bool linear)
bool SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
void SDL_DestroySurface(SDL_Surface *surface)
bool SDL_BlitSurfaceUnchecked(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect)
bool SDL_SaveBMP(SDL_Surface *surface, const char *file)
bool SDL_FlipSurface(SDL_Surface *surface, SDL_FlipMode flip)
Uint32 SDL_MapSurfaceRGB(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
bool SDL_WriteSurfacePixelFloat(SDL_Surface *surface, int x, int y, float r, float g, float b, float a)
SDL_Surface * SDL_LoadBMP_IO(SDL_IOStream *src, bool closeio)
bool SDL_SetSurfaceColorKey(SDL_Surface *surface, bool enabled, Uint32 key)
SDL_Surface * SDL_DuplicateSurface(SDL_Surface *surface)
bool SDL_SurfaceHasAlternateImages(SDL_Surface *surface)
bool SDL_ReadSurfacePixelFloat(SDL_Surface *surface, int x, int y, float *r, float *g, float *b, float *a)
bool SDL_SetSurfaceRLE(SDL_Surface *surface, bool enabled)
bool SDL_BlitSurface9Grid(SDL_Surface *src, const SDL_Rect *srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect)
void SDL_RemoveSurfaceAlternateImages(SDL_Surface *surface)
bool SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color)
Uint32 SDL_SurfaceFlags
Definition SDL_surface.h:65
SDL_Palette * SDL_CreateSurfacePalette(SDL_Surface *surface)
bool SDL_GetSurfaceClipRect(SDL_Surface *surface, SDL_Rect *rect)
SDL_Surface * SDL_ConvertSurface(SDL_Surface *surface, SDL_PixelFormat format)
bool SDL_SurfaceHasColorKey(SDL_Surface *surface)
bool SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode)
bool SDL_SurfaceHasRLE(SDL_Surface *surface)
SDL_Surface ** SDL_GetSurfaceImages(SDL_Surface *surface, int *count)
SDL_Palette * SDL_GetSurfacePalette(SDL_Surface *surface)
SDL_ScaleMode
Definition SDL_surface.h:85
@ SDL_SCALEMODE_LINEAR
Definition SDL_surface.h:88
@ SDL_SCALEMODE_PIXELART
Definition SDL_surface.h:89
@ SDL_SCALEMODE_NEAREST
Definition SDL_surface.h:87
@ SDL_SCALEMODE_INVALID
Definition SDL_surface.h:86
bool SDL_ConvertPixelsAndColorspace(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch)
bool SDL_AddSurfaceAlternateImage(SDL_Surface *surface, SDL_Surface *image)
bool SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect)
SDL_FlipMode
Definition SDL_surface.h:98
@ SDL_FLIP_VERTICAL
@ SDL_FLIP_NONE
Definition SDL_surface.h:99
@ SDL_FLIP_HORIZONTAL
SDL_Colorspace SDL_GetSurfaceColorspace(SDL_Surface *surface)
void SDL_UnlockSurface(SDL_Surface *surface)
SDL_Surface * SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelFormat format, SDL_Palette *palette, SDL_Colorspace colorspace, SDL_PropertiesID props)
SDL_Surface * SDL_ScaleSurface(SDL_Surface *surface, int width, int height, SDL_ScaleMode scaleMode)
bool SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b)
bool SDL_LockSurface(SDL_Surface *surface)
bool SDL_ConvertPixels(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch)
Uint32 SDL_MapSurfaceRGBA(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_Surface * SDL_CreateSurfaceFrom(int width, int height, SDL_PixelFormat format, void *pixels, int pitch)
bool SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha)
bool SDL_BlitSurfaceTiledWithScale(SDL_Surface *src, const SDL_Rect *srcrect, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect)
bool SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode)
bool SDL_SetSurfaceClipRect(SDL_Surface *surface, const SDL_Rect *rect)
bool SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode)
SDL_Surface * SDL_LoadBMP(const char *file)
bool SDL_SetSurfaceColorspace(SDL_Surface *surface, SDL_Colorspace colorspace)
bool SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
bool SDL_StretchSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode)
bool SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect)
bool SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio)
bool SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode)
bool SDL_ClearSurface(SDL_Surface *surface, float r, float g, float b, float a)
bool SDL_WriteSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_Surface * SDL_CreateSurface(int width, int height, SDL_PixelFormat format)
SDL_SurfaceFlags flags
void * reserved
SDL_PixelFormat format
void * pixels