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