SDL_surface.h 61 KB

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