sdlpixels.inc 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  1. // based on "sdl_pixels.h" (2.0.14, WIP)
  2. {**
  3. * \file SDL_pixels.h
  4. *
  5. * Header for the enumerated pixel format definitions.
  6. *}
  7. {**
  8. * Transparency definitions
  9. *
  10. * These define alpha as the opacity of a surface.
  11. *}
  12. const
  13. SDL_ALPHA_OPAQUE = 255;
  14. SDL_ALPHA_TRANSPARENT = 0;
  15. {** Pixel type. *}
  16. type
  17. PPSDL_PixelType = ^PSDL_PixelType;
  18. PSDL_PixelType = ^TSDL_PixelType;
  19. TSDL_PixelType = type cuint;
  20. const
  21. SDL_PIXELTYPE_UNKNOWN = TSDL_PixelType(0);
  22. SDL_PIXELTYPE_INDEX1 = TSDL_PixelType(1);
  23. SDL_PIXELTYPE_INDEX4 = TSDL_PixelType(2);
  24. SDL_PIXELTYPE_INDEX8 = TSDL_PixelType(3);
  25. SDL_PIXELTYPE_PACKED8 = TSDL_PixelType(4);
  26. SDL_PIXELTYPE_PACKED16 = TSDL_PixelType(5);
  27. SDL_PIXELTYPE_PACKED32 = TSDL_PixelType(6);
  28. SDL_PIXELTYPE_ARRAYU8 = TSDL_PixelType(7);
  29. SDL_PIXELTYPE_ARRAYU16 = TSDL_PixelType(8);
  30. SDL_PIXELTYPE_ARRAYU32 = TSDL_PixelType(9);
  31. SDL_PIXELTYPE_ARRAYF16 = TSDL_PixelType(10);
  32. SDL_PIXELTYPE_ARRAYF32 = TSDL_PixelType(11);
  33. {** Bitmap pixel order, high bit -> low bit. *}
  34. type
  35. PPSDL_BitmapOrder = ^PSDL_BitmapOrder;
  36. PSDL_BitmapOrder = ^TSDL_BitmapOrder;
  37. TSDL_BitmapOrder = type cuint32;
  38. const
  39. SDL_BITMAPORDER_NONE = TSDL_BitmapOrder(0);
  40. SDL_BITMAPORDER_4321 = TSDL_BitmapOrder(1);
  41. SDL_BITMAPORDER_1234 = TSDL_BitmapOrder(2);
  42. {** Packed component order, high bit -> low bit. *}
  43. type
  44. PPSDL_PackOrder = ^PSDL_PackOrder;
  45. PSDL_PackOrder = ^TSDL_PackOrder;
  46. TSDL_PackOrder = type cuint32;
  47. const
  48. SDL_PACKEDORDER_NONE = TSDL_PackOrder(0);
  49. SDL_PACKEDORDER_XRGB = TSDL_PackOrder(1);
  50. SDL_PACKEDORDER_RGBX = TSDL_PackOrder(2);
  51. SDL_PACKEDORDER_ARGB = TSDL_PackOrder(3);
  52. SDL_PACKEDORDER_RGBA = TSDL_PackOrder(4);
  53. SDL_PACKEDORDER_XBGR = TSDL_PackOrder(5);
  54. SDL_PACKEDORDER_BGRX = TSDL_PackOrder(6);
  55. SDL_PACKEDORDER_ABGR = TSDL_PackOrder(7);
  56. SDL_PACKEDORDER_BGRA = TSDL_PackOrder(8);
  57. {** Array component order, low byte -> high byte. *}
  58. type
  59. PPSDL_ArrayOrder = ^PSDL_ArrayOrder;
  60. PSDL_ArrayOrder = ^TSDL_ArrayOrder;
  61. TSDL_ArrayOrder = type cuint32;
  62. const
  63. SDL_ARRAYORDER_NONE = TSDL_ArrayOrder(0);
  64. SDL_ARRAYORDER_RGB = TSDL_ArrayOrder(1);
  65. SDL_ARRAYORDER_RGBA = TSDL_ArrayOrder(2);
  66. SDL_ARRAYORDER_ARGB = TSDL_ArrayOrder(3);
  67. SDL_ARRAYORDER_BGR = TSDL_ArrayOrder(4);
  68. SDL_ARRAYORDER_BGRA = TSDL_ArrayOrder(5);
  69. SDL_ARRAYORDER_ABGR = TSDL_ArrayOrder(6);
  70. {** Packed component layout. *}
  71. type
  72. PPSDL_PackedLayout = ^PSDL_PackedLayout;
  73. PSDL_PackedLayout = ^TSDL_PackedLayout;
  74. TSDL_PackedLayout = type cuint32;
  75. const
  76. SDL_PACKEDLAYOUT_NONE = TSDL_PackedLayout(0);
  77. SDL_PACKEDLAYOUT_332 = TSDL_PackedLayout(1);
  78. SDL_PACKEDLAYOUT_4444 = TSDL_PackedLayout(2);
  79. SDL_PACKEDLAYOUT_1555 = TSDL_PackedLayout(3);
  80. SDL_PACKEDLAYOUT_5551 = TSDL_PackedLayout(4);
  81. SDL_PACKEDLAYOUT_565 = TSDL_PackedLayout(5);
  82. SDL_PACKEDLAYOUT_8888 = TSDL_PackedLayout(6);
  83. SDL_PACKEDLAYOUT_2101010 = TSDL_PackedLayout(7);
  84. SDL_PACKEDLAYOUT_1010102 = TSDL_PackedLayout(8);
  85. {
  86. SDL2-for-Pascal: The SDL_DEFINE_PIXELFOURCC macro is replaced
  87. by another macro, the SDL_FOURCC macro (in SDL_stdinc.h).
  88. The original C SDL_FOURCC macro:
  89. #define SDL_FOURCC(A, B, C, D) \
  90. ((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \
  91. (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \
  92. (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \
  93. (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24))
  94. In Pascal it is cleaner to implement this directly as a
  95. constant instead of a function. So we do, e. g.:
  96. SDL_PIXELFORMAT_YV12 = (cuint32('Y') ) or
  97. (cuint32('V') shl 8) or
  98. (cuint32('1') shl 16) or
  99. (cuint32('2') shl 24);
  100. In the future it may be desirable to have a Pascal function.
  101. The prototype could look like this:
  102. function SDL_DEFINE_PIXELFOURCC(A,B,C,D: Variant): Variant;
  103. }
  104. {
  105. SDL2-for-Pascal: The SDL_DEFINE_PIXELFORMAT macro returns the underlying
  106. pixel format based on five arguments.
  107. The original C macro:
  108. #define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
  109. ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
  110. ((bits) << 8) | ((bytes) << 0))
  111. This C implementation could be replaced by a Pascal function,
  112. but from a performance stand point this will be slower.
  113. Therefore we decided to keep it as it has been implemented
  114. before by the original binding authors and translate
  115. every pixel format constant by the very same expression:
  116. SDL_PIXELFORMAT_[...] = (1 shl 28) or
  117. (SDL_PIXELTYPE_[...] shl 24) or
  118. (SDL_BITMAPORDER_[...] shl 20) or
  119. ([...] shl 16) or
  120. ([...] shl 8) or
  121. ([...] shl 0);
  122. In the future it may be desirable to have a Pascal function.
  123. The prototype could look like this:
  124. function SDL_DEFINE_PIXELFORMAT(type, order, layour, bit, bytes: cuint32): Result;
  125. }
  126. function SDL_PIXELFLAG(X: cuint32): cuint32;
  127. function SDL_PIXELTYPE(X: cuint32): cuint32;
  128. function SDL_PIXELORDER(X: cuint32): cuint32;
  129. function SDL_PIXELLAYOUT(X: cuint32): cuint32;
  130. function SDL_BITSPERPIXEL(X: cuint32): cuint32;
  131. {
  132. SDL2-for-Pascal: Is it worth translating these macros as they seem to be used
  133. by SDL2 internally only?
  134. #define SDL_BYTESPERPIXEL(X) \
  135. (SDL_ISPIXELFORMAT_FOURCC(X) ? \
  136. ((((X) == SDL_PIXELFORMAT_YUY2) || \
  137. ((X) == SDL_PIXELFORMAT_UYVY) || \
  138. ((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF))
  139. #define SDL_ISPIXELFORMAT_INDEXED(format) \
  140. (!SDL_ISPIXELFORMAT_FOURCC(format) && \
  141. ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
  142. (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
  143. (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8)))
  144. #define SDL_ISPIXELFORMAT_PACKED(format) \
  145. (!SDL_ISPIXELFORMAT_FOURCC(format) && \
  146. ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED8) || \
  147. (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED16) || \
  148. (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32)))
  149. #define SDL_ISPIXELFORMAT_ARRAY(format) \
  150. (!SDL_ISPIXELFORMAT_FOURCC(format) && \
  151. ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU8) || \
  152. (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU16) || \
  153. (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU32) || \
  154. (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \
  155. (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32)))
  156. #define SDL_ISPIXELFORMAT_ALPHA(format) \
  157. ((SDL_ISPIXELFORMAT_PACKED(format) && \
  158. ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
  159. (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
  160. (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
  161. (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))) || \
  162. (SDL_ISPIXELFORMAT_ARRAY(format) && \
  163. ((SDL_PIXELORDER(format) == SDL_ARRAYORDER_ARGB) || \
  164. (SDL_PIXELORDER(format) == SDL_ARRAYORDER_RGBA) || \
  165. (SDL_PIXELORDER(format) == SDL_ARRAYORDER_ABGR) || \
  166. (SDL_PIXELORDER(format) == SDL_ARRAYORDER_BGRA))))
  167. }
  168. {* The flag is set to 1 because 0x1? is not in the printable ASCII range *}
  169. function SDL_ISPIXELFORMAT_FOURCC(format: Variant): Boolean;
  170. {* Note: If you modify this list, update SDL_GetPixelFormatName() *}
  171. const
  172. SDL_PIXELFORMAT_UNKNOWN = 0;
  173. SDL_PIXELFORMAT_INDEX1LSB = (1 shl 28) or
  174. (SDL_PIXELTYPE_INDEX1 shl 24) or
  175. (SDL_BITMAPORDER_4321 shl 20) or
  176. (0 shl 16) or
  177. (1 shl 8) or
  178. (0 shl 0);
  179. SDL_PIXELFORMAT_INDEX1MSB = (1 shl 28) or
  180. (SDL_PIXELTYPE_INDEX1 shl 24) or
  181. (SDL_BITMAPORDER_1234 shl 20) or
  182. (0 shl 16) or
  183. (1 shl 8) or
  184. (0 shl 0);
  185. SDL_PIXELFORMAT_INDEX4LSB = (1 shl 28) or
  186. (SDL_PIXELTYPE_INDEX4 shl 24) or
  187. (SDL_BITMAPORDER_4321 shl 20) or
  188. (0 shl 16) or
  189. (4 shl 8) or
  190. (0 shl 0);
  191. SDL_PIXELFORMAT_INDEX4MSB = (1 shl 28) or
  192. (SDL_PIXELTYPE_INDEX4 shl 24) or
  193. (SDL_BITMAPORDER_1234 shl 20) or
  194. (0 shl 16) or
  195. (4 shl 8) or
  196. (0 shl 0);
  197. SDL_PIXELFORMAT_INDEX8 = (1 shl 28) or
  198. (SDL_PIXELTYPE_PACKED8 shl 24) or
  199. (0 shl 20) or
  200. (0 shl 16) or
  201. (8 shl 8) or
  202. (1 shl 0);
  203. SDL_PIXELFORMAT_RGB332 = (1 shl 28) or
  204. (SDL_PIXELTYPE_PACKED8 shl 24) or
  205. (SDL_PACKEDORDER_XRGB shl 20) or
  206. (SDL_PACKEDLAYOUT_332 shl 16) or
  207. (8 shl 8) or
  208. (1 shl 0);
  209. SDL_PIXELFORMAT_RGB444 = (1 shl 28) or
  210. (SDL_PIXELTYPE_PACKED16 shl 24) or
  211. (SDL_PACKEDORDER_XRGB shl 20) or
  212. (SDL_PACKEDLAYOUT_4444 shl 16) or
  213. (12 shl 8) or
  214. (2 shl 0);
  215. SDL_PIXELFORMAT_RGB555 = (1 shl 28) or
  216. (SDL_PIXELTYPE_PACKED16 shl 24) or
  217. (SDL_PACKEDORDER_XRGB shl 20) or
  218. (SDL_PACKEDLAYOUT_1555 shl 16) or
  219. (15 shl 8) or
  220. (2 shl 0);
  221. SDL_PIXELFORMAT_BGR555 = (1 shl 28) or
  222. (SDL_PIXELTYPE_PACKED16 shl 24) or
  223. (SDL_PACKEDORDER_XBGR shl 20) or
  224. (SDL_PACKEDLAYOUT_1555 shl 16) or
  225. (15 shl 8) or
  226. (2 shl 0);
  227. SDL_PIXELFORMAT_ARGB4444 = (1 shl 28) or
  228. (SDL_PIXELTYPE_PACKED16 shl 24) or
  229. (SDL_PACKEDORDER_ARGB shl 20) or
  230. (SDL_PACKEDLAYOUT_4444 shl 16) or
  231. (16 shl 8) or
  232. (2 shl 0);
  233. SDL_PIXELFORMAT_RGBA4444 = (1 shl 28) or
  234. (SDL_PIXELTYPE_PACKED16 shl 24) or
  235. (SDL_PACKEDORDER_RGBA shl 20) or
  236. (SDL_PACKEDLAYOUT_4444 shl 16) or
  237. (16 shl 8) or
  238. (2 shl 0);
  239. SDL_PIXELFORMAT_ABGR4444 = (1 shl 28) or
  240. (SDL_PIXELTYPE_PACKED16 shl 24) or
  241. (SDL_PACKEDORDER_ABGR shl 20) or
  242. (SDL_PACKEDLAYOUT_4444 shl 16) or
  243. (16 shl 8) or
  244. (2 shl 0);
  245. SDL_PIXELFORMAT_BGRA4444 = (1 shl 28) or
  246. (SDL_PIXELTYPE_PACKED16 shl 24) or
  247. (SDL_PACKEDORDER_BGRA shl 20) or
  248. (SDL_PACKEDLAYOUT_4444 shl 16) or
  249. (16 shl 8) or
  250. (2 shl 0);
  251. SDL_PIXELFORMAT_ARGB1555 = (1 shl 28) or
  252. (SDL_PIXELTYPE_PACKED16 shl 24) or
  253. (SDL_PACKEDORDER_ARGB shl 20) or
  254. (SDL_PACKEDLAYOUT_1555 shl 16) or
  255. (16 shl 8) or
  256. (2 shl 0);
  257. SDL_PIXELFORMAT_RGBA5551 = (1 shl 28) or
  258. (SDL_PIXELTYPE_PACKED16 shl 24) or
  259. (SDL_PACKEDORDER_RGBA shl 20) or
  260. (SDL_PACKEDLAYOUT_5551 shl 16) or
  261. (16 shl 8) or
  262. (2 shl 0);
  263. SDL_PIXELFORMAT_ABGR1555 = (1 shl 28) or
  264. (SDL_PIXELTYPE_PACKED16 shl 24) or
  265. (SDL_PACKEDORDER_ABGR shl 20) or
  266. (SDL_PACKEDLAYOUT_1555 shl 16) or
  267. (16 shl 8) or
  268. (2 shl 0);
  269. SDL_PIXELFORMAT_BGRA5551 = (1 shl 28) or
  270. (SDL_PIXELTYPE_PACKED16 shl 24) or
  271. (SDL_PACKEDORDER_BGRA shl 20) or
  272. (SDL_PACKEDLAYOUT_5551 shl 16) or
  273. (16 shl 8) or
  274. (2 shl 0);
  275. SDL_PIXELFORMAT_RGB565 = (1 shl 28) or
  276. (SDL_PIXELTYPE_PACKED16 shl 24) or
  277. (SDL_PACKEDORDER_XRGB shl 20) or
  278. (SDL_PACKEDLAYOUT_565 shl 16) or
  279. (16 shl 8) or
  280. (2 shl 0);
  281. SDL_PIXELFORMAT_BGR565 = (1 shl 28) or
  282. (SDL_PIXELTYPE_PACKED16 shl 24) or
  283. (SDL_PACKEDORDER_XBGR shl 20) or
  284. (SDL_PACKEDLAYOUT_1555 shl 16) or
  285. (16 shl 8) or
  286. (2 shl 0);
  287. SDL_PIXELFORMAT_RGB24 = (1 shl 28) or
  288. (SDL_PIXELTYPE_ARRAYU8 shl 24) or
  289. (SDL_ARRAYORDER_RGB shl 20) or
  290. (0 shl 16) or
  291. (24 shl 8) or
  292. (3 shl 0);
  293. SDL_PIXELFORMAT_BGR24 = (1 shl 28) or
  294. (SDL_PIXELTYPE_ARRAYU8 shl 24) or
  295. (SDL_ARRAYORDER_BGR shl 20) or
  296. (0 shl 16) or
  297. (24 shl 8) or
  298. (3 shl 0);
  299. SDL_PIXELFORMAT_RGB888 = (1 shl 28) or
  300. (SDL_PIXELTYPE_PACKED32 shl 24) or
  301. (SDL_PACKEDORDER_XRGB shl 20) or
  302. (SDL_PACKEDLAYOUT_8888 shl 16) or
  303. (24 shl 8) or
  304. (4 shl 0);
  305. SDL_PIXELFORMAT_RGBX8888 = (1 shl 28) or
  306. (SDL_PIXELTYPE_PACKED32 shl 24) or
  307. (SDL_PACKEDORDER_RGBX shl 20) or
  308. (SDL_PACKEDLAYOUT_8888 shl 16) or
  309. (24 shl 8) or
  310. (4 shl 0);
  311. SDL_PIXELFORMAT_BGR888 = (1 shl 28) or
  312. (SDL_PIXELTYPE_PACKED32 shl 24) or
  313. (SDL_PACKEDORDER_XBGR shl 20) or
  314. (SDL_PACKEDLAYOUT_8888 shl 16) or
  315. (24 shl 8) or
  316. (4 shl 0);
  317. SDL_PIXELFORMAT_BGRX8888 = (1 shl 28) or
  318. (SDL_PIXELTYPE_PACKED32 shl 24) or
  319. (SDL_PACKEDORDER_BGRX shl 20) or
  320. (SDL_PACKEDLAYOUT_8888 shl 16) or
  321. (24 shl 8) or
  322. (4 shl 0);
  323. SDL_PIXELFORMAT_ARGB8888 = (1 shl 28) or
  324. (SDL_PIXELTYPE_PACKED32 shl 24) or
  325. (SDL_PACKEDORDER_ARGB shl 20) or
  326. (SDL_PACKEDLAYOUT_8888 shl 16) or
  327. (32 shl 8) or
  328. (4 shl 0);
  329. SDL_PIXELFORMAT_RGBA8888 = (1 shl 28) or
  330. (SDL_PIXELTYPE_PACKED32 shl 24) or
  331. (SDL_PACKEDORDER_RGBA shl 20) or
  332. (SDL_PACKEDLAYOUT_8888 shl 16) or
  333. (32 shl 8) or
  334. (4 shl 0);
  335. SDL_PIXELFORMAT_ABGR8888 = (1 shl 28) or
  336. (SDL_PIXELTYPE_PACKED32 shl 24) or
  337. (SDL_PACKEDORDER_ABGR shl 20) or
  338. (SDL_PACKEDLAYOUT_8888 shl 16) or
  339. (32 shl 8) or
  340. (4 shl 0);
  341. SDL_PIXELFORMAT_BGRA8888 = (1 shl 28) or
  342. (SDL_PIXELTYPE_PACKED32 shl 24) or
  343. (SDL_PACKEDORDER_RGBX shl 20) or
  344. (SDL_PACKEDLAYOUT_8888 shl 16) or
  345. (32 shl 8) or
  346. (4 shl 0);
  347. SDL_PIXELFORMAT_ARGB2101010 = (1 shl 28) or
  348. (SDL_PIXELTYPE_PACKED32 shl 24) or
  349. (SDL_PACKEDORDER_ARGB shl 20) or
  350. (SDL_PACKEDLAYOUT_2101010 shl 16)or
  351. (32 shl 8) or
  352. (4 shl 0);
  353. (* Aliases for RGBA byte arrays of color data, for the current platform *)
  354. {$IFDEF FPC}
  355. {$IF DEFINED(ENDIAN_LITTLE)}
  356. SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_ABGR8888;
  357. SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_BGRA8888;
  358. SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_ARGB8888;
  359. SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_RGBA8888;
  360. {$ELSEIF DEFINED(ENDIAN_BIG)}
  361. SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_RGBA8888;
  362. SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB8888;
  363. SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA8888;
  364. SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR8888;
  365. {$ELSE}
  366. {$FATAL Cannot determine endianness.}
  367. {$IFEND}
  368. {$ENDIF}
  369. {**< Planar mode: Y + V + U (3 planes) *}
  370. SDL_PIXELFORMAT_YV12 = (cuint32('Y') ) or
  371. (cuint32('V') shl 8) or
  372. (cuint32('1') shl 16) or
  373. (cuint32('2') shl 24);
  374. {**< Planar mode: Y + U + V (3 planes) *}
  375. SDL_PIXELFORMAT_IYUV = (cuint32('I') ) or
  376. (cuint32('Y') shl 8) or
  377. (cuint32('U') shl 16) or
  378. (cuint32('V') shl 24);
  379. {**< Packed mode: Y0+U0+Y1+V0 (1 plane) *}
  380. SDL_PIXELFORMAT_YUY2 = (cuint32('Y') ) or
  381. (cuint32('U') shl 8) or
  382. (cuint32('Y') shl 16) or
  383. (cuint32('2') shl 24);
  384. {**< Packed mode: U0+Y0+V0+Y1 (1 plane) *}
  385. SDL_PIXELFORMAT_UYVY = (cuint32('U') ) or
  386. (cuint32('Y') shl 8) or
  387. (cuint32('V') shl 16) or
  388. (cuint32('Y') shl 24);
  389. {**< Packed mode: Y0+V0+Y1+U0 (1 plane) *}
  390. SDL_PIXELFORMAT_YVYU = (cuint32('Y') ) or
  391. (cuint32('V') shl 8) or
  392. (cuint32('Y') shl 16) or
  393. (cuint32('U') shl 24);
  394. {**< Planar mode: Y + U/V interleaved (2 planes) *}
  395. SDL_PIXELFORMAT_NV12 = (cuint32('N') ) or
  396. (cuint32('V') shl 8) or
  397. (cuint32('1') shl 16) or
  398. (cuint32('2') shl 24);
  399. {**< Planar mode: Y + V/U interleaved (2 planes) *}
  400. SDL_PIXELFORMAT_NV21 = (cuint32('N') ) or
  401. (cuint32('V') shl 8) or
  402. (cuint32('2') shl 16) or
  403. (cuint32('1') shl 24);
  404. {**< Android video texture format *}
  405. SDL_PIXELFORMAT_EXTERMAL_OES
  406. = (cuint32('O') ) or
  407. (cuint32('E') shl 8) or
  408. (cuint32('S') shl 16) or
  409. (cuint32(' ') shl 24);
  410. type
  411. {**
  412. * The bits of this structure can be directly reinterpreted as an integer-packed
  413. * color which uses the SDL_PIXELFORMAT_RGBA32 format (SDL_PIXELFORMAT_ABGR8888
  414. * on little-endian systems and SDL_PIXELFORMAT_RGBA8888 on big-endian systems).
  415. *}
  416. PPSDL_Color = ^PSDL_Color;
  417. PSDL_Color = ^TSDL_Color;
  418. TSDL_Color = record
  419. r: cuint8;
  420. g: cuint8;
  421. b: cuint8;
  422. a: cuint8;
  423. end;
  424. PPSDL_Colour = ^PSDL_Colour;
  425. PSDL_Colour = ^TSDL_Colour;
  426. TSDL_Colour = TSDL_Color;
  427. PPSDL_Palette = ^PSDL_Palette;
  428. PSDL_Palette = ^TSDL_Palette;
  429. TSDL_Palette = record
  430. ncolors: cint;
  431. colors: PSDL_Color;
  432. version: cuint32;
  433. refcount: cint;
  434. end;
  435. {**
  436. * Everything in the pixel format structure is read-only.
  437. *}
  438. PPSDL_PixelFormat = ^PSDL_PixelFormat;
  439. PSDL_PixelFormat = ^TSDL_PixelFormat;
  440. TSDL_PixelFormat = record
  441. format: cuint32;
  442. palette: PSDL_Palette;
  443. BitsPerPixel: cuint8;
  444. BytesPerPixel: cuint8;
  445. padding: array[0..1] of cuint8;
  446. Rmask: cuint32;
  447. Gmask: cuint32;
  448. Bmask: cuint32;
  449. Amask: cuint32;
  450. Rloss: cuint8;
  451. Gloss: cuint8;
  452. Bloss: cuint8;
  453. Aloss: cuint8;
  454. Rshift: cuint8;
  455. Gshift: cuint8;
  456. Bshift: cuint8;
  457. Ashift: cuint8;
  458. refcount: cint;
  459. next: PSDL_PixelFormat;
  460. end;
  461. {**
  462. * Get the human readable name of a pixel format.
  463. *
  464. * \param format the pixel format to query
  465. * \returns the human readable name of the specified pixel format or
  466. * `SDL_PIXELFORMAT_UNKNOWN` if the format isn't recognized.
  467. *
  468. * \since This function is available since SDL 2.0.0.
  469. *}
  470. function SDL_GetPixelFormatName(format: cuint32): PAnsiChar; cdecl;
  471. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetPixelFormatName' {$ENDIF} {$ENDIF};
  472. {**
  473. * Convert one of the enumerated pixel formats to a bpp value and RGBA masks.
  474. *
  475. * \param format one of the SDL_PixelFormatEnum values
  476. * \param bpp a bits per pixel value; usually 15, 16, or 32
  477. * \param Rmask a pointer filled in with the red mask for the format
  478. * \param Gmask a pointer filled in with the green mask for the format
  479. * \param Bmask a pointer filled in with the blue mask for the format
  480. * \param Amask a pointer filled in with the alpha mask for the format
  481. * \returns SDL_TRUE on success or SDL_FALSE if the conversion wasn't
  482. * possible; call SDL_GetError() for more information.
  483. *
  484. * \since This function is available since SDL 2.0.0.
  485. *
  486. * \sa SDL_MasksToPixelFormatEnum
  487. *}
  488. function SDL_PixelFormatEnumToMasks(format: cuint32; bpp: pcint;
  489. Rmask: pcuint32; Gmask: pcuint32; Bmask: pcuint32; Amask: pcuint32): TSDL_Bool; cdecl;
  490. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_PixelFormatEnumToMasks' {$ENDIF} {$ENDIF};
  491. {**
  492. * Convert a bpp value and RGBA masks to an enumerated pixel format.
  493. *
  494. * This will return `SDL_PIXELFORMAT_UNKNOWN` if the conversion wasn't
  495. * possible.
  496. *
  497. * \param bpp a bits per pixel value; usually 15, 16, or 32
  498. * \param Rmask the red mask for the format
  499. * \param Gmask the green mask for the format
  500. * \param Bmask the blue mask for the format
  501. * \param Amask the alpha mask for the format
  502. * \returns one of the SDL_PixelFormatEnum values
  503. *
  504. * \since This function is available since SDL 2.0.0.
  505. *
  506. * \sa SDL_PixelFormatEnumToMasks
  507. *}
  508. function SDL_MasksToPixelFormatEnum(bpp: cint; Rmask: cuint32; Gmask: cuint32; Bmask: cuint32; Amask: cuint32): cuint32; cdecl;
  509. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_MasksToPixelFormatEnum' {$ENDIF} {$ENDIF};
  510. {**
  511. * Create an SDL_PixelFormat structure corresponding to a pixel format.
  512. *
  513. * Returned structure may come from a shared global cache (i.e. not newly
  514. * allocated), and hence should not be modified, especially the palette. Weird
  515. * errors such as `Blit combination not supported` may occur.
  516. *
  517. * \param pixel_format one of the SDL_PixelFormatEnum values
  518. * \returns the new SDL_PixelFormat structure or NULL on failure; call
  519. * SDL_GetError() for more information.
  520. *
  521. * \since This function is available since SDL 2.0.0.
  522. *
  523. * \sa SDL_FreeFormat
  524. *}
  525. function SDL_AllocFormat(pixel_format: cuint32): PSDL_PixelFormat; cdecl;
  526. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_AllocFormat' {$ENDIF} {$ENDIF};
  527. {**
  528. * Free an SDL_PixelFormat structure allocated by SDL_AllocFormat().
  529. *
  530. * \param format the SDL_PixelFormat structure to free
  531. *
  532. * \since This function is available since SDL 2.0.0.
  533. *
  534. * \sa SDL_AllocFormat
  535. *}
  536. procedure SDL_FreeFormat(format: PSDL_PixelFormat); cdecl;
  537. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FreeFormat' {$ENDIF} {$ENDIF};
  538. {**
  539. * Create a palette structure with the specified number of color entries.
  540. *
  541. * The palette entries are initialized to white.
  542. *
  543. * \param ncolors represents the number of color entries in the color palette
  544. * \returns a new SDL_Palette structure on success or NULL on failure (e.g. if
  545. * there wasn't enough memory); call SDL_GetError() for more
  546. * information.
  547. *
  548. * \since This function is available since SDL 2.0.0.
  549. *
  550. * \sa SDL_FreePalette
  551. *}
  552. function SDL_AllocPalette(ncolors: cint): PSDL_Palette; cdecl;
  553. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_AllocPalette' {$ENDIF} {$ENDIF};
  554. {**
  555. * Set the palette for a pixel format structure.
  556. *
  557. * \param format the SDL_PixelFormat structure that will use the palette
  558. * \param palette the SDL_Palette structure that will be used
  559. * \returns 0 on success or a negative error code on failure; call
  560. * SDL_GetError() for more information.
  561. *
  562. * \since This function is available since SDL 2.0.0.
  563. *
  564. * \sa SDL_AllocPalette
  565. * \sa SDL_FreePalette
  566. *}
  567. function SDL_SetPixelFormatPalette(format: PSDL_PixelFormat; palette: PSDL_Palette): cint; cdecl;
  568. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetPixelFormatPalette' {$ENDIF} {$ENDIF};
  569. {**
  570. * Set a range of colors in a palette.
  571. *
  572. * \param palette the SDL_Palette structure to modify
  573. * \param colors an array of SDL_Color structures to copy into the palette
  574. * \param firstcolor the index of the first palette entry to modify
  575. * \param ncolors the number of entries to modify
  576. * \returns 0 on success or a negative error code if not all of the colors
  577. * could be set; call SDL_GetError() for more information.
  578. *
  579. * \since This function is available since SDL 2.0.0.
  580. *
  581. * \sa SDL_AllocPalette
  582. * \sa SDL_CreateRGBSurface
  583. *}
  584. function SDL_SetPaletteColors(palette: PSDL_Palette; const colors: PSDL_Color; firstcolor: cint; ncolors: cint): cint; cdecl;
  585. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetPaletteColors' {$ENDIF} {$ENDIF};
  586. {**
  587. * Free a palette created with SDL_AllocPalette().
  588. *
  589. * \param palette the SDL_Palette structure to be freed
  590. *
  591. * \since This function is available since SDL 2.0.0.
  592. *
  593. * \sa SDL_AllocPalette
  594. *}
  595. procedure SDL_FreePalette(palette: PSDL_Palette); cdecl;
  596. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FreePalette' {$ENDIF} {$ENDIF};
  597. {**
  598. * Map an RGB triple to an opaque pixel value for a given pixel format.
  599. *
  600. * This function maps the RGB color value to the specified pixel format and
  601. * returns the pixel value best approximating the given RGB color value for
  602. * the given pixel format.
  603. *
  604. * If the format has a palette (8-bit) the index of the closest matching color
  605. * in the palette will be returned.
  606. *
  607. * If the specified pixel format has an alpha component it will be returned as
  608. * all 1 bits (fully opaque).
  609. *
  610. * If the pixel format bpp (color depth) is less than 32-bpp then the unused
  611. * upper bits of the return value can safely be ignored (e.g., with a 16-bpp
  612. * format the return value can be assigned to a Uint16, and similarly a Uint8
  613. * for an 8-bpp format).
  614. *
  615. * \param format an SDL_PixelFormat structure describing the pixel format
  616. * \param r the red component of the pixel in the range 0-255
  617. * \param g the green component of the pixel in the range 0-255
  618. * \param b the blue component of the pixel in the range 0-255
  619. * \returns a pixel value
  620. *
  621. * \since This function is available since SDL 2.0.0.
  622. *
  623. * \sa SDL_GetRGB
  624. * \sa SDL_GetRGBA
  625. * \sa SDL_MapRGBA
  626. *}
  627. function SDL_MapRGB(const format: PSDL_PixelFormat; r: cuint8; g: cuint8; b: cuint8): cuint32; cdecl;
  628. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_MapRGB' {$ENDIF} {$ENDIF};
  629. {**
  630. * Map an RGBA quadruple to a pixel value for a given pixel format.
  631. *
  632. * This function maps the RGBA color value to the specified pixel format and
  633. * returns the pixel value best approximating the given RGBA color value for
  634. * the given pixel format.
  635. *
  636. * If the specified pixel format has no alpha component the alpha value will
  637. * be ignored (as it will be in formats with a palette).
  638. *
  639. * If the format has a palette (8-bit) the index of the closest matching color
  640. * in the palette will be returned.
  641. *
  642. * If the pixel format bpp (color depth) is less than 32-bpp then the unused
  643. * upper bits of the return value can safely be ignored (e.g., with a 16-bpp
  644. * format the return value can be assigned to a Uint16, and similarly a Uint8
  645. * for an 8-bpp format).
  646. *
  647. * \param format an SDL_PixelFormat structure describing the format of the
  648. * pixel
  649. * \param r the red component of the pixel in the range 0-255
  650. * \param g the green component of the pixel in the range 0-255
  651. * \param b the blue component of the pixel in the range 0-255
  652. * \param a the alpha component of the pixel in the range 0-255
  653. * \returns a pixel value
  654. *
  655. * \since This function is available since SDL 2.0.0.
  656. *
  657. * \sa SDL_GetRGB
  658. * \sa SDL_GetRGBA
  659. * \sa SDL_MapRGB
  660. *}
  661. function SDL_MapRGBA(const format: PSDL_PixelFormat; r: cuint8; g: cuint8; b: cuint8; a: cuint8): cuint32; cdecl;
  662. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_MapRGBA' {$ENDIF} {$ENDIF};
  663. {**
  664. * Get RGB values from a pixel in the specified format.
  665. *
  666. * This function uses the entire 8-bit [0..255] range when converting color
  667. * components from pixel formats with less than 8-bits per RGB component
  668. * (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff,
  669. * 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).
  670. *
  671. * \param pixel a pixel value
  672. * \param format an SDL_PixelFormat structure describing the format of the
  673. * pixel
  674. * \param r a pointer filled in with the red component
  675. * \param g a pointer filled in with the green component
  676. * \param b a pointer filled in with the blue component
  677. *
  678. * \since This function is available since SDL 2.0.0.
  679. *
  680. * \sa SDL_GetRGBA
  681. * \sa SDL_MapRGB
  682. * \sa SDL_MapRGBA
  683. *}
  684. procedure SDL_GetRGB(pixel: cuint32; const format: PSDL_PixelFormat; r: pcuint8; g: pcuint8; b: pcuint8); cdecl;
  685. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetRGB' {$ENDIF} {$ENDIF};
  686. {**
  687. * Get RGBA values from a pixel in the specified format.
  688. *
  689. * This function uses the entire 8-bit [0..255] range when converting color
  690. * components from pixel formats with less than 8-bits per RGB component
  691. * (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff,
  692. * 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).
  693. *
  694. * If the surface has no alpha component, the alpha will be returned as 0xff
  695. * (100% opaque).
  696. *
  697. * \param pixel a pixel value
  698. * \param format an SDL_PixelFormat structure describing the format of the
  699. * pixel
  700. * \param r a pointer filled in with the red component
  701. * \param g a pointer filled in with the green component
  702. * \param b a pointer filled in with the blue component
  703. * \param a a pointer filled in with the alpha component
  704. *
  705. * \since This function is available since SDL 2.0.0.
  706. *
  707. * \sa SDL_GetRGB
  708. * \sa SDL_MapRGB
  709. * \sa SDL_MapRGBA
  710. *}
  711. procedure SDL_GetRGBA(pixel: cuint32; const format: PSDL_PixelFormat; r: pcuint8; g: pcuint8; b: pcuint8; a: pcuint8); cdecl;
  712. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetRGBA' {$ENDIF} {$ENDIF};
  713. {/**
  714. * Calculate a 256 entry gamma ramp for a gamma value.
  715. *
  716. * \param gamma a gamma value where 0.0 is black and 1.0 is identity
  717. * \param ramp an array of 256 values filled in with the gamma ramp
  718. *
  719. * \since This function is available since SDL 2.0.0.
  720. *
  721. * \sa SDL_SetWindowGammaRamp
  722. *}
  723. procedure SDL_CalculateGammaRamp(gamma: cfloat; ramp: pcuint16); cdecl;
  724. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_CalculateGammaRamp' {$ENDIF} {$ENDIF};