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