SDL_surface.h 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 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_Surface definition and management functions.
  22. */
  23. #ifndef SDL_surface_h_
  24. #define SDL_surface_h_
  25. #include <SDL3/SDL_stdinc.h>
  26. #include <SDL3/SDL_error.h>
  27. #include <SDL3/SDL_blendmode.h>
  28. #include <SDL3/SDL_pixels.h>
  29. #include <SDL3/SDL_properties.h>
  30. #include <SDL3/SDL_rect.h>
  31. #include <SDL3/SDL_iostream.h>
  32. #include <SDL3/SDL_begin_code.h>
  33. /* Set up for C function definitions, even when using C++ */
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. /**
  38. * The flags on an SDL_Surface.
  39. *
  40. * These are generally meant to be considered read-only.
  41. *
  42. * \since This datatype is available since SDL 3.0.0.
  43. */
  44. typedef Uint32 SDL_SurfaceFlags;
  45. #define SDL_PREALLOC 0x00000001u /**< Surface uses preallocated memory */
  46. #define SDL_RLEACCEL 0x00000002u /**< Surface is RLE encoded */
  47. #define SDL_DONTFREE 0x00000004u /**< Surface is referenced internally */
  48. #define SDL_SIMD_ALIGNED 0x00000008u /**< Surface uses aligned memory */
  49. #define SDL_SURFACE_USES_PROPERTIES 0x00000010u /**< Surface uses properties */
  50. /**
  51. * Evaluates to true if the surface needs to be locked before access.
  52. *
  53. * \since This macro is available since SDL 3.0.0.
  54. */
  55. #define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0)
  56. /**
  57. * An opaque type used in SDL_Surface.
  58. *
  59. * This is used by SDL to keep track of how blit operations should work
  60. * internally; it is not for use directly by applications.
  61. *
  62. * \since This struct is available since SDL 3.0.0.
  63. */
  64. typedef struct SDL_BlitMap SDL_BlitMap;
  65. /**
  66. * The scaling mode.
  67. *
  68. * \since This enum is available since SDL 3.0.0.
  69. */
  70. typedef enum SDL_ScaleMode
  71. {
  72. SDL_SCALEMODE_NEAREST, /**< nearest pixel sampling */
  73. SDL_SCALEMODE_LINEAR, /**< linear filtering */
  74. SDL_SCALEMODE_BEST /**< anisotropic filtering */
  75. } SDL_ScaleMode;
  76. /**
  77. * The flip mode.
  78. *
  79. * \since This enum is available since SDL 3.0.0.
  80. */
  81. typedef enum SDL_FlipMode
  82. {
  83. SDL_FLIP_NONE, /**< Do not flip */
  84. SDL_FLIP_HORIZONTAL, /**< flip horizontally */
  85. SDL_FLIP_VERTICAL /**< flip vertically */
  86. } SDL_FlipMode;
  87. /**
  88. * A collection of pixels used in software blitting.
  89. *
  90. * Pixels are arranged in memory in rows, with the top row first. Each row
  91. * occupies an amount of memory given by the pitch (sometimes known as the row
  92. * stride in non-SDL APIs).
  93. *
  94. * Within each row, pixels are arranged from left to right until the width is
  95. * reached. Each pixel occupies a number of bits appropriate for its format,
  96. * with most formats representing each pixel as one or more whole bytes (in
  97. * some indexed formats, instead multiple pixels are packed into each byte),
  98. * and a byte order given by the format. After encoding all pixels, any
  99. * remaining bytes to reach the pitch are used as padding to reach a desired
  100. * alignment, and have undefined contents.
  101. *
  102. * \since This struct is available since SDL 3.0.0.
  103. */
  104. typedef struct SDL_Surface
  105. {
  106. SDL_SurfaceFlags flags; /**< Read-only */
  107. SDL_PixelFormat *format; /**< Read-only */
  108. int w, h; /**< Read-only */
  109. int pitch; /**< Read-only */
  110. void *pixels; /**< Read-write */
  111. void *reserved; /**< Private */
  112. /** information needed for surfaces requiring locks */
  113. int locked; /**< Read-only */
  114. /** list of BlitMap that hold a reference to this surface */
  115. void *list_blitmap; /**< Private */
  116. /** clipping information */
  117. SDL_Rect clip_rect; /**< Read-only */
  118. /** info for fast blit mapping to other surfaces */
  119. SDL_BlitMap *map; /**< Private */
  120. /** Reference count -- used when freeing surface */
  121. int refcount; /**< Read-mostly */
  122. } SDL_Surface;
  123. /**
  124. * Allocate a new RGB surface with a specific pixel format.
  125. *
  126. * \param width the width of the surface.
  127. * \param height the height of the surface.
  128. * \param format the SDL_PixelFormatEnum for the new surface's pixel format.
  129. * \returns the new SDL_Surface structure that is created or NULL if it fails;
  130. * call SDL_GetError() for more information.
  131. *
  132. * \since This function is available since SDL 3.0.0.
  133. *
  134. * \sa SDL_CreateSurfaceFrom
  135. * \sa SDL_DestroySurface
  136. */
  137. extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_CreateSurface(int width, int height, SDL_PixelFormatEnum format);
  138. /**
  139. * Allocate a new RGB surface with a specific pixel format and existing pixel
  140. * data.
  141. *
  142. * No copy is made of the pixel data. Pixel data is not managed automatically;
  143. * you must free the surface before you free the pixel data.
  144. *
  145. * Pitch is the offset in bytes from one row of pixels to the next, e.g.
  146. * `width*4` for `SDL_PIXELFORMAT_RGBA8888`.
  147. *
  148. * You may pass NULL for pixels and 0 for pitch to create a surface that you
  149. * will fill in with valid values later.
  150. *
  151. * \param pixels a pointer to existing pixel data.
  152. * \param width the width of the surface.
  153. * \param height the height of the surface.
  154. * \param pitch the number of bytes between each row, including padding.
  155. * \param format the SDL_PixelFormatEnum for the new surface's pixel format.
  156. * \returns the new SDL_Surface structure that is created or NULL if it fails;
  157. * call SDL_GetError() for more information.
  158. *
  159. * \since This function is available since SDL 3.0.0.
  160. *
  161. * \sa SDL_CreateSurface
  162. * \sa SDL_DestroySurface
  163. */
  164. extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_CreateSurfaceFrom(void *pixels, int width, int height, int pitch, SDL_PixelFormatEnum format);
  165. /**
  166. * Free an RGB surface.
  167. *
  168. * It is safe to pass NULL to this function.
  169. *
  170. * \param surface the SDL_Surface to free.
  171. *
  172. * \since This function is available since SDL 3.0.0.
  173. *
  174. * \sa SDL_CreateSurface
  175. * \sa SDL_CreateSurfaceFrom
  176. */
  177. extern SDL_DECLSPEC void SDLCALL SDL_DestroySurface(SDL_Surface *surface);
  178. /**
  179. * Get the properties associated with a surface.
  180. *
  181. * The following properties are understood by SDL:
  182. *
  183. * - `SDL_PROP_SURFACE_COLORSPACE_NUMBER`: an SDL_ColorSpace value describing
  184. * the surface colorspace, defaults to SDL_COLORSPACE_SRGB_LINEAR for
  185. * floating point formats, SDL_COLORSPACE_HDR10 for 10-bit formats,
  186. * SDL_COLORSPACE_SRGB for other RGB surfaces and SDL_COLORSPACE_BT709_FULL
  187. * for YUV surfaces.
  188. * - `SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating point
  189. * surfaces, this defines the value of 100% diffuse white, with higher
  190. * values being displayed in the High Dynamic Range headroom. This defaults
  191. * to 203 for HDR10 surfaces and 1.0 for floating point surfaces.
  192. * - `SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT`: for HDR10 and floating point
  193. * surfaces, this defines the maximum dynamic range used by the content, in
  194. * terms of the SDR white point. This defaults to 0.0, which disables tone
  195. * mapping.
  196. * - `SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING`: the tone mapping operator
  197. * used when compressing from a surface with high dynamic range to another
  198. * with lower dynamic range. Currently this supports "chrome", which uses
  199. * the same tone mapping that Chrome uses for HDR content, the form "*=N",
  200. * where N is a floating point scale factor applied in linear space, and
  201. * "none", which disables tone mapping. This defaults to "chrome".
  202. *
  203. * \param surface the SDL_Surface structure to query.
  204. * \returns a valid property ID on success or 0 on failure; call
  205. * SDL_GetError() for more information.
  206. *
  207. * \since This function is available since SDL 3.0.0.
  208. *
  209. * \sa SDL_GetProperty
  210. * \sa SDL_SetProperty
  211. */
  212. extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSurfaceProperties(SDL_Surface *surface);
  213. #define SDL_PROP_SURFACE_COLORSPACE_NUMBER "SDL.surface.colorspace"
  214. #define SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT "SDL.surface.SDR_white_point"
  215. #define SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT "SDL.surface.HDR_headroom"
  216. #define SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING "SDL.surface.tonemap"
  217. /**
  218. * Set the colorspace used by a surface.
  219. *
  220. * Setting the colorspace doesn't change the pixels, only how they are
  221. * interpreted in color operations.
  222. *
  223. * \param surface the SDL_Surface structure to update.
  224. * \param colorspace an SDL_ColorSpace value describing the surface
  225. * colorspace.
  226. * \returns 0 on success or a negative error code on failure; call
  227. * SDL_GetError() for more information.
  228. *
  229. * \since This function is available since SDL 3.0.0.
  230. */
  231. extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceColorspace(SDL_Surface *surface, SDL_Colorspace colorspace);
  232. /**
  233. * Get the colorspace used by a surface.
  234. *
  235. * The colorspace defaults to SDL_COLORSPACE_SRGB_LINEAR for floating point
  236. * formats, SDL_COLORSPACE_HDR10 for 10-bit formats, SDL_COLORSPACE_SRGB for
  237. * other RGB surfaces and SDL_COLORSPACE_BT709_FULL for YUV textures.
  238. *
  239. * \param surface the SDL_Surface structure to query.
  240. * \param colorspace a pointer filled in with an SDL_ColorSpace value
  241. * describing the surface colorspace.
  242. * \returns 0 on success or a negative error code on failure; call
  243. * SDL_GetError() for more information.
  244. *
  245. * \since This function is available since SDL 3.0.0.
  246. */
  247. extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceColorspace(SDL_Surface *surface, SDL_Colorspace *colorspace);
  248. /**
  249. * Set the palette used by a surface.
  250. *
  251. * A single palette can be shared with many surfaces.
  252. *
  253. * \param surface the SDL_Surface structure to update.
  254. * \param palette the SDL_Palette structure to use.
  255. * \returns 0 on success or a negative error code on failure; call
  256. * SDL_GetError() for more information.
  257. *
  258. * \since This function is available since SDL 3.0.0.
  259. */
  260. extern SDL_DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette);
  261. /**
  262. * Set up a surface for directly accessing the pixels.
  263. *
  264. * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write to
  265. * and read from `surface->pixels`, using the pixel format stored in
  266. * `surface->format`. Once you are done accessing the surface, you should use
  267. * SDL_UnlockSurface() to release it.
  268. *
  269. * Not all surfaces require locking. If `SDL_MUSTLOCK(surface)` evaluates to
  270. * 0, then you can read and write to the surface at any time, and the pixel
  271. * format of the surface will not change.
  272. *
  273. * \param surface the SDL_Surface structure to be locked.
  274. * \returns 0 on success or a negative error code on failure; call
  275. * SDL_GetError() for more information.
  276. *
  277. * \since This function is available since SDL 3.0.0.
  278. *
  279. * \sa SDL_MUSTLOCK
  280. * \sa SDL_UnlockSurface
  281. */
  282. extern SDL_DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface *surface);
  283. /**
  284. * Release a surface after directly accessing the pixels.
  285. *
  286. * \param surface the SDL_Surface structure to be unlocked.
  287. *
  288. * \since This function is available since SDL 3.0.0.
  289. *
  290. * \sa SDL_LockSurface
  291. */
  292. extern SDL_DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface);
  293. /**
  294. * Load a BMP image from a seekable SDL data stream.
  295. *
  296. * The new surface should be freed with SDL_DestroySurface(). Not doing so
  297. * will result in a memory leak.
  298. *
  299. * \param src the data stream for the surface.
  300. * \param closeio if SDL_TRUE, calls SDL_CloseIO() on `src` before returning,
  301. * even in the case of an error.
  302. * \returns a pointer to a new SDL_Surface structure or NULL if there was an
  303. * error; call SDL_GetError() for more information.
  304. *
  305. * \since This function is available since SDL 3.0.0.
  306. *
  307. * \sa SDL_DestroySurface
  308. * \sa SDL_LoadBMP
  309. * \sa SDL_SaveBMP_IO
  310. */
  311. extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio);
  312. /**
  313. * Load a BMP image from a file.
  314. *
  315. * The new surface should be freed with SDL_DestroySurface(). Not doing so
  316. * will result in a memory leak.
  317. *
  318. * \param file the BMP file to load.
  319. * \returns a pointer to a new SDL_Surface structure or NULL if there was an
  320. * error; call SDL_GetError() for more information.
  321. *
  322. * \since This function is available since SDL 3.0.0.
  323. *
  324. * \sa SDL_DestroySurface
  325. * \sa SDL_LoadBMP_IO
  326. * \sa SDL_SaveBMP
  327. */
  328. extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP(const char *file);
  329. /**
  330. * Save a surface to a seekable SDL data stream in BMP format.
  331. *
  332. * Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the
  333. * BMP directly. Other RGB formats with 8-bit or higher get converted to a
  334. * 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit
  335. * surface before they are saved. YUV and paletted 1-bit and 4-bit formats are
  336. * not supported.
  337. *
  338. * \param surface the SDL_Surface structure containing the image to be saved.
  339. * \param dst a data stream to save to.
  340. * \param closeio if SDL_TRUE, calls SDL_CloseIO() on `dst` before returning,
  341. * even in the case of an error.
  342. * \returns 0 on success or a negative error code on failure; call
  343. * SDL_GetError() for more information.
  344. *
  345. * \since This function is available since SDL 3.0.0.
  346. *
  347. * \sa SDL_LoadBMP_IO
  348. * \sa SDL_SaveBMP
  349. */
  350. extern SDL_DECLSPEC int SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio);
  351. /**
  352. * Save a surface to a file.
  353. *
  354. * Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the
  355. * BMP directly. Other RGB formats with 8-bit or higher get converted to a
  356. * 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit
  357. * surface before they are saved. YUV and paletted 1-bit and 4-bit formats are
  358. * not supported.
  359. *
  360. * \param surface the SDL_Surface structure containing the image to be saved.
  361. * \param file a file to save to.
  362. * \returns 0 on success or a negative error code on failure; call
  363. * SDL_GetError() for more information.
  364. *
  365. * \since This function is available since SDL 3.0.0.
  366. *
  367. * \sa SDL_LoadBMP
  368. * \sa SDL_SaveBMP_IO
  369. */
  370. extern SDL_DECLSPEC int SDLCALL SDL_SaveBMP(SDL_Surface *surface, const char *file);
  371. /**
  372. * Set the RLE acceleration hint for a surface.
  373. *
  374. * If RLE is enabled, color key and alpha blending blits are much faster, but
  375. * the surface must be locked before directly accessing the pixels.
  376. *
  377. * \param surface the SDL_Surface structure to optimize.
  378. * \param flag 0 to disable, non-zero to enable RLE acceleration.
  379. * \returns 0 on success or a negative error code on failure; call
  380. * SDL_GetError() for more information.
  381. *
  382. * \since This function is available since SDL 3.0.0.
  383. *
  384. * \sa SDL_BlitSurface
  385. * \sa SDL_LockSurface
  386. * \sa SDL_UnlockSurface
  387. */
  388. extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface, int flag);
  389. /**
  390. * Returns whether the surface is RLE enabled.
  391. *
  392. * It is safe to pass a NULL `surface` here; it will return SDL_FALSE.
  393. *
  394. * \param surface the SDL_Surface structure to query.
  395. * \returns SDL_TRUE if the surface is RLE enabled, SDL_FALSE otherwise.
  396. *
  397. * \since This function is available since SDL 3.0.0.
  398. *
  399. * \sa SDL_SetSurfaceRLE
  400. */
  401. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SurfaceHasRLE(SDL_Surface *surface);
  402. /**
  403. * Set the color key (transparent pixel) in a surface.
  404. *
  405. * The color key defines a pixel value that will be treated as transparent in
  406. * a blit. For example, one can use this to specify that cyan pixels should be
  407. * considered transparent, and therefore not rendered.
  408. *
  409. * It is a pixel of the format used by the surface, as generated by
  410. * SDL_MapRGB().
  411. *
  412. * RLE acceleration can substantially speed up blitting of images with large
  413. * horizontal runs of transparent pixels. See SDL_SetSurfaceRLE() for details.
  414. *
  415. * \param surface the SDL_Surface structure to update.
  416. * \param flag SDL_TRUE to enable color key, SDL_FALSE to disable color key.
  417. * \param key the transparent pixel.
  418. * \returns 0 on success or a negative error code on failure; call
  419. * SDL_GetError() for more information.
  420. *
  421. * \since This function is available since SDL 3.0.0.
  422. *
  423. * \sa SDL_GetSurfaceColorKey
  424. * \sa SDL_SurfaceHasColorKey
  425. */
  426. extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceColorKey(SDL_Surface *surface, int flag, Uint32 key);
  427. /**
  428. * Returns whether the surface has a color key.
  429. *
  430. * It is safe to pass a NULL `surface` here; it will return SDL_FALSE.
  431. *
  432. * \param surface the SDL_Surface structure to query.
  433. * \returns SDL_TRUE if the surface has a color key, SDL_FALSE otherwise.
  434. *
  435. * \since This function is available since SDL 3.0.0.
  436. *
  437. * \sa SDL_SetSurfaceColorKey
  438. * \sa SDL_GetSurfaceColorKey
  439. */
  440. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SurfaceHasColorKey(SDL_Surface *surface);
  441. /**
  442. * Get the color key (transparent pixel) for a surface.
  443. *
  444. * The color key is a pixel of the format used by the surface, as generated by
  445. * SDL_MapRGB().
  446. *
  447. * If the surface doesn't have color key enabled this function returns -1.
  448. *
  449. * \param surface the SDL_Surface structure to query.
  450. * \param key a pointer filled in with the transparent pixel.
  451. * \returns 0 on success or a negative error code on failure; call
  452. * SDL_GetError() for more information.
  453. *
  454. * \since This function is available since SDL 3.0.0.
  455. *
  456. * \sa SDL_SetSurfaceColorKey
  457. * \sa SDL_SurfaceHasColorKey
  458. */
  459. extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceColorKey(SDL_Surface *surface, Uint32 *key);
  460. /**
  461. * Set an additional color value multiplied into blit operations.
  462. *
  463. * When this surface is blitted, during the blit operation each source color
  464. * channel is modulated by the appropriate color value according to the
  465. * following formula:
  466. *
  467. * `srcC = srcC * (color / 255)`
  468. *
  469. * \param surface the SDL_Surface structure to update.
  470. * \param r the red color value multiplied into blit operations.
  471. * \param g the green color value multiplied into blit operations.
  472. * \param b the blue color value multiplied into blit operations.
  473. * \returns 0 on success or a negative error code on failure; call
  474. * SDL_GetError() for more information.
  475. *
  476. * \since This function is available since SDL 3.0.0.
  477. *
  478. * \sa SDL_GetSurfaceColorMod
  479. * \sa SDL_SetSurfaceAlphaMod
  480. */
  481. extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b);
  482. /**
  483. * Get the additional color value multiplied into blit operations.
  484. *
  485. * \param surface the SDL_Surface structure to query.
  486. * \param r a pointer filled in with the current red color value.
  487. * \param g a pointer filled in with the current green color value.
  488. * \param b a pointer filled in with the current blue color value.
  489. * \returns 0 on success or a negative error code on failure; call
  490. * SDL_GetError() for more information.
  491. *
  492. * \since This function is available since SDL 3.0.0.
  493. *
  494. * \sa SDL_GetSurfaceAlphaMod
  495. * \sa SDL_SetSurfaceColorMod
  496. */
  497. extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b);
  498. /**
  499. * Set an additional alpha value used in blit operations.
  500. *
  501. * When this surface is blitted, during the blit operation the source alpha
  502. * value is modulated by this alpha value according to the following formula:
  503. *
  504. * `srcA = srcA * (alpha / 255)`
  505. *
  506. * \param surface the SDL_Surface structure to update.
  507. * \param alpha the alpha value multiplied into blit operations.
  508. * \returns 0 on success or a negative error code on failure; call
  509. * SDL_GetError() for more information.
  510. *
  511. * \since This function is available since SDL 3.0.0.
  512. *
  513. * \sa SDL_GetSurfaceAlphaMod
  514. * \sa SDL_SetSurfaceColorMod
  515. */
  516. extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha);
  517. /**
  518. * Get the additional alpha value used in blit operations.
  519. *
  520. * \param surface the SDL_Surface structure to query.
  521. * \param alpha a pointer filled in with the current alpha value.
  522. * \returns 0 on success or a negative error code on failure; call
  523. * SDL_GetError() for more information.
  524. *
  525. * \since This function is available since SDL 3.0.0.
  526. *
  527. * \sa SDL_GetSurfaceColorMod
  528. * \sa SDL_SetSurfaceAlphaMod
  529. */
  530. extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha);
  531. /**
  532. * Set the blend mode used for blit operations.
  533. *
  534. * To copy a surface to another surface (or texture) without blending with the
  535. * existing data, the blendmode of the SOURCE surface should be set to
  536. * `SDL_BLENDMODE_NONE`.
  537. *
  538. * \param surface the SDL_Surface structure to update.
  539. * \param blendMode the SDL_BlendMode to use for blit blending.
  540. * \returns 0 on success or a negative error code on failure; call
  541. * SDL_GetError() for more information.
  542. *
  543. * \since This function is available since SDL 3.0.0.
  544. *
  545. * \sa SDL_GetSurfaceBlendMode
  546. */
  547. extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode);
  548. /**
  549. * Get the blend mode used for blit operations.
  550. *
  551. * \param surface the SDL_Surface structure to query.
  552. * \param blendMode a pointer filled in with the current SDL_BlendMode.
  553. * \returns 0 on success or a negative error code on failure; call
  554. * SDL_GetError() for more information.
  555. *
  556. * \since This function is available since SDL 3.0.0.
  557. *
  558. * \sa SDL_SetSurfaceBlendMode
  559. */
  560. extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode);
  561. /**
  562. * Set the clipping rectangle for a surface.
  563. *
  564. * When `surface` is the destination of a blit, only the area within the clip
  565. * rectangle is drawn into.
  566. *
  567. * Note that blits are automatically clipped to the edges of the source and
  568. * destination surfaces.
  569. *
  570. * \param surface the SDL_Surface structure to be clipped.
  571. * \param rect the SDL_Rect structure representing the clipping rectangle, or
  572. * NULL to disable clipping.
  573. * \returns SDL_TRUE if the rectangle intersects the surface, otherwise
  574. * SDL_FALSE and blits will be completely clipped.
  575. *
  576. * \since This function is available since SDL 3.0.0.
  577. *
  578. * \sa SDL_GetSurfaceClipRect
  579. */
  580. extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetSurfaceClipRect(SDL_Surface *surface, const SDL_Rect *rect);
  581. /**
  582. * Get the clipping rectangle for a surface.
  583. *
  584. * When `surface` is the destination of a blit, only the area within the clip
  585. * rectangle is drawn into.
  586. *
  587. * \param surface the SDL_Surface structure representing the surface to be
  588. * clipped.
  589. * \param rect an SDL_Rect structure filled in with the clipping rectangle for
  590. * the surface.
  591. * \returns 0 on success or a negative error code on failure; call
  592. * SDL_GetError() for more information.
  593. *
  594. * \since This function is available since SDL 3.0.0.
  595. *
  596. * \sa SDL_SetSurfaceClipRect
  597. */
  598. extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceClipRect(SDL_Surface *surface, SDL_Rect *rect);
  599. /**
  600. * Flip a surface vertically or horizontally.
  601. *
  602. * \param surface the surface to flip.
  603. * \param flip the direction to flip.
  604. * \returns 0 on success or a negative error code on failure; call
  605. * SDL_GetError() for more information.
  606. *
  607. * \since This function is available since SDL 3.0.0.
  608. */
  609. extern SDL_DECLSPEC int SDLCALL SDL_FlipSurface(SDL_Surface *surface, SDL_FlipMode flip);
  610. /**
  611. * Creates a new surface identical to the existing surface.
  612. *
  613. * The returned surface should be freed with SDL_DestroySurface().
  614. *
  615. * \param surface the surface to duplicate.
  616. * \returns a copy of the surface, or NULL on failure; call SDL_GetError() for
  617. * more information.
  618. *
  619. * \since This function is available since SDL 3.0.0.
  620. *
  621. * \sa SDL_DestroySurface
  622. */
  623. extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface *surface);
  624. /**
  625. * Copy an existing surface to a new surface of the specified format.
  626. *
  627. * This function is used to optimize images for faster *repeat* blitting. This
  628. * is accomplished by converting the original and storing the result as a new
  629. * surface. The new, optimized surface can then be used as the source for
  630. * future blits, making them faster.
  631. *
  632. * \param surface the existing SDL_Surface structure to convert.
  633. * \param format the SDL_PixelFormat structure that the new surface is
  634. * optimized for.
  635. * \returns the new SDL_Surface structure that is created or NULL if it fails;
  636. * call SDL_GetError() for more information.
  637. *
  638. * \since This function is available since SDL 3.0.0.
  639. *
  640. * \sa SDL_ConvertSurfaceFormat
  641. * \sa SDL_ConvertSurfaceFormatAndColorspace
  642. * \sa SDL_CreatePixelFormat
  643. * \sa SDL_DestroySurface
  644. */
  645. extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface(SDL_Surface *surface, const SDL_PixelFormat *format);
  646. /**
  647. * Copy an existing surface to a new surface of the specified format.
  648. *
  649. * This function operates just like SDL_ConvertSurface(), but accepts an
  650. * SDL_PixelFormatEnum value instead of an SDL_PixelFormat structure. As such,
  651. * it might be easier to call but it doesn't have access to palette
  652. * information for the destination surface, in case that would be important.
  653. *
  654. * \param surface the existing SDL_Surface structure to convert.
  655. * \param pixel_format the new pixel format.
  656. * \returns the new SDL_Surface structure that is created or NULL if it fails;
  657. * call SDL_GetError() for more information.
  658. *
  659. * \since This function is available since SDL 3.0.0.
  660. *
  661. * \sa SDL_ConvertSurface
  662. * \sa SDL_ConvertSurfaceFormatAndColorspace
  663. * \sa SDL_DestroySurface
  664. */
  665. extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat(SDL_Surface *surface, SDL_PixelFormatEnum pixel_format);
  666. /**
  667. * Copy an existing surface to a new surface of the specified format and
  668. * colorspace.
  669. *
  670. * This function converts an existing surface to a new format and colorspace
  671. * and returns the new surface. This will perform any pixel format and
  672. * colorspace conversion needed.
  673. *
  674. * \param surface the existing SDL_Surface structure to convert.
  675. * \param pixel_format the new pixel format.
  676. * \param colorspace the new colorspace.
  677. * \param props an SDL_PropertiesID with additional color properties, or 0.
  678. * \returns the new SDL_Surface structure that is created or NULL if it fails;
  679. * call SDL_GetError() for more information.
  680. *
  681. * \since This function is available since SDL 3.0.0.
  682. *
  683. * \sa SDL_ConvertSurface
  684. * \sa SDL_ConvertSurfaceFormat
  685. * \sa SDL_DestroySurface
  686. */
  687. extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormatAndColorspace(SDL_Surface *surface, SDL_PixelFormatEnum pixel_format, SDL_Colorspace colorspace, SDL_PropertiesID props);
  688. /**
  689. * Copy a block of pixels of one format to another format.
  690. *
  691. * \param width the width of the block to copy, in pixels.
  692. * \param height the height of the block to copy, in pixels.
  693. * \param src_format an SDL_PixelFormatEnum value of the `src` pixels format.
  694. * \param src a pointer to the source pixels.
  695. * \param src_pitch the pitch of the source pixels, in bytes.
  696. * \param dst_format an SDL_PixelFormatEnum value of the `dst` pixels format.
  697. * \param dst a pointer to be filled in with new pixel data.
  698. * \param dst_pitch the pitch of the destination pixels, in bytes.
  699. * \returns 0 on success or a negative error code on failure; call
  700. * SDL_GetError() for more information.
  701. *
  702. * \since This function is available since SDL 3.0.0.
  703. *
  704. * \sa SDL_ConvertPixelsAndColorspace
  705. */
  706. extern SDL_DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, SDL_PixelFormatEnum src_format, const void *src, int src_pitch, SDL_PixelFormatEnum dst_format, void *dst, int dst_pitch);
  707. /**
  708. * Copy a block of pixels of one format and colorspace to another format and
  709. * colorspace.
  710. *
  711. * \param width the width of the block to copy, in pixels.
  712. * \param height the height of the block to copy, in pixels.
  713. * \param src_format an SDL_PixelFormatEnum value of the `src` pixels format.
  714. * \param src_colorspace an SDL_ColorSpace value describing the colorspace of
  715. * the `src` pixels.
  716. * \param src_properties an SDL_PropertiesID with additional source color
  717. * properties, or 0.
  718. * \param src a pointer to the source pixels.
  719. * \param src_pitch the pitch of the source pixels, in bytes.
  720. * \param dst_format an SDL_PixelFormatEnum value of the `dst` pixels format.
  721. * \param dst_colorspace an SDL_ColorSpace value describing the colorspace of
  722. * the `dst` pixels.
  723. * \param dst_properties an SDL_PropertiesID with additional destination color
  724. * properties, or 0.
  725. * \param dst a pointer to be filled in with new pixel data.
  726. * \param dst_pitch the pitch of the destination pixels, in bytes.
  727. * \returns 0 on success or a negative error code on failure; call
  728. * SDL_GetError() for more information.
  729. *
  730. * \since This function is available since SDL 3.0.0.
  731. *
  732. * \sa SDL_ConvertPixels
  733. */
  734. extern SDL_DECLSPEC int SDLCALL SDL_ConvertPixelsAndColorspace(int width, int height, SDL_PixelFormatEnum src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormatEnum dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
  735. /**
  736. * Premultiply the alpha on a block of pixels.
  737. *
  738. * This is safe to use with src == dst, but not for other overlapping areas.
  739. *
  740. * This function is currently only implemented for SDL_PIXELFORMAT_ARGB8888.
  741. *
  742. * \param width the width of the block to convert, in pixels.
  743. * \param height the height of the block to convert, in pixels.
  744. * \param src_format an SDL_PixelFormatEnum value of the `src` pixels format.
  745. * \param src a pointer to the source pixels.
  746. * \param src_pitch the pitch of the source pixels, in bytes.
  747. * \param dst_format an SDL_PixelFormatEnum value of the `dst` pixels format.
  748. * \param dst a pointer to be filled in with premultiplied pixel data.
  749. * \param dst_pitch the pitch of the destination pixels, in bytes.
  750. * \returns 0 on success or a negative error code on failure; call
  751. * SDL_GetError() for more information.
  752. *
  753. * \since This function is available since SDL 3.0.0.
  754. */
  755. extern SDL_DECLSPEC int SDLCALL SDL_PremultiplyAlpha(int width, int height, SDL_PixelFormatEnum src_format, const void *src, int src_pitch, SDL_PixelFormatEnum dst_format, void *dst, int dst_pitch);
  756. /**
  757. * Perform a fast fill of a rectangle with a specific color.
  758. *
  759. * `color` should be a pixel of the format used by the surface, and can be
  760. * generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an
  761. * alpha component then the destination is simply filled with that alpha
  762. * information, no blending takes place.
  763. *
  764. * If there is a clip rectangle set on the destination (set via
  765. * SDL_SetSurfaceClipRect()), then this function will fill based on the
  766. * intersection of the clip rectangle and `rect`.
  767. *
  768. * \param dst the SDL_Surface structure that is the drawing target.
  769. * \param rect the SDL_Rect structure representing the rectangle to fill, or
  770. * NULL to fill the entire surface.
  771. * \param color the color to fill with.
  772. * \returns 0 on success or a negative error code on failure; call
  773. * SDL_GetError() for more information.
  774. *
  775. * \since This function is available since SDL 3.0.0.
  776. *
  777. * \sa SDL_FillSurfaceRects
  778. */
  779. extern SDL_DECLSPEC int SDLCALL SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color);
  780. /**
  781. * Perform a fast fill of a set of rectangles with a specific color.
  782. *
  783. * `color` should be a pixel of the format used by the surface, and can be
  784. * generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an
  785. * alpha component then the destination is simply filled with that alpha
  786. * information, no blending takes place.
  787. *
  788. * If there is a clip rectangle set on the destination (set via
  789. * SDL_SetSurfaceClipRect()), then this function will fill based on the
  790. * intersection of the clip rectangle and `rect`.
  791. *
  792. * \param dst the SDL_Surface structure that is the drawing target.
  793. * \param rects an array of SDL_Rects representing the rectangles to fill.
  794. * \param count the number of rectangles in the array.
  795. * \param color the color to fill with.
  796. * \returns 0 on success or a negative error code on failure; call
  797. * SDL_GetError() for more information.
  798. *
  799. * \since This function is available since SDL 3.0.0.
  800. *
  801. * \sa SDL_FillSurfaceRect
  802. */
  803. extern SDL_DECLSPEC int SDLCALL SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color);
  804. /**
  805. * Performs a fast blit from the source surface to the destination surface.
  806. *
  807. * This assumes that the source and destination rectangles are the same size.
  808. * If either `srcrect` or `dstrect` are NULL, the entire surface (`src` or
  809. * `dst`) is copied. The final blit rectangles are saved in `srcrect` and
  810. * `dstrect` after all clipping is performed.
  811. *
  812. * The blit function should not be called on a locked surface.
  813. *
  814. * The blit semantics for surfaces with and without blending and colorkey are
  815. * defined as follows:
  816. *
  817. * ```
  818. * RGBA->RGB:
  819. * Source surface blend mode set to SDL_BLENDMODE_BLEND:
  820. * alpha-blend (using the source alpha-channel and per-surface alpha)
  821. * SDL_SRCCOLORKEY ignored.
  822. * Source surface blend mode set to SDL_BLENDMODE_NONE:
  823. * copy RGB.
  824. * if SDL_SRCCOLORKEY set, only copy the pixels matching the
  825. * RGB values of the source color key, ignoring alpha in the
  826. * comparison.
  827. *
  828. * RGB->RGBA:
  829. * Source surface blend mode set to SDL_BLENDMODE_BLEND:
  830. * alpha-blend (using the source per-surface alpha)
  831. * Source surface blend mode set to SDL_BLENDMODE_NONE:
  832. * copy RGB, set destination alpha to source per-surface alpha value.
  833. * both:
  834. * if SDL_SRCCOLORKEY set, only copy the pixels matching the
  835. * source color key.
  836. *
  837. * RGBA->RGBA:
  838. * Source surface blend mode set to SDL_BLENDMODE_BLEND:
  839. * alpha-blend (using the source alpha-channel and per-surface alpha)
  840. * SDL_SRCCOLORKEY ignored.
  841. * Source surface blend mode set to SDL_BLENDMODE_NONE:
  842. * copy all of RGBA to the destination.
  843. * if SDL_SRCCOLORKEY set, only copy the pixels matching the
  844. * RGB values of the source color key, ignoring alpha in the
  845. * comparison.
  846. *
  847. * RGB->RGB:
  848. * Source surface blend mode set to SDL_BLENDMODE_BLEND:
  849. * alpha-blend (using the source per-surface alpha)
  850. * Source surface blend mode set to SDL_BLENDMODE_NONE:
  851. * copy RGB.
  852. * both:
  853. * if SDL_SRCCOLORKEY set, only copy the pixels matching the
  854. * source color key.
  855. * ```
  856. *
  857. * \param src the SDL_Surface structure to be copied from.
  858. * \param srcrect the SDL_Rect structure representing the rectangle to be
  859. * copied, or NULL to copy the entire surface.
  860. * \param dst the SDL_Surface structure that is the blit target.
  861. * \param dstrect the SDL_Rect structure representing the x and y position in
  862. * the destination surface. On input the width and height are
  863. * ignored (taken from srcrect), and on output this is filled
  864. * in with the actual rectangle used after clipping.
  865. * \returns 0 on success or a negative error code on failure; call
  866. * SDL_GetError() for more information.
  867. *
  868. * \threadsafety The same destination surface should not be used from two
  869. * threads at once. It is safe to use the same source surface
  870. * from multiple threads.
  871. *
  872. * \since This function is available since SDL 3.0.0.
  873. *
  874. * \sa SDL_BlitSurfaceScaled
  875. */
  876. extern SDL_DECLSPEC int SDLCALL SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect);
  877. /**
  878. * Perform low-level surface blitting only.
  879. *
  880. * This is a semi-private blit function and it performs low-level surface
  881. * blitting, assuming the input rectangles have already been clipped.
  882. *
  883. * \param src the SDL_Surface structure to be copied from.
  884. * \param srcrect the SDL_Rect structure representing the rectangle to be
  885. * copied, or NULL to copy the entire surface.
  886. * \param dst the SDL_Surface structure that is the blit target.
  887. * \param dstrect the SDL_Rect structure representing the target rectangle in
  888. * the destination surface.
  889. * \returns 0 on success or a negative error code on failure; call
  890. * SDL_GetError() for more information.
  891. *
  892. * \threadsafety The same destination surface should not be used from two
  893. * threads at once. It is safe to use the same source surface
  894. * from multiple threads.
  895. *
  896. * \since This function is available since SDL 3.0.0.
  897. *
  898. * \sa SDL_BlitSurface
  899. */
  900. extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceUnchecked(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
  901. /**
  902. * Perform stretch blit between two surfaces of the same format.
  903. *
  904. * Using SDL_SCALEMODE_NEAREST: fast, low quality. Using SDL_SCALEMODE_LINEAR:
  905. * bilinear scaling, slower, better quality, only 32BPP.
  906. *
  907. * \param src the SDL_Surface structure to be copied from.
  908. * \param srcrect the SDL_Rect structure representing the rectangle to be
  909. * copied.
  910. * \param dst the SDL_Surface structure that is the blit target.
  911. * \param dstrect the SDL_Rect structure representing the target rectangle in
  912. * the destination surface.
  913. * \param scaleMode scale algorithm to be used.
  914. * \returns 0 on success or a negative error code on failure; call
  915. * SDL_GetError() for more information.
  916. *
  917. * \since This function is available since SDL 3.0.0.
  918. *
  919. * \sa SDL_BlitSurfaceScaled
  920. */
  921. extern SDL_DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
  922. /**
  923. * Perform a scaled blit to a destination surface, which may be of a different
  924. * format.
  925. *
  926. * \param src the SDL_Surface structure to be copied from.
  927. * \param srcrect the SDL_Rect structure representing the rectangle to be
  928. * copied.
  929. * \param dst the SDL_Surface structure that is the blit target.
  930. * \param dstrect the SDL_Rect structure representing the target rectangle in
  931. * the destination surface, filled with the actual rectangle
  932. * used after clipping.
  933. * \param scaleMode the SDL_ScaleMode to be used.
  934. * \returns 0 on success or a negative error code on failure; call
  935. * SDL_GetError() for more information.
  936. *
  937. * \threadsafety The same destination surface should not be used from two
  938. * threads at once. It is safe to use the same source surface
  939. * from multiple threads.
  940. *
  941. * \since This function is available since SDL 3.0.0.
  942. *
  943. * \sa SDL_BlitSurface
  944. */
  945. extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
  946. /**
  947. * Perform low-level surface scaled blitting only.
  948. *
  949. * This is a semi-private function and it performs low-level surface blitting,
  950. * assuming the input rectangles have already been clipped.
  951. *
  952. * \param src the SDL_Surface structure to be copied from.
  953. * \param srcrect the SDL_Rect structure representing the rectangle to be
  954. * copied.
  955. * \param dst the SDL_Surface structure that is the blit target.
  956. * \param dstrect the SDL_Rect structure representing the target rectangle in
  957. * the destination surface.
  958. * \param scaleMode scale algorithm to be used.
  959. * \returns 0 on success or a negative error code on failure; call
  960. * SDL_GetError() for more information.
  961. *
  962. * \threadsafety The same destination surface should not be used from two
  963. * threads at once. It is safe to use the same source surface
  964. * from multiple threads.
  965. *
  966. * \since This function is available since SDL 3.0.0.
  967. *
  968. * \sa SDL_BlitSurfaceScaled
  969. */
  970. extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
  971. /**
  972. * Retrieves a single pixel from a surface.
  973. *
  974. * This function prioritizes correctness over speed: it is suitable for unit
  975. * tests, but is not intended for use in a game engine.
  976. *
  977. * Like SDL_GetRGBA, this uses the entire 0..255 range when converting color
  978. * components from pixel formats with less than 8 bits per RGB component.
  979. *
  980. * \param surface the surface to read.
  981. * \param x the horizontal coordinate, 0 <= x < width.
  982. * \param y the vertical coordinate, 0 <= y < height.
  983. * \param r a pointer filled in with the red channel, 0-255, or NULL to ignore
  984. * this channel.
  985. * \param g a pointer filled in with the green channel, 0-255, or NULL to
  986. * ignore this channel.
  987. * \param b a pointer filled in with the blue channel, 0-255, or NULL to
  988. * ignore this channel.
  989. * \param a a pointer filled in with the alpha channel, 0-255, or NULL to
  990. * ignore this channel.
  991. * \returns 0 on success or a negative error code on failure; call
  992. * SDL_GetError() for more information.
  993. *
  994. * \since This function is available since SDL 3.0.0.
  995. */
  996. extern SDL_DECLSPEC int SDLCALL SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
  997. /* Ends C function definitions when using C++ */
  998. #ifdef __cplusplus
  999. }
  1000. #endif
  1001. #include <SDL3/SDL_close_code.h>
  1002. #endif /* SDL_surface_h_ */