SDL_surface.h 61 KB

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