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 * This is intended as a convenience function for loading images from trusted
601 * sources. If you want to load arbitrary images you should use libpng or
602 * another image loading library designed with security in mind.
603 *
604 * The new surface should be freed with SDL_DestroySurface(). Not doing so
605 * will result in a memory leak.
606 *
607 * \param src the data stream for the surface.
608 * \param closeio if true, calls SDL_CloseIO() on `src` before returning, even
609 * in the case of an error.
610 * \returns a pointer to a new SDL_Surface structure or NULL on failure; call
611 * SDL_GetError() for more information.
612 *
613 * \threadsafety It is safe to call this function from any thread.
614 *
615 * \since This function is available since SDL 3.4.0.
616 *
617 * \sa SDL_DestroySurface
618 * \sa SDL_LoadPNG
619 * \sa SDL_SavePNG_IO
620 */
621extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadPNG_IO(SDL_IOStream *src, bool closeio);
622
623/**
624 * Load a PNG image from a file.
625 *
626 * This is intended as a convenience function for loading images from trusted
627 * sources. If you want to load arbitrary images you should use libpng or
628 * another image loading library designed with security in mind.
629 *
630 * The new surface should be freed with SDL_DestroySurface(). Not doing so
631 * will result in a memory leak.
632 *
633 * \param file the PNG file to load.
634 * \returns a pointer to a new SDL_Surface structure or NULL on failure; call
635 * SDL_GetError() for more information.
636 *
637 * \threadsafety It is safe to call this function from any thread.
638 *
639 * \since This function is available since SDL 3.4.0.
640 *
641 * \sa SDL_DestroySurface
642 * \sa SDL_LoadPNG_IO
643 * \sa SDL_SavePNG
644 */
645extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadPNG(const char *file);
646
647/**
648 * Save a surface to a seekable SDL data stream in PNG format.
649 *
650 * \param surface the SDL_Surface structure containing the image to be saved.
651 * \param dst a data stream to save to.
652 * \param closeio if true, calls SDL_CloseIO() on `dst` before returning, even
653 * in the case of an error.
654 * \returns true on success or false on failure; call SDL_GetError() for more
655 * information.
656 *
657 * \threadsafety This function can be called on different threads with
658 * different surfaces.
659 *
660 * \since This function is available since SDL 3.4.0.
661 *
662 * \sa SDL_LoadPNG_IO
663 * \sa SDL_SavePNG
664 */
665extern SDL_DECLSPEC bool SDLCALL SDL_SavePNG_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio);
666
667/**
668 * Save a surface to a file in PNG format.
669 *
670 * \param surface the SDL_Surface structure containing the image to be saved.
671 * \param file a file to save to.
672 * \returns true on success or false on failure; call SDL_GetError() for more
673 * information.
674 *
675 * \threadsafety This function can be called on different threads with
676 * different surfaces.
677 *
678 * \since This function is available since SDL 3.4.0.
679 *
680 * \sa SDL_LoadPNG
681 * \sa SDL_SavePNG_IO
682 */
683extern SDL_DECLSPEC bool SDLCALL SDL_SavePNG(SDL_Surface *surface, const char *file);
684
685/**
686 * Set the RLE acceleration hint for a surface.
687 *
688 * If RLE is enabled, color key and alpha blending blits are much faster, but
689 * the surface must be locked before directly accessing the pixels.
690 *
691 * \param surface the SDL_Surface structure to optimize.
692 * \param enabled true to enable RLE acceleration, false to disable it.
693 * \returns true on success or false on failure; call SDL_GetError() for more
694 * information.
695 *
696 * \threadsafety This function can be called on different threads with
697 * different surfaces.
698 *
699 * \since This function is available since SDL 3.2.0.
700 *
701 * \sa SDL_BlitSurface
702 * \sa SDL_LockSurface
703 * \sa SDL_UnlockSurface
704 */
705extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface, bool enabled);
706
707/**
708 * Returns whether the surface is RLE enabled.
709 *
710 * It is safe to pass a NULL `surface` here; it will return false.
711 *
712 * \param surface the SDL_Surface structure to query.
713 * \returns true if the surface is RLE enabled, false otherwise.
714 *
715 * \threadsafety It is safe to call this function from any thread.
716 *
717 * \since This function is available since SDL 3.2.0.
718 *
719 * \sa SDL_SetSurfaceRLE
720 */
721extern SDL_DECLSPEC bool SDLCALL SDL_SurfaceHasRLE(SDL_Surface *surface);
722
723/**
724 * Set the color key (transparent pixel) in a surface.
725 *
726 * The color key defines a pixel value that will be treated as transparent in
727 * a blit. For example, one can use this to specify that cyan pixels should be
728 * considered transparent, and therefore not rendered.
729 *
730 * It is a pixel of the format used by the surface, as generated by
731 * SDL_MapRGB().
732 *
733 * \param surface the SDL_Surface structure to update.
734 * \param enabled true to enable color key, false to disable color key.
735 * \param key the transparent pixel.
736 * \returns true on success or false on failure; call SDL_GetError() for more
737 * information.
738 *
739 * \threadsafety This function can be called on different threads with
740 * different surfaces.
741 *
742 * \since This function is available since SDL 3.2.0.
743 *
744 * \sa SDL_GetSurfaceColorKey
745 * \sa SDL_SetSurfaceRLE
746 * \sa SDL_SurfaceHasColorKey
747 */
748extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorKey(SDL_Surface *surface, bool enabled, Uint32 key);
749
750/**
751 * Returns whether the surface has a color key.
752 *
753 * It is safe to pass a NULL `surface` here; it will return false.
754 *
755 * \param surface the SDL_Surface structure to query.
756 * \returns true if the surface has a color key, false otherwise.
757 *
758 * \threadsafety It is safe to call this function from any thread.
759 *
760 * \since This function is available since SDL 3.2.0.
761 *
762 * \sa SDL_SetSurfaceColorKey
763 * \sa SDL_GetSurfaceColorKey
764 */
765extern SDL_DECLSPEC bool SDLCALL SDL_SurfaceHasColorKey(SDL_Surface *surface);
766
767/**
768 * Get the color key (transparent pixel) for a surface.
769 *
770 * The color key is a pixel of the format used by the surface, as generated by
771 * SDL_MapRGB().
772 *
773 * If the surface doesn't have color key enabled this function returns false.
774 *
775 * \param surface the SDL_Surface structure to query.
776 * \param key a pointer filled in with the transparent pixel.
777 * \returns true on success or false on failure; call SDL_GetError() for more
778 * information.
779 *
780 * \threadsafety It is safe to call this function from any thread.
781 *
782 * \since This function is available since SDL 3.2.0.
783 *
784 * \sa SDL_SetSurfaceColorKey
785 * \sa SDL_SurfaceHasColorKey
786 */
787extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceColorKey(SDL_Surface *surface, Uint32 *key);
788
789/**
790 * Set an additional color value multiplied into blit operations.
791 *
792 * When this surface is blitted, during the blit operation each source color
793 * channel is modulated by the appropriate color value according to the
794 * following formula:
795 *
796 * `srcC = srcC * (color / 255)`
797 *
798 * \param surface the SDL_Surface structure to update.
799 * \param r the red color value multiplied into blit operations.
800 * \param g the green color value multiplied into blit operations.
801 * \param b the blue color value multiplied into blit operations.
802 * \returns true on success or false on failure; call SDL_GetError() for more
803 * information.
804 *
805 * \threadsafety This function can be called on different threads with
806 * different surfaces.
807 *
808 * \since This function is available since SDL 3.2.0.
809 *
810 * \sa SDL_GetSurfaceColorMod
811 * \sa SDL_SetSurfaceAlphaMod
812 */
813extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b);
814
815
816/**
817 * Get the additional color value multiplied into blit operations.
818 *
819 * \param surface the SDL_Surface structure to query.
820 * \param r a pointer filled in with the current red color value.
821 * \param g a pointer filled in with the current green color value.
822 * \param b a pointer filled in with the current blue color value.
823 * \returns true on success or false on failure; call SDL_GetError() for more
824 * information.
825 *
826 * \threadsafety This function can be called on different threads with
827 * different surfaces.
828 *
829 * \since This function is available since SDL 3.2.0.
830 *
831 * \sa SDL_GetSurfaceAlphaMod
832 * \sa SDL_SetSurfaceColorMod
833 */
834extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b);
835
836/**
837 * Set an additional alpha value used in blit operations.
838 *
839 * When this surface is blitted, during the blit operation the source alpha
840 * value is modulated by this alpha value according to the following formula:
841 *
842 * `srcA = srcA * (alpha / 255)`
843 *
844 * \param surface the SDL_Surface structure to update.
845 * \param alpha the alpha value multiplied into blit operations.
846 * \returns true on success or false on failure; call SDL_GetError() for more
847 * information.
848 *
849 * \threadsafety This function can be called on different threads with
850 * different surfaces.
851 *
852 * \since This function is available since SDL 3.2.0.
853 *
854 * \sa SDL_GetSurfaceAlphaMod
855 * \sa SDL_SetSurfaceColorMod
856 */
857extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha);
858
859/**
860 * Get the additional alpha value used in blit operations.
861 *
862 * \param surface the SDL_Surface structure to query.
863 * \param alpha a pointer filled in with the current alpha value.
864 * \returns true on success or false on failure; call SDL_GetError() for more
865 * information.
866 *
867 * \threadsafety It is safe to call this function from any thread.
868 *
869 * \since This function is available since SDL 3.2.0.
870 *
871 * \sa SDL_GetSurfaceColorMod
872 * \sa SDL_SetSurfaceAlphaMod
873 */
874extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha);
875
876/**
877 * Set the blend mode used for blit operations.
878 *
879 * To copy a surface to another surface (or texture) without blending with the
880 * existing data, the blendmode of the SOURCE surface should be set to
881 * `SDL_BLENDMODE_NONE`.
882 *
883 * \param surface the SDL_Surface structure to update.
884 * \param blendMode the SDL_BlendMode to use for blit blending.
885 * \returns true on success or false on failure; call SDL_GetError() for more
886 * information.
887 *
888 * \threadsafety This function can be called on different threads with
889 * different surfaces.
890 *
891 * \since This function is available since SDL 3.2.0.
892 *
893 * \sa SDL_GetSurfaceBlendMode
894 */
895extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode);
896
897/**
898 * Get the blend mode used for blit operations.
899 *
900 * \param surface the SDL_Surface structure to query.
901 * \param blendMode a pointer filled in with the current SDL_BlendMode.
902 * \returns true on success or false on failure; call SDL_GetError() for more
903 * information.
904 *
905 * \threadsafety It is safe to call this function from any thread.
906 *
907 * \since This function is available since SDL 3.2.0.
908 *
909 * \sa SDL_SetSurfaceBlendMode
910 */
911extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode);
912
913/**
914 * Set the clipping rectangle for a surface.
915 *
916 * When `surface` is the destination of a blit, only the area within the clip
917 * rectangle is drawn into.
918 *
919 * Note that blits are automatically clipped to the edges of the source and
920 * destination surfaces.
921 *
922 * \param surface the SDL_Surface structure to be clipped.
923 * \param rect the SDL_Rect structure representing the clipping rectangle, or
924 * NULL to disable clipping.
925 * \returns true if the rectangle intersects the surface, otherwise false and
926 * blits will be completely clipped.
927 *
928 * \threadsafety This function can be called on different threads with
929 * different surfaces.
930 *
931 * \since This function is available since SDL 3.2.0.
932 *
933 * \sa SDL_GetSurfaceClipRect
934 */
935extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceClipRect(SDL_Surface *surface, const SDL_Rect *rect);
936
937/**
938 * Get the clipping rectangle for a surface.
939 *
940 * When `surface` is the destination of a blit, only the area within the clip
941 * rectangle is drawn into.
942 *
943 * \param surface the SDL_Surface structure representing the surface to be
944 * clipped.
945 * \param rect an SDL_Rect structure filled in with the clipping rectangle for
946 * the surface.
947 * \returns true on success or false on failure; call SDL_GetError() for more
948 * information.
949 *
950 * \threadsafety This function can be called on different threads with
951 * different surfaces.
952 *
953 * \since This function is available since SDL 3.2.0.
954 *
955 * \sa SDL_SetSurfaceClipRect
956 */
957extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceClipRect(SDL_Surface *surface, SDL_Rect *rect);
958
959/**
960 * Flip a surface vertically or horizontally.
961 *
962 * \param surface the surface to flip.
963 * \param flip the direction to flip.
964 * \returns true on success or false on failure; call SDL_GetError() for more
965 * information.
966 *
967 * \threadsafety This function can be called on different threads with
968 * different surfaces.
969 *
970 * \since This function is available since SDL 3.2.0.
971 */
972extern SDL_DECLSPEC bool SDLCALL SDL_FlipSurface(SDL_Surface *surface, SDL_FlipMode flip);
973
974/**
975 * Return a copy of a surface rotated clockwise a number of degrees.
976 *
977 * The angle of rotation can be negative for counter-clockwise rotation.
978 *
979 * When the rotation isn't a multiple of 90 degrees, the resulting surface is
980 * larger than the original, with the background filled in with the colorkey,
981 * if available, or RGBA 255/255/255/0 if not.
982 *
983 * \param surface the surface to rotate.
984 * \param angle the rotation angle, in degrees.
985 * \returns a rotated copy of the surface or NULL on failure; call
986 * SDL_GetError() for more information.
987 *
988 * \threadsafety This function can be called on different threads with
989 * different surfaces.
990 *
991 * \since This function is available since SDL 3.4.0.
992 */
993extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RotateSurface(SDL_Surface *surface, float angle);
994
995/**
996 * Creates a new surface identical to the existing surface.
997 *
998 * If the original surface has alternate images, the new surface will have a
999 * reference to them as well.
1000 *
1001 * The returned surface should be freed with SDL_DestroySurface().
1002 *
1003 * \param surface the surface to duplicate.
1004 * \returns a copy of the surface or NULL on failure; call SDL_GetError() for
1005 * more information.
1006 *
1007 * \threadsafety This function can be called on different threads with
1008 * different surfaces.
1009 *
1010 * \since This function is available since SDL 3.2.0.
1011 *
1012 * \sa SDL_DestroySurface
1013 */
1014extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_DuplicateSurface(SDL_Surface *surface);
1015
1016/**
1017 * Creates a new surface identical to the existing surface, scaled to the
1018 * desired size.
1019 *
1020 * The returned surface should be freed with SDL_DestroySurface().
1021 *
1022 * \param surface the surface to duplicate and scale.
1023 * \param width the width of the new surface.
1024 * \param height the height of the new surface.
1025 * \param scaleMode the SDL_ScaleMode to be used.
1026 * \returns a copy of the surface or NULL on failure; call SDL_GetError() for
1027 * more information.
1028 *
1029 * \threadsafety This function can be called on different threads with
1030 * different surfaces.
1031 *
1032 * \since This function is available since SDL 3.2.0.
1033 *
1034 * \sa SDL_DestroySurface
1035 */
1036extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ScaleSurface(SDL_Surface *surface, int width, int height, SDL_ScaleMode scaleMode);
1037
1038/**
1039 * Copy an existing surface to a new surface of the specified format.
1040 *
1041 * This function is used to optimize images for faster *repeat* blitting. This
1042 * is accomplished by converting the original and storing the result as a new
1043 * surface. The new, optimized surface can then be used as the source for
1044 * future blits, making them faster.
1045 *
1046 * If you are converting to an indexed surface and want to map colors to a
1047 * palette, you can use SDL_ConvertSurfaceAndColorspace() instead.
1048 *
1049 * If the original surface has alternate images, the new surface will have a
1050 * reference to them as well.
1051 *
1052 * \param surface the existing SDL_Surface structure to convert.
1053 * \param format the new pixel format.
1054 * \returns the new SDL_Surface structure that is created or NULL on failure;
1055 * call SDL_GetError() for more information.
1056 *
1057 * \threadsafety This function can be called on different threads with
1058 * different surfaces.
1059 *
1060 * \since This function is available since SDL 3.2.0.
1061 *
1062 * \sa SDL_ConvertSurfaceAndColorspace
1063 * \sa SDL_DestroySurface
1064 */
1065extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface(SDL_Surface *surface, SDL_PixelFormat format);
1066
1067/**
1068 * Copy an existing surface to a new surface of the specified format and
1069 * colorspace.
1070 *
1071 * This function converts an existing surface to a new format and colorspace
1072 * and returns the new surface. This will perform any pixel format and
1073 * colorspace conversion needed.
1074 *
1075 * If the original surface has alternate images, the new surface will have a
1076 * reference to them as well.
1077 *
1078 * \param surface the existing SDL_Surface structure to convert.
1079 * \param format the new pixel format.
1080 * \param palette an optional palette to use for indexed formats, may be NULL.
1081 * \param colorspace the new colorspace.
1082 * \param props an SDL_PropertiesID with additional color properties, or 0.
1083 * \returns the new SDL_Surface structure that is created or NULL on failure;
1084 * call SDL_GetError() for more information.
1085 *
1086 * \threadsafety This function can be called on different threads with
1087 * different surfaces.
1088 *
1089 * \since This function is available since SDL 3.2.0.
1090 *
1091 * \sa SDL_ConvertSurface
1092 * \sa SDL_DestroySurface
1093 */
1095
1096/**
1097 * Copy a block of pixels of one format to another format.
1098 *
1099 * \param width the width of the block to copy, in pixels.
1100 * \param height the height of the block to copy, in pixels.
1101 * \param src_format an SDL_PixelFormat value of the `src` pixels format.
1102 * \param src a pointer to the source pixels.
1103 * \param src_pitch the pitch of the source pixels, in bytes.
1104 * \param dst_format an SDL_PixelFormat value of the `dst` pixels format.
1105 * \param dst a pointer to be filled in with new pixel data.
1106 * \param dst_pitch the pitch of the destination pixels, in bytes.
1107 * \returns true on success or false on failure; call SDL_GetError() for more
1108 * information.
1109 *
1110 * \threadsafety The same destination pixels should not be used from two
1111 * threads at once. It is safe to use the same source pixels
1112 * from multiple threads.
1113 *
1114 * \since This function is available since SDL 3.2.0.
1115 *
1116 * \sa SDL_ConvertPixelsAndColorspace
1117 */
1118extern 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);
1119
1120/**
1121 * Copy a block of pixels of one format and colorspace to another format and
1122 * colorspace.
1123 *
1124 * \param width the width of the block to copy, in pixels.
1125 * \param height the height of the block to copy, in pixels.
1126 * \param src_format an SDL_PixelFormat value of the `src` pixels format.
1127 * \param src_colorspace an SDL_Colorspace value describing the colorspace of
1128 * the `src` pixels.
1129 * \param src_properties an SDL_PropertiesID with additional source color
1130 * properties, or 0.
1131 * \param src a pointer to the source pixels.
1132 * \param src_pitch the pitch of the source pixels, in bytes.
1133 * \param dst_format an SDL_PixelFormat value of the `dst` pixels format.
1134 * \param dst_colorspace an SDL_Colorspace value describing the colorspace of
1135 * the `dst` pixels.
1136 * \param dst_properties an SDL_PropertiesID with additional destination color
1137 * properties, or 0.
1138 * \param dst a pointer to be filled in with new pixel data.
1139 * \param dst_pitch the pitch of the destination pixels, in bytes.
1140 * \returns true on success or false on failure; call SDL_GetError() for more
1141 * information.
1142 *
1143 * \threadsafety The same destination pixels should not be used from two
1144 * threads at once. It is safe to use the same source pixels
1145 * from multiple threads.
1146 *
1147 * \since This function is available since SDL 3.2.0.
1148 *
1149 * \sa SDL_ConvertPixels
1150 */
1151extern 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);
1152
1153/**
1154 * Premultiply the alpha on a block of pixels.
1155 *
1156 * This is safe to use with src == dst, but not for other overlapping areas.
1157 *
1158 * \param width the width of the block to convert, in pixels.
1159 * \param height the height of the block to convert, in pixels.
1160 * \param src_format an SDL_PixelFormat value of the `src` pixels format.
1161 * \param src a pointer to the source pixels.
1162 * \param src_pitch the pitch of the source pixels, in bytes.
1163 * \param dst_format an SDL_PixelFormat value of the `dst` pixels format.
1164 * \param dst a pointer to be filled in with premultiplied pixel data.
1165 * \param dst_pitch the pitch of the destination pixels, in bytes.
1166 * \param linear true to convert from sRGB to linear space for the alpha
1167 * multiplication, false to do multiplication in sRGB space.
1168 * \returns true on success or false on failure; call SDL_GetError() for more
1169 * information.
1170 *
1171 * \threadsafety The same destination pixels should not be used from two
1172 * threads at once. It is safe to use the same source pixels
1173 * from multiple threads.
1174 *
1175 * \since This function is available since SDL 3.2.0.
1176 */
1177extern 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);
1178
1179/**
1180 * Premultiply the alpha in a surface.
1181 *
1182 * This is safe to use with src == dst, but not for other overlapping areas.
1183 *
1184 * \param surface the surface to modify.
1185 * \param linear true to convert from sRGB to linear space for the alpha
1186 * multiplication, false to do multiplication in sRGB space.
1187 * \returns true on success or false on failure; call SDL_GetError() for more
1188 * information.
1189 *
1190 * \threadsafety This function can be called on different threads with
1191 * different surfaces.
1192 *
1193 * \since This function is available since SDL 3.2.0.
1194 */
1195extern SDL_DECLSPEC bool SDLCALL SDL_PremultiplySurfaceAlpha(SDL_Surface *surface, bool linear);
1196
1197/**
1198 * Clear a surface with a specific color, with floating point precision.
1199 *
1200 * This function handles all surface formats, and ignores any clip rectangle.
1201 *
1202 * If the surface is YUV, the color is assumed to be in the sRGB colorspace,
1203 * otherwise the color is assumed to be in the colorspace of the suface.
1204 *
1205 * \param surface the SDL_Surface to clear.
1206 * \param r the red component of the pixel, normally in the range 0-1.
1207 * \param g the green component of the pixel, normally in the range 0-1.
1208 * \param b the blue component of the pixel, normally in the range 0-1.
1209 * \param a the alpha component of the pixel, normally in the range 0-1.
1210 * \returns true on success or false on failure; call SDL_GetError() for more
1211 * information.
1212 *
1213 * \threadsafety This function can be called on different threads with
1214 * different surfaces.
1215 *
1216 * \since This function is available since SDL 3.2.0.
1217 */
1218extern SDL_DECLSPEC bool SDLCALL SDL_ClearSurface(SDL_Surface *surface, float r, float g, float b, float a);
1219
1220/**
1221 * Perform a fast fill of a rectangle with a specific color.
1222 *
1223 * `color` should be a pixel of the format used by the surface, and can be
1224 * generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an
1225 * alpha component then the destination is simply filled with that alpha
1226 * information, no blending takes place.
1227 *
1228 * If there is a clip rectangle set on the destination (set via
1229 * SDL_SetSurfaceClipRect()), then this function will fill based on the
1230 * intersection of the clip rectangle and `rect`.
1231 *
1232 * \param dst the SDL_Surface structure that is the drawing target.
1233 * \param rect the SDL_Rect structure representing the rectangle to fill, or
1234 * NULL to fill the entire surface.
1235 * \param color the color to fill with.
1236 * \returns true on success or false on failure; call SDL_GetError() for more
1237 * information.
1238 *
1239 * \threadsafety This function can be called on different threads with
1240 * different surfaces.
1241 *
1242 * \since This function is available since SDL 3.2.0.
1243 *
1244 * \sa SDL_FillSurfaceRects
1245 */
1246extern SDL_DECLSPEC bool SDLCALL SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color);
1247
1248/**
1249 * Perform a fast fill of a set of rectangles with a specific color.
1250 *
1251 * `color` should be a pixel of the format used by the surface, and can be
1252 * generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an
1253 * alpha component then the destination is simply filled with that alpha
1254 * information, no blending takes place.
1255 *
1256 * If there is a clip rectangle set on the destination (set via
1257 * SDL_SetSurfaceClipRect()), then this function will fill based on the
1258 * intersection of the clip rectangle and `rect`.
1259 *
1260 * \param dst the SDL_Surface structure that is the drawing target.
1261 * \param rects an array of SDL_Rects representing the rectangles to fill.
1262 * \param count the number of rectangles in the array.
1263 * \param color the color to fill with.
1264 * \returns true on success or false on failure; call SDL_GetError() for more
1265 * information.
1266 *
1267 * \threadsafety This function can be called on different threads with
1268 * different surfaces.
1269 *
1270 * \since This function is available since SDL 3.2.0.
1271 *
1272 * \sa SDL_FillSurfaceRect
1273 */
1274extern SDL_DECLSPEC bool SDLCALL SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color);
1275
1276/**
1277 * Performs a fast blit from the source surface to the destination surface
1278 * with clipping.
1279 *
1280 * If either `srcrect` or `dstrect` are NULL, the entire surface (`src` or
1281 * `dst`) is copied while ensuring clipping to `dst->clip_rect`.
1282 *
1283 * The blit function should not be called on a locked surface.
1284 *
1285 * The blit semantics for surfaces with and without blending and colorkey are
1286 * defined as follows:
1287 *
1288 * ```
1289 * RGBA->RGB:
1290 * Source surface blend mode set to SDL_BLENDMODE_BLEND:
1291 * alpha-blend (using the source alpha-channel and per-surface alpha)
1292 * SDL_SRCCOLORKEY ignored.
1293 * Source surface blend mode set to SDL_BLENDMODE_NONE:
1294 * copy RGB.
1295 * if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
1296 * RGB values of the source color key, ignoring alpha in the
1297 * comparison.
1298 *
1299 * RGB->RGBA:
1300 * Source surface blend mode set to SDL_BLENDMODE_BLEND:
1301 * alpha-blend (using the source per-surface alpha)
1302 * Source surface blend mode set to SDL_BLENDMODE_NONE:
1303 * copy RGB, set destination alpha to source per-surface alpha value.
1304 * both:
1305 * if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
1306 * source color key.
1307 *
1308 * RGBA->RGBA:
1309 * Source surface blend mode set to SDL_BLENDMODE_BLEND:
1310 * alpha-blend (using the source alpha-channel and per-surface alpha)
1311 * SDL_SRCCOLORKEY ignored.
1312 * Source surface blend mode set to SDL_BLENDMODE_NONE:
1313 * copy all of RGBA to the destination.
1314 * if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
1315 * RGB values of the source color key, ignoring alpha in the
1316 * comparison.
1317 *
1318 * RGB->RGB:
1319 * Source surface blend mode set to SDL_BLENDMODE_BLEND:
1320 * alpha-blend (using the source per-surface alpha)
1321 * Source surface blend mode set to SDL_BLENDMODE_NONE:
1322 * copy RGB.
1323 * both:
1324 * if SDL_SRCCOLORKEY set, only copy the pixels that do not match the
1325 * source color key.
1326 * ```
1327 *
1328 * \param src the SDL_Surface structure to be copied from.
1329 * \param srcrect the SDL_Rect structure representing the rectangle to be
1330 * copied, or NULL to copy the entire surface.
1331 * \param dst the SDL_Surface structure that is the blit target.
1332 * \param dstrect the SDL_Rect structure representing the x and y position in
1333 * the destination surface, or NULL for (0,0). The width and
1334 * height are ignored, and are copied from `srcrect`. If you
1335 * want a specific width and height, you should use
1336 * SDL_BlitSurfaceScaled().
1337 * \returns true on success or false on failure; call SDL_GetError() for more
1338 * information.
1339 *
1340 * \threadsafety Only one thread should be using the `src` and `dst` surfaces
1341 * at any given time.
1342 *
1343 * \since This function is available since SDL 3.2.0.
1344 *
1345 * \sa SDL_BlitSurfaceScaled
1346 */
1347extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
1348
1349/**
1350 * Perform low-level surface blitting only.
1351 *
1352 * This is a semi-private blit function and it performs low-level surface
1353 * blitting, assuming the input rectangles have already been clipped.
1354 *
1355 * \param src the SDL_Surface structure to be copied from.
1356 * \param srcrect the SDL_Rect structure representing the rectangle to be
1357 * copied, may not be NULL.
1358 * \param dst the SDL_Surface structure that is the blit target.
1359 * \param dstrect the SDL_Rect structure representing the target rectangle in
1360 * the destination surface, may not be NULL.
1361 * \returns true on success or false on failure; call SDL_GetError() for more
1362 * information.
1363 *
1364 * \threadsafety Only one thread should be using the `src` and `dst` surfaces
1365 * at any given time.
1366 *
1367 * \since This function is available since SDL 3.2.0.
1368 *
1369 * \sa SDL_BlitSurface
1370 */
1371extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceUnchecked(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
1372
1373/**
1374 * Perform a scaled blit to a destination surface, which may be of a different
1375 * format.
1376 *
1377 * \param src the SDL_Surface structure to be copied from.
1378 * \param srcrect the SDL_Rect structure representing the rectangle to be
1379 * copied, or NULL to copy the entire surface.
1380 * \param dst the SDL_Surface structure that is the blit target.
1381 * \param dstrect the SDL_Rect structure representing the target rectangle in
1382 * the destination surface, or NULL to fill the entire
1383 * destination surface.
1384 * \param scaleMode the SDL_ScaleMode to be used.
1385 * \returns true on success or false on failure; call SDL_GetError() for more
1386 * information.
1387 *
1388 * \threadsafety Only one thread should be using the `src` and `dst` surfaces
1389 * at any given time.
1390 *
1391 * \since This function is available since SDL 3.2.0.
1392 *
1393 * \sa SDL_BlitSurface
1394 */
1395extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
1396
1397/**
1398 * Perform low-level surface scaled blitting only.
1399 *
1400 * This is a semi-private function and it performs low-level surface blitting,
1401 * assuming the input rectangles have already been clipped.
1402 *
1403 * \param src the SDL_Surface structure to be copied from.
1404 * \param srcrect the SDL_Rect structure representing the rectangle to be
1405 * copied, may not be NULL.
1406 * \param dst the SDL_Surface structure that is the blit target.
1407 * \param dstrect the SDL_Rect structure representing the target rectangle in
1408 * the destination surface, may not be NULL.
1409 * \param scaleMode the SDL_ScaleMode to be used.
1410 * \returns true on success or false on failure; call SDL_GetError() for more
1411 * information.
1412 *
1413 * \threadsafety Only one thread should be using the `src` and `dst` surfaces
1414 * at any given time.
1415 *
1416 * \since This function is available since SDL 3.2.0.
1417 *
1418 * \sa SDL_BlitSurfaceScaled
1419 */
1420extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
1421
1422/**
1423 * Perform a stretched pixel copy from one surface to another.
1424 *
1425 * \param src the SDL_Surface structure to be copied from.
1426 * \param srcrect the SDL_Rect structure representing the rectangle to be
1427 * copied, or NULL to copy the entire surface.
1428 * \param dst the SDL_Surface structure that is the blit target.
1429 * \param dstrect the SDL_Rect structure representing the target rectangle in
1430 * the destination surface, or NULL to fill the entire
1431 * destination surface.
1432 * \param scaleMode the SDL_ScaleMode to be used.
1433 * \returns true on success or false on failure; call SDL_GetError() for more
1434 * information.
1435 *
1436 * \threadsafety Only one thread should be using the `src` and `dst` surfaces
1437 * at any given time.
1438 *
1439 * \since This function is available since SDL 3.4.0.
1440 *
1441 * \sa SDL_BlitSurfaceScaled
1442 */
1443extern SDL_DECLSPEC bool SDLCALL SDL_StretchSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
1444
1445/**
1446 * Perform a tiled blit to a destination surface, which may be of a different
1447 * format.
1448 *
1449 * The pixels in `srcrect` will be repeated as many times as needed to
1450 * completely fill `dstrect`.
1451 *
1452 * \param src the SDL_Surface structure to be copied from.
1453 * \param srcrect the SDL_Rect structure representing the rectangle to be
1454 * copied, or NULL to copy the entire surface.
1455 * \param dst the SDL_Surface structure that is the blit target.
1456 * \param dstrect the SDL_Rect structure representing the target rectangle in
1457 * the destination surface, or NULL to fill the entire surface.
1458 * \returns true on success or false on failure; call SDL_GetError() for more
1459 * information.
1460 *
1461 * \threadsafety Only one thread should be using the `src` and `dst` surfaces
1462 * at any given time.
1463 *
1464 * \since This function is available since SDL 3.2.0.
1465 *
1466 * \sa SDL_BlitSurface
1467 */
1468extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
1469
1470/**
1471 * Perform a scaled and tiled blit to a destination surface, which may be of a
1472 * different format.
1473 *
1474 * The pixels in `srcrect` will be scaled and repeated as many times as needed
1475 * to completely fill `dstrect`.
1476 *
1477 * \param src the SDL_Surface structure to be copied from.
1478 * \param srcrect the SDL_Rect structure representing the rectangle to be
1479 * copied, or NULL to copy the entire surface.
1480 * \param scale the scale used to transform srcrect into the destination
1481 * rectangle, e.g. a 32x32 texture with a scale of 2 would fill
1482 * 64x64 tiles.
1483 * \param scaleMode scale algorithm to be used.
1484 * \param dst the SDL_Surface structure that is the blit target.
1485 * \param dstrect the SDL_Rect structure representing the target rectangle in
1486 * the destination surface, or NULL to fill the entire surface.
1487 * \returns true on success or false on failure; call SDL_GetError() for more
1488 * information.
1489 *
1490 * \threadsafety Only one thread should be using the `src` and `dst` surfaces
1491 * at any given time.
1492 *
1493 * \since This function is available since SDL 3.2.0.
1494 *
1495 * \sa SDL_BlitSurface
1496 */
1497extern 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);
1498
1499/**
1500 * Perform a scaled blit using the 9-grid algorithm to a destination surface,
1501 * which may be of a different format.
1502 *
1503 * The pixels in the source surface are split into a 3x3 grid, using the
1504 * different corner sizes for each corner, and the sides and center making up
1505 * the remaining pixels. The corners are then scaled using `scale` and fit
1506 * into the corners of the destination rectangle. The sides and center are
1507 * then stretched into place to cover the remaining destination rectangle.
1508 *
1509 * \param src the SDL_Surface structure to be copied from.
1510 * \param srcrect the SDL_Rect structure representing the rectangle to be used
1511 * for the 9-grid, or NULL to use the entire surface.
1512 * \param left_width the width, in pixels, of the left corners in `srcrect`.
1513 * \param right_width the width, in pixels, of the right corners in `srcrect`.
1514 * \param top_height the height, in pixels, of the top corners in `srcrect`.
1515 * \param bottom_height the height, in pixels, of the bottom corners in
1516 * `srcrect`.
1517 * \param scale the scale used to transform the corner of `srcrect` into the
1518 * corner of `dstrect`, or 0.0f for an unscaled blit.
1519 * \param scaleMode scale algorithm to be used.
1520 * \param dst the SDL_Surface structure that is the blit target.
1521 * \param dstrect the SDL_Rect structure representing the target rectangle in
1522 * the destination surface, or NULL to fill the entire surface.
1523 * \returns true on success or false on failure; call SDL_GetError() for more
1524 * information.
1525 *
1526 * \threadsafety Only one thread should be using the `src` and `dst` surfaces
1527 * at any given time.
1528 *
1529 * \since This function is available since SDL 3.2.0.
1530 *
1531 * \sa SDL_BlitSurface
1532 */
1533extern 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);
1534
1535/**
1536 * Map an RGB triple to an opaque pixel value for a surface.
1537 *
1538 * This function maps the RGB color value to the specified pixel format and
1539 * returns the pixel value best approximating the given RGB color value for
1540 * the given pixel format.
1541 *
1542 * If the surface has a palette, the index of the closest matching color in
1543 * the palette will be returned.
1544 *
1545 * If the surface pixel format has an alpha component it will be returned as
1546 * all 1 bits (fully opaque).
1547 *
1548 * If the pixel format bpp (color depth) is less than 32-bpp then the unused
1549 * upper bits of the return value can safely be ignored (e.g., with a 16-bpp
1550 * format the return value can be assigned to a Uint16, and similarly a Uint8
1551 * for an 8-bpp format).
1552 *
1553 * \param surface the surface to use for the pixel format and palette.
1554 * \param r the red component of the pixel in the range 0-255.
1555 * \param g the green component of the pixel in the range 0-255.
1556 * \param b the blue component of the pixel in the range 0-255.
1557 * \returns a pixel value.
1558 *
1559 * \threadsafety This function can be called on different threads with
1560 * different surfaces.
1561 *
1562 * \since This function is available since SDL 3.2.0.
1563 *
1564 * \sa SDL_MapSurfaceRGBA
1565 */
1566extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapSurfaceRGB(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b);
1567
1568/**
1569 * Map an RGBA quadruple to a pixel value for a surface.
1570 *
1571 * This function maps the RGBA color value to the specified pixel format and
1572 * returns the pixel value best approximating the given RGBA color value for
1573 * the given pixel format.
1574 *
1575 * If the surface pixel format has no alpha component the alpha value will be
1576 * ignored (as it will be in formats with a palette).
1577 *
1578 * If the surface has a palette, the index of the closest matching color in
1579 * the palette will be returned.
1580 *
1581 * If the pixel format bpp (color depth) is less than 32-bpp then the unused
1582 * upper bits of the return value can safely be ignored (e.g., with a 16-bpp
1583 * format the return value can be assigned to a Uint16, and similarly a Uint8
1584 * for an 8-bpp format).
1585 *
1586 * \param surface the surface to use for the pixel format and palette.
1587 * \param r the red component of the pixel in the range 0-255.
1588 * \param g the green component of the pixel in the range 0-255.
1589 * \param b the blue component of the pixel in the range 0-255.
1590 * \param a the alpha component of the pixel in the range 0-255.
1591 * \returns a pixel value.
1592 *
1593 * \threadsafety This function can be called on different threads with
1594 * different surfaces.
1595 *
1596 * \since This function is available since SDL 3.2.0.
1597 *
1598 * \sa SDL_MapSurfaceRGB
1599 */
1600extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapSurfaceRGBA(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
1601
1602/**
1603 * Retrieves a single pixel from a surface.
1604 *
1605 * This function prioritizes correctness over speed: it is suitable for unit
1606 * tests, but is not intended for use in a game engine.
1607 *
1608 * Like SDL_GetRGBA, this uses the entire 0..255 range when converting color
1609 * components from pixel formats with less than 8 bits per RGB component.
1610 *
1611 * \param surface the surface to read.
1612 * \param x the horizontal coordinate, 0 <= x < width.
1613 * \param y the vertical coordinate, 0 <= y < height.
1614 * \param r a pointer filled in with the red channel, 0-255, or NULL to ignore
1615 * this channel.
1616 * \param g a pointer filled in with the green channel, 0-255, or NULL to
1617 * ignore this channel.
1618 * \param b a pointer filled in with the blue channel, 0-255, or NULL to
1619 * ignore this channel.
1620 * \param a a pointer filled in with the alpha channel, 0-255, or NULL to
1621 * ignore this channel.
1622 * \returns true on success or false on failure; call SDL_GetError() for more
1623 * information.
1624 *
1625 * \threadsafety This function can be called on different threads with
1626 * different surfaces.
1627 *
1628 * \since This function is available since SDL 3.2.0.
1629 */
1630extern SDL_DECLSPEC bool SDLCALL SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
1631
1632/**
1633 * Retrieves a single pixel from a surface.
1634 *
1635 * This function prioritizes correctness over speed: it is suitable for unit
1636 * tests, but is not intended for use in a game engine.
1637 *
1638 * \param surface the surface to read.
1639 * \param x the horizontal coordinate, 0 <= x < width.
1640 * \param y the vertical coordinate, 0 <= y < height.
1641 * \param r a pointer filled in with the red channel, normally in the range
1642 * 0-1, or NULL to ignore this channel.
1643 * \param g a pointer filled in with the green channel, normally in the range
1644 * 0-1, or NULL to ignore this channel.
1645 * \param b a pointer filled in with the blue channel, normally in the range
1646 * 0-1, or NULL to ignore this channel.
1647 * \param a a pointer filled in with the alpha channel, normally in the range
1648 * 0-1, or NULL to ignore this channel.
1649 * \returns true on success or false on failure; call SDL_GetError() for more
1650 * information.
1651 *
1652 * \threadsafety This function can be called on different threads with
1653 * different surfaces.
1654 *
1655 * \since This function is available since SDL 3.2.0.
1656 */
1657extern SDL_DECLSPEC bool SDLCALL SDL_ReadSurfacePixelFloat(SDL_Surface *surface, int x, int y, float *r, float *g, float *b, float *a);
1658
1659/**
1660 * Writes a single pixel to a surface.
1661 *
1662 * This function prioritizes correctness over speed: it is suitable for unit
1663 * tests, but is not intended for use in a game engine.
1664 *
1665 * Like SDL_MapRGBA, this uses the entire 0..255 range when converting color
1666 * components from pixel formats with less than 8 bits per RGB component.
1667 *
1668 * \param surface the surface to write.
1669 * \param x the horizontal coordinate, 0 <= x < width.
1670 * \param y the vertical coordinate, 0 <= y < height.
1671 * \param r the red channel value, 0-255.
1672 * \param g the green channel value, 0-255.
1673 * \param b the blue channel value, 0-255.
1674 * \param a the alpha channel value, 0-255.
1675 * \returns true on success or false on failure; call SDL_GetError() for more
1676 * information.
1677 *
1678 * \threadsafety This function can be called on different threads with
1679 * different surfaces.
1680 *
1681 * \since This function is available since SDL 3.2.0.
1682 */
1683extern SDL_DECLSPEC bool SDLCALL SDL_WriteSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
1684
1685/**
1686 * Writes a single pixel to a surface.
1687 *
1688 * This function prioritizes correctness over speed: it is suitable for unit
1689 * tests, but is not intended for use in a game engine.
1690 *
1691 * \param surface the surface to write.
1692 * \param x the horizontal coordinate, 0 <= x < width.
1693 * \param y the vertical coordinate, 0 <= y < height.
1694 * \param r the red channel value, normally in the range 0-1.
1695 * \param g the green channel value, normally in the range 0-1.
1696 * \param b the blue channel value, normally in the range 0-1.
1697 * \param a the alpha channel value, normally in the range 0-1.
1698 * \returns true on success or false on failure; call SDL_GetError() for more
1699 * information.
1700 *
1701 * \threadsafety This function can be called on different threads with
1702 * different surfaces.
1703 *
1704 * \since This function is available since SDL 3.2.0.
1705 */
1706extern SDL_DECLSPEC bool SDLCALL SDL_WriteSurfacePixelFloat(SDL_Surface *surface, int x, int y, float r, float g, float b, float a);
1707
1708/* Ends C function definitions when using C++ */
1709#ifdef __cplusplus
1710}
1711#endif
1712#include <SDL3/SDL_close_code.h>
1713
1714#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