SDL_surface.h 61 KB

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