SDL_pixels.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. #ifndef _SDL_pixels_h
  2. #define _SDL_pixels_h
  3. #include "begin_code.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #define SDL_ALPHA_OPAQUE 255
  8. #define SDL_ALPHA_TRANSPARENT 0
  9. enum
  10. {
  11. SDL_PIXELTYPE_UNKNOWN,
  12. SDL_PIXELTYPE_INDEX1,
  13. SDL_PIXELTYPE_INDEX4,
  14. SDL_PIXELTYPE_INDEX8,
  15. SDL_PIXELTYPE_PACKED8,
  16. SDL_PIXELTYPE_PACKED16,
  17. SDL_PIXELTYPE_PACKED32,
  18. SDL_PIXELTYPE_ARRAYU8,
  19. SDL_PIXELTYPE_ARRAYU16,
  20. SDL_PIXELTYPE_ARRAYU32,
  21. SDL_PIXELTYPE_ARRAYF16,
  22. SDL_PIXELTYPE_ARRAYF32
  23. };
  24. enum
  25. {
  26. SDL_BITMAPORDER_NONE,
  27. SDL_BITMAPORDER_4321,
  28. SDL_BITMAPORDER_1234
  29. };
  30. enum
  31. {
  32. SDL_PACKEDORDER_NONE,
  33. SDL_PACKEDORDER_XRGB,
  34. SDL_PACKEDORDER_RGBX,
  35. SDL_PACKEDORDER_ARGB,
  36. SDL_PACKEDORDER_RGBA,
  37. SDL_PACKEDORDER_XBGR,
  38. SDL_PACKEDORDER_BGRX,
  39. SDL_PACKEDORDER_ABGR,
  40. SDL_PACKEDORDER_BGRA
  41. };
  42. enum
  43. {
  44. SDL_ARRAYORDER_NONE,
  45. SDL_ARRAYORDER_RGB,
  46. SDL_ARRAYORDER_RGBA,
  47. SDL_ARRAYORDER_ARGB,
  48. SDL_ARRAYORDER_BGR,
  49. SDL_ARRAYORDER_BGRA,
  50. SDL_ARRAYORDER_ABGR
  51. };
  52. enum
  53. {
  54. SDL_PACKEDLAYOUT_NONE,
  55. SDL_PACKEDLAYOUT_332,
  56. SDL_PACKEDLAYOUT_4444,
  57. SDL_PACKEDLAYOUT_1555,
  58. SDL_PACKEDLAYOUT_5551,
  59. SDL_PACKEDLAYOUT_565,
  60. SDL_PACKEDLAYOUT_8888,
  61. SDL_PACKEDLAYOUT_2101010,
  62. SDL_PACKEDLAYOUT_1010102
  63. };
  64. #define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D)
  65. #define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
  66. ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
  67. ((bits) << 8) | ((bytes) << 0))
  68. #define SDL_PIXELFLAG(X) (((X) >> 28) & 0x0F)
  69. #define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F)
  70. #define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F)
  71. #define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F)
  72. #define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF)
  73. #define SDL_BYTESPERPIXEL(X) \
  74. (SDL_ISPIXELFORMAT_FOURCC(X) ? \
  75. ((((X) == SDL_PIXELFORMAT_YUY2) || \
  76. ((X) == SDL_PIXELFORMAT_UYVY) || \
  77. ((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF))
  78. #define SDL_ISPIXELFORMAT_INDEXED(format) \
  79. (!SDL_ISPIXELFORMAT_FOURCC(format) && \
  80. ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
  81. (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
  82. (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8)))
  83. #define SDL_ISPIXELFORMAT_ALPHA(format) \
  84. (!SDL_ISPIXELFORMAT_FOURCC(format) && \
  85. ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
  86. (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
  87. (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
  88. (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA)))
  89. #define SDL_ISPIXELFORMAT_FOURCC(format) \
  90. ((format) && (SDL_PIXELFLAG(format) != 1))
  91. enum
  92. {
  93. SDL_PIXELFORMAT_UNKNOWN,
  94. SDL_PIXELFORMAT_INDEX1LSB =
  95. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0,
  96. 1, 0),
  97. SDL_PIXELFORMAT_INDEX1MSB =
  98. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0,
  99. 1, 0),
  100. SDL_PIXELFORMAT_INDEX4LSB =
  101. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0,
  102. 4, 0),
  103. SDL_PIXELFORMAT_INDEX4MSB =
  104. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0,
  105. 4, 0),
  106. SDL_PIXELFORMAT_INDEX8 =
  107. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1),
  108. SDL_PIXELFORMAT_RGB332 =
  109. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB,
  110. SDL_PACKEDLAYOUT_332, 8, 1),
  111. SDL_PIXELFORMAT_RGB444 =
  112. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
  113. SDL_PACKEDLAYOUT_4444, 12, 2),
  114. SDL_PIXELFORMAT_RGB555 =
  115. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
  116. SDL_PACKEDLAYOUT_1555, 15, 2),
  117. SDL_PIXELFORMAT_BGR555 =
  118. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
  119. SDL_PACKEDLAYOUT_1555, 15, 2),
  120. SDL_PIXELFORMAT_ARGB4444 =
  121. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
  122. SDL_PACKEDLAYOUT_4444, 16, 2),
  123. SDL_PIXELFORMAT_RGBA4444 =
  124. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
  125. SDL_PACKEDLAYOUT_4444, 16, 2),
  126. SDL_PIXELFORMAT_ABGR4444 =
  127. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
  128. SDL_PACKEDLAYOUT_4444, 16, 2),
  129. SDL_PIXELFORMAT_BGRA4444 =
  130. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA,
  131. SDL_PACKEDLAYOUT_4444, 16, 2),
  132. SDL_PIXELFORMAT_ARGB1555 =
  133. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
  134. SDL_PACKEDLAYOUT_1555, 16, 2),
  135. SDL_PIXELFORMAT_RGBA5551 =
  136. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
  137. SDL_PACKEDLAYOUT_5551, 16, 2),
  138. SDL_PIXELFORMAT_ABGR1555 =
  139. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
  140. SDL_PACKEDLAYOUT_1555, 16, 2),
  141. SDL_PIXELFORMAT_BGRA5551 =
  142. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA,
  143. SDL_PACKEDLAYOUT_5551, 16, 2),
  144. SDL_PIXELFORMAT_RGB565 =
  145. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
  146. SDL_PACKEDLAYOUT_565, 16, 2),
  147. SDL_PIXELFORMAT_BGR565 =
  148. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
  149. SDL_PACKEDLAYOUT_565, 16, 2),
  150. SDL_PIXELFORMAT_RGB24 =
  151. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0,
  152. 24, 3),
  153. SDL_PIXELFORMAT_BGR24 =
  154. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0,
  155. 24, 3),
  156. SDL_PIXELFORMAT_RGB888 =
  157. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB,
  158. SDL_PACKEDLAYOUT_8888, 24, 4),
  159. SDL_PIXELFORMAT_RGBX8888 =
  160. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX,
  161. SDL_PACKEDLAYOUT_8888, 24, 4),
  162. SDL_PIXELFORMAT_BGR888 =
  163. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR,
  164. SDL_PACKEDLAYOUT_8888, 24, 4),
  165. SDL_PIXELFORMAT_BGRX8888 =
  166. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX,
  167. SDL_PACKEDLAYOUT_8888, 24, 4),
  168. SDL_PIXELFORMAT_ARGB8888 =
  169. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
  170. SDL_PACKEDLAYOUT_8888, 32, 4),
  171. SDL_PIXELFORMAT_RGBA8888 =
  172. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA,
  173. SDL_PACKEDLAYOUT_8888, 32, 4),
  174. SDL_PIXELFORMAT_ABGR8888 =
  175. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR,
  176. SDL_PACKEDLAYOUT_8888, 32, 4),
  177. SDL_PIXELFORMAT_BGRA8888 =
  178. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA,
  179. SDL_PACKEDLAYOUT_8888, 32, 4),
  180. SDL_PIXELFORMAT_ARGB2101010 =
  181. SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
  182. SDL_PACKEDLAYOUT_2101010, 32, 4),
  183. SDL_PIXELFORMAT_YV12 =
  184. SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'),
  185. SDL_PIXELFORMAT_IYUV =
  186. SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'),
  187. SDL_PIXELFORMAT_YUY2 =
  188. SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'),
  189. SDL_PIXELFORMAT_UYVY =
  190. SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'),
  191. SDL_PIXELFORMAT_YVYU =
  192. SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U')
  193. };
  194. typedef struct SDL_Color
  195. {
  196. Uint8 r;
  197. Uint8 g;
  198. Uint8 b;
  199. Uint8 a;
  200. } SDL_Color;
  201. #define SDL_Colour SDL_Color
  202. typedef struct SDL_Palette
  203. {
  204. int ncolors;
  205. SDL_Color *colors;
  206. Uint32 version;
  207. int refcount;
  208. } SDL_Palette;
  209. typedef struct SDL_PixelFormat
  210. {
  211. Uint32 format;
  212. SDL_Palette *palette;
  213. Uint8 BitsPerPixel;
  214. Uint8 BytesPerPixel;
  215. Uint8 padding[2];
  216. Uint32 Rmask;
  217. Uint32 Gmask;
  218. Uint32 Bmask;
  219. Uint32 Amask;
  220. Uint8 Rloss;
  221. Uint8 Gloss;
  222. Uint8 Bloss;
  223. Uint8 Aloss;
  224. Uint8 Rshift;
  225. Uint8 Gshift;
  226. Uint8 Bshift;
  227. Uint8 Ashift;
  228. int refcount;
  229. struct SDL_PixelFormat *next;
  230. } SDL_PixelFormat;
  231. extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format);
  232. typedef SDL_bool SDLCALL tSDL_PixelFormatEnumToMasks(Uint32 format,
  233. int *bpp,
  234. Uint32 * Rmask,
  235. Uint32 * Gmask,
  236. Uint32 * Bmask,
  237. Uint32 * Amask);
  238. typedef Uint32 SDLCALL tSDL_MasksToPixelFormatEnum(int bpp,
  239. Uint32 Rmask,
  240. Uint32 Gmask,
  241. Uint32 Bmask,
  242. Uint32 Amask);
  243. typedef SDL_PixelFormat * SDLCALL tSDL_AllocFormat(Uint32 pixel_format);
  244. typedef void SDLCALL tSDL_FreeFormat(SDL_PixelFormat *format);
  245. typedef SDL_Palette * SDLCALL tSDL_AllocPalette(int ncolors);
  246. typedef int SDLCALL tSDL_SetPixelFormatPalette(SDL_PixelFormat * format,
  247. SDL_Palette *palette);
  248. typedef int SDLCALL tSDL_SetPaletteColors(SDL_Palette * palette,
  249. const SDL_Color * colors,
  250. int firstcolor, int ncolors);
  251. typedef void SDLCALL tSDL_FreePalette(SDL_Palette * palette);
  252. typedef Uint32 SDLCALL tSDL_MapRGB(const SDL_PixelFormat * format,
  253. Uint8 r, Uint8 g, Uint8 b);
  254. typedef Uint32 SDLCALL tSDL_MapRGBA(const SDL_PixelFormat * format,
  255. Uint8 r, Uint8 g, Uint8 b,
  256. Uint8 a);
  257. typedef void SDLCALL tSDL_GetRGB(Uint32 pixel,
  258. const SDL_PixelFormat * format,
  259. Uint8 * r, Uint8 * g, Uint8 * b);
  260. typedef void SDLCALL tSDL_GetRGBA(Uint32 pixel,
  261. const SDL_PixelFormat * format,
  262. Uint8 * r, Uint8 * g, Uint8 * b,
  263. Uint8 * a);
  264. typedef void SDLCALL tSDL_CalculateGammaRamp(float gamma, Uint16 * ramp);
  265. extern tSDL_PixelFormatEnumToMasks *SDL_PixelFormatEnumToMasks;
  266. extern tSDL_MasksToPixelFormatEnum *SDL_MasksToPixelFormatEnum;
  267. extern tSDL_AllocFormat *SDL_AllocFormat;
  268. extern tSDL_FreeFormat *SDL_FreeFormat;
  269. extern tSDL_AllocPalette *SDL_AllocPalette;
  270. extern tSDL_SetPixelFormatPalette *SDL_SetPixelFormatPalette;
  271. extern tSDL_SetPaletteColors *SDL_SetPaletteColors;
  272. extern tSDL_FreePalette *SDL_FreePalette;
  273. extern tSDL_MapRGB *SDL_MapRGB;
  274. extern tSDL_MapRGBA *SDL_MapRGBA;
  275. extern tSDL_GetRGB *SDL_GetRGB;
  276. extern tSDL_GetRGBA *SDL_GetRGBA;
  277. extern tSDL_CalculateGammaRamp *SDL_CalculateGammaRamp;
  278. #ifdef __cplusplus
  279. }
  280. #endif
  281. #include "close_code.h"
  282. #endif