1 /* 2 DSDL 3 Copyright (C) 2025 Inochi2D Project <luna@foxgirls.gay> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20 21 ========================================================================== 22 23 Simple DirectMedia Layer 24 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> 25 26 This software is provided 'as-is', without any express or implied 27 warranty. In no event will the authors be held liable for any damages 28 arising from the use of this software. 29 30 Permission is granted to anyone to use this software for any purpose, 31 including commercial applications, and to alter it and redistribute it 32 freely, subject to the following restrictions: 33 34 1. The origin of this software must not be misrepresented; you must not 35 claim that you wrote the original software. If you use this software 36 in a product, an acknowledgment in the product documentation would be 37 appreciated but is not required. 38 2. Altered source versions must be plainly marked as such, and must not be 39 misrepresented as being the original software. 40 3. This notice may not be removed or altered from any source distribution. 41 */ 42 43 /** 44 SDL Pixel Managment 45 46 See_Also: 47 $(LINK2 https://wiki.libsdl.org/SDL3/CategoryPixels, SDL3 Pixel Documentation) 48 49 Copyright: © 2025 Inochi2D Project, © 1997-2025 Sam Lantinga 50 License: Subject to the terms of the Zlib License, as written in the LICENSE file. 51 Authors: 52 Luna Nielsen 53 */ 54 module sdl.pixels; 55 import sdl.stdc; 56 57 extern(C) nothrow @nogc: 58 59 private { 60 version(BigEndian) enum IsBigEndian = true; 61 else enum IsBigEndian = false; 62 } 63 64 /** 65 A fully opaque 8-bit alpha value. 66 67 See_Also: 68 $(D SDL_ALPHA_TRANSPARENT) 69 */ 70 enum SDL_ALPHA_OPAQUE = 255; 71 72 /** 73 A fully opaque floating point alpha value. 74 75 See_Also: 76 $(D SDL_ALPHA_TRANSPARENT_FLOAT) 77 */ 78 enum SDL_ALPHA_OPAQUE_FLOAT = 1.0f; 79 80 /** 81 A fully transparent 8-bit alpha value. 82 83 See_Also: 84 $(D SDL_ALPHA_OPAQUE) 85 */ 86 enum SDL_ALPHA_TRANSPARENT = 0; 87 88 /** 89 A fully transparent floating point alpha value. 90 91 See_Also: 92 $(D SDL_ALPHA_OPAQUE_FLOAT) 93 */ 94 enum SDL_ALPHA_TRANSPARENT_FLOAT = 0.0f; 95 96 /** 97 Pixel type. 98 */ 99 enum SDL_PixelType { 100 SDL_PIXELTYPE_UNKNOWN, 101 SDL_PIXELTYPE_INDEX1, 102 SDL_PIXELTYPE_INDEX4, 103 SDL_PIXELTYPE_INDEX8, 104 SDL_PIXELTYPE_PACKED8, 105 SDL_PIXELTYPE_PACKED16, 106 SDL_PIXELTYPE_PACKED32, 107 SDL_PIXELTYPE_ARRAYU8, 108 SDL_PIXELTYPE_ARRAYU16, 109 SDL_PIXELTYPE_ARRAYU32, 110 SDL_PIXELTYPE_ARRAYF16, 111 SDL_PIXELTYPE_ARRAYF32, 112 113 /* appended at the end for compatibility with sdl2-compat: */ 114 SDL_PIXELTYPE_INDEX2 115 } 116 117 /** 118 Bitmap pixel order, high bit -> low bit. 119 */ 120 enum SDL_BitmapOrder { 121 SDL_BITMAPORDER_NONE, 122 SDL_BITMAPORDER_4321, 123 SDL_BITMAPORDER_1234 124 } 125 126 /** 127 Packed component order, high bit -> low bit. 128 */ 129 enum SDL_PackedOrder { 130 SDL_PACKEDORDER_NONE, 131 SDL_PACKEDORDER_XRGB, 132 SDL_PACKEDORDER_RGBX, 133 SDL_PACKEDORDER_ARGB, 134 SDL_PACKEDORDER_RGBA, 135 SDL_PACKEDORDER_XBGR, 136 SDL_PACKEDORDER_BGRX, 137 SDL_PACKEDORDER_ABGR, 138 SDL_PACKEDORDER_BGRA 139 } 140 141 /** 142 Array component order, low byte -> high byte. 143 */ 144 enum SDL_ArrayOrder { 145 SDL_ARRAYORDER_NONE, 146 SDL_ARRAYORDER_RGB, 147 SDL_ARRAYORDER_RGBA, 148 SDL_ARRAYORDER_ARGB, 149 SDL_ARRAYORDER_BGR, 150 SDL_ARRAYORDER_BGRA, 151 SDL_ARRAYORDER_ABGR 152 } 153 154 /** 155 Packed component layout. 156 */ 157 enum SDL_PackedLayout { 158 SDL_PACKEDLAYOUT_NONE, 159 SDL_PACKEDLAYOUT_332, 160 SDL_PACKEDLAYOUT_4444, 161 SDL_PACKEDLAYOUT_1555, 162 SDL_PACKEDLAYOUT_5551, 163 SDL_PACKEDLAYOUT_565, 164 SDL_PACKEDLAYOUT_8888, 165 SDL_PACKEDLAYOUT_2101010, 166 SDL_PACKEDLAYOUT_1010102 167 } 168 169 /** 170 Pixel format. 171 172 SDL's pixel formats have the following naming convention: 173 174 - Names with a list of components and a single bit count, such as RGB24 and 175 ABGR32, define a platform-independent encoding into bytes in the order 176 specified. For example, in RGB24 data, each pixel is encoded in 3 bytes 177 (red, green, blue) in that order, and in ABGR32 data, each pixel is 178 encoded in 4 bytes (alpha, blue, green, red) in that order. Use these 179 names if the property of a format that is important to you is the order 180 of the bytes in memory or on disk. 181 - Names with a bit count per component, such as ARGB8888 and XRGB1555, are 182 "packed" into an appropriately-sized integer in the platform's native 183 endianness. For example, ARGB8888 is a sequence of 32-bit integers; in 184 each integer, the most significant bits are alpha, and the least 185 significant bits are blue. On a little-endian CPU such as x86, the least 186 significant bits of each integer are arranged first in memory, but on a 187 big-endian CPU such as s390x, the most significant bits are arranged 188 first. Use these names if the property of a format that is important to 189 you is the meaning of each bit position within a native-endianness 190 integer. 191 - In indexed formats such as INDEX4LSB, each pixel is represented by 192 encoding an index into the palette into the indicated number of bits, 193 with multiple pixels packed into each byte if appropriate. In LSB 194 formats, the first (leftmost) pixel is stored in the least-significant 195 bits of the byte; in MSB formats, it's stored in the most-significant 196 bits. INDEX8 does not need LSB/MSB variants, because each pixel exactly 197 fills one byte. 198 199 The 32-bit byte-array encodings such as RGBA32 are aliases for the 200 appropriate 8888 encoding for the current platform. For example, RGBA32 is 201 an alias for ABGR8888 on little-endian CPUs like x86, or an alias for 202 RGBA8888 on big-endian CPUs. 203 */ 204 enum SDL_PixelFormat { 205 SDL_PIXELFORMAT_UNKNOWN = 0, 206 SDL_PIXELFORMAT_INDEX1LSB = 0x11100100u, 207 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0, 1, 0), */ 208 SDL_PIXELFORMAT_INDEX1MSB = 0x11200100u, 209 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0, 1, 0), */ 210 SDL_PIXELFORMAT_INDEX2LSB = 0x1c100200u, 211 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX2, SDL_BITMAPORDER_4321, 0, 2, 0), */ 212 SDL_PIXELFORMAT_INDEX2MSB = 0x1c200200u, 213 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX2, SDL_BITMAPORDER_1234, 0, 2, 0), */ 214 SDL_PIXELFORMAT_INDEX4LSB = 0x12100400u, 215 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0, 4, 0), */ 216 SDL_PIXELFORMAT_INDEX4MSB = 0x12200400u, 217 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0, 4, 0), */ 218 SDL_PIXELFORMAT_INDEX8 = 0x13000801u, 219 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1), */ 220 SDL_PIXELFORMAT_RGB332 = 0x14110801u, 221 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_332, 8, 1), */ 222 SDL_PIXELFORMAT_XRGB4444 = 0x15120c02u, 223 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_4444, 12, 2), */ 224 SDL_PIXELFORMAT_XBGR4444 = 0x15520c02u, 225 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_4444, 12, 2), */ 226 SDL_PIXELFORMAT_XRGB1555 = 0x15130f02u, 227 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_1555, 15, 2), */ 228 SDL_PIXELFORMAT_XBGR1555 = 0x15530f02u, 229 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_1555, 15, 2), */ 230 SDL_PIXELFORMAT_ARGB4444 = 0x15321002u, 231 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_4444, 16, 2), */ 232 SDL_PIXELFORMAT_RGBA4444 = 0x15421002u, 233 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_4444, 16, 2), */ 234 SDL_PIXELFORMAT_ABGR4444 = 0x15721002u, 235 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_4444, 16, 2), */ 236 SDL_PIXELFORMAT_BGRA4444 = 0x15821002u, 237 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_4444, 16, 2), */ 238 SDL_PIXELFORMAT_ARGB1555 = 0x15331002u, 239 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_1555, 16, 2), */ 240 SDL_PIXELFORMAT_RGBA5551 = 0x15441002u, 241 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_5551, 16, 2), */ 242 SDL_PIXELFORMAT_ABGR1555 = 0x15731002u, 243 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_1555, 16, 2), */ 244 SDL_PIXELFORMAT_BGRA5551 = 0x15841002u, 245 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_5551, 16, 2), */ 246 SDL_PIXELFORMAT_RGB565 = 0x15151002u, 247 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_565, 16, 2), */ 248 SDL_PIXELFORMAT_BGR565 = 0x15551002u, 249 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_565, 16, 2), */ 250 SDL_PIXELFORMAT_RGB24 = 0x17101803u, 251 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0, 24, 3), */ 252 SDL_PIXELFORMAT_BGR24 = 0x17401803u, 253 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0, 24, 3), */ 254 SDL_PIXELFORMAT_XRGB8888 = 0x16161804u, 255 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_8888, 24, 4), */ 256 SDL_PIXELFORMAT_RGBX8888 = 0x16261804u, 257 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX, SDL_PACKEDLAYOUT_8888, 24, 4), */ 258 SDL_PIXELFORMAT_XBGR8888 = 0x16561804u, 259 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_8888, 24, 4), */ 260 SDL_PIXELFORMAT_BGRX8888 = 0x16661804u, 261 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX, SDL_PACKEDLAYOUT_8888, 24, 4), */ 262 SDL_PIXELFORMAT_ARGB8888 = 0x16362004u, 263 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_8888, 32, 4), */ 264 SDL_PIXELFORMAT_RGBA8888 = 0x16462004u, 265 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA, SDL_PACKEDLAYOUT_8888, 32, 4), */ 266 SDL_PIXELFORMAT_ABGR8888 = 0x16762004u, 267 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_8888, 32, 4), */ 268 SDL_PIXELFORMAT_BGRA8888 = 0x16862004u, 269 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA, SDL_PACKEDLAYOUT_8888, 32, 4), */ 270 SDL_PIXELFORMAT_XRGB2101010 = 0x16172004u, 271 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_2101010, 32, 4), */ 272 SDL_PIXELFORMAT_XBGR2101010 = 0x16572004u, 273 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_2101010, 32, 4), */ 274 SDL_PIXELFORMAT_ARGB2101010 = 0x16372004u, 275 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_2101010, 32, 4), */ 276 SDL_PIXELFORMAT_ABGR2101010 = 0x16772004u, 277 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_2101010, 32, 4), */ 278 SDL_PIXELFORMAT_RGB48 = 0x18103006u, 279 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_RGB, 0, 48, 6), */ 280 SDL_PIXELFORMAT_BGR48 = 0x18403006u, 281 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_BGR, 0, 48, 6), */ 282 SDL_PIXELFORMAT_RGBA64 = 0x18204008u, 283 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_RGBA, 0, 64, 8), */ 284 SDL_PIXELFORMAT_ARGB64 = 0x18304008u, 285 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_ARGB, 0, 64, 8), */ 286 SDL_PIXELFORMAT_BGRA64 = 0x18504008u, 287 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_BGRA, 0, 64, 8), */ 288 SDL_PIXELFORMAT_ABGR64 = 0x18604008u, 289 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU16, SDL_ARRAYORDER_ABGR, 0, 64, 8), */ 290 SDL_PIXELFORMAT_RGB48_FLOAT = 0x1a103006u, 291 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_RGB, 0, 48, 6), */ 292 SDL_PIXELFORMAT_BGR48_FLOAT = 0x1a403006u, 293 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_BGR, 0, 48, 6), */ 294 SDL_PIXELFORMAT_RGBA64_FLOAT = 0x1a204008u, 295 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_RGBA, 0, 64, 8), */ 296 SDL_PIXELFORMAT_ARGB64_FLOAT = 0x1a304008u, 297 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_ARGB, 0, 64, 8), */ 298 SDL_PIXELFORMAT_BGRA64_FLOAT = 0x1a504008u, 299 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_BGRA, 0, 64, 8), */ 300 SDL_PIXELFORMAT_ABGR64_FLOAT = 0x1a604008u, 301 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF16, SDL_ARRAYORDER_ABGR, 0, 64, 8), */ 302 SDL_PIXELFORMAT_RGB96_FLOAT = 0x1b10600cu, 303 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_RGB, 0, 96, 12), */ 304 SDL_PIXELFORMAT_BGR96_FLOAT = 0x1b40600cu, 305 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_BGR, 0, 96, 12), */ 306 SDL_PIXELFORMAT_RGBA128_FLOAT = 0x1b208010u, 307 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_RGBA, 0, 128, 16), */ 308 SDL_PIXELFORMAT_ARGB128_FLOAT = 0x1b308010u, 309 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_ARGB, 0, 128, 16), */ 310 SDL_PIXELFORMAT_BGRA128_FLOAT = 0x1b508010u, 311 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_BGRA, 0, 128, 16), */ 312 SDL_PIXELFORMAT_ABGR128_FLOAT = 0x1b608010u, 313 /* SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYF32, SDL_ARRAYORDER_ABGR, 0, 128, 16), */ 314 315 SDL_PIXELFORMAT_YV12 = 0x32315659u, /**< Planar mode: Y + V + U (3 planes) */ 316 /* SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'), */ 317 SDL_PIXELFORMAT_IYUV = 0x56555949u, /**< Planar mode: Y + U + V (3 planes) */ 318 /* SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'), */ 319 SDL_PIXELFORMAT_YUY2 = 0x32595559u, /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */ 320 /* SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'), */ 321 SDL_PIXELFORMAT_UYVY = 0x59565955u, /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ 322 /* SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'), */ 323 SDL_PIXELFORMAT_YVYU = 0x55595659u, /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ 324 /* SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U'), */ 325 SDL_PIXELFORMAT_NV12 = 0x3231564eu, /**< Planar mode: Y + U/V interleaved (2 planes) */ 326 /* SDL_DEFINE_PIXELFOURCC('N', 'V', '1', '2'), */ 327 SDL_PIXELFORMAT_NV21 = 0x3132564eu, /**< Planar mode: Y + V/U interleaved (2 planes) */ 328 /* SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1'), */ 329 SDL_PIXELFORMAT_P010 = 0x30313050u, /**< Planar mode: Y + U/V interleaved (2 planes) */ 330 /* SDL_DEFINE_PIXELFOURCC('P', '0', '1', '0'), */ 331 SDL_PIXELFORMAT_EXTERNAL_OES = 0x2053454fu, /**< Android video texture format */ 332 /* SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ') */ 333 334 /* Aliases for RGBA byte arrays of color data, for the current platform */ 335 SDL_PIXELFORMAT_RGBA32 = IsBigEndian ? SDL_PIXELFORMAT_RGBA8888 : SDL_PIXELFORMAT_ABGR8888, 336 SDL_PIXELFORMAT_ARGB32 = IsBigEndian ? SDL_PIXELFORMAT_ARGB8888 : SDL_PIXELFORMAT_BGRA8888, 337 SDL_PIXELFORMAT_BGRA32 = IsBigEndian ? SDL_PIXELFORMAT_BGRA8888 : SDL_PIXELFORMAT_ARGB8888, 338 SDL_PIXELFORMAT_ABGR32 = IsBigEndian ? SDL_PIXELFORMAT_ABGR8888 : SDL_PIXELFORMAT_RGBA8888, 339 SDL_PIXELFORMAT_RGBX32 = IsBigEndian ? SDL_PIXELFORMAT_RGBX8888 : SDL_PIXELFORMAT_XBGR8888, 340 SDL_PIXELFORMAT_XRGB32 = IsBigEndian ? SDL_PIXELFORMAT_XRGB8888 : SDL_PIXELFORMAT_BGRX8888, 341 SDL_PIXELFORMAT_BGRX32 = IsBigEndian ? SDL_PIXELFORMAT_BGRX8888 : SDL_PIXELFORMAT_XRGB8888, 342 SDL_PIXELFORMAT_XBGR32 = IsBigEndian ? SDL_PIXELFORMAT_XBGR8888 : SDL_PIXELFORMAT_RGBX8888 343 } 344 345 /** 346 Colorspace color type. 347 */ 348 enum SDL_ColorType { 349 SDL_COLOR_TYPE_UNKNOWN = 0, 350 SDL_COLOR_TYPE_RGB = 1, 351 SDL_COLOR_TYPE_YCBCR = 2 352 } 353 354 /** 355 Colorspace color range, as described by 356 https://www.itu.int/rec/R-REC-BT.2100-2-201807-I/en 357 */ 358 enum SDL_ColorRange { 359 SDL_COLOR_RANGE_UNKNOWN = 0, 360 SDL_COLOR_RANGE_LIMITED = 1, /**< Narrow range, e.g. 16-235 for 8-bit RGB and luma, and 16-240 for 8-bit chroma */ 361 SDL_COLOR_RANGE_FULL = 2 /**< Full range, e.g. 0-255 for 8-bit RGB and luma, and 1-255 for 8-bit chroma */ 362 } 363 364 /** 365 Colorspace color primaries, as described by 366 https://www.itu.int/rec/T-REC-H.273-201612-S/en 367 */ 368 enum SDL_ColorPrimaries { 369 SDL_COLOR_PRIMARIES_UNKNOWN = 0, 370 SDL_COLOR_PRIMARIES_BT709 = 1, /**< ITU-R BT.709-6 */ 371 SDL_COLOR_PRIMARIES_UNSPECIFIED = 2, 372 SDL_COLOR_PRIMARIES_BT470M = 4, /**< ITU-R BT.470-6 System M */ 373 SDL_COLOR_PRIMARIES_BT470BG = 5, /**< ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625 */ 374 SDL_COLOR_PRIMARIES_BT601 = 6, /**< ITU-R BT.601-7 525, SMPTE 170M */ 375 SDL_COLOR_PRIMARIES_SMPTE240 = 7, /**< SMPTE 240M, functionally the same as SDL_COLOR_PRIMARIES_BT601 */ 376 SDL_COLOR_PRIMARIES_GENERIC_FILM = 8, /**< Generic film (color filters using Illuminant C) */ 377 SDL_COLOR_PRIMARIES_BT2020 = 9, /**< ITU-R BT.2020-2 / ITU-R BT.2100-0 */ 378 SDL_COLOR_PRIMARIES_XYZ = 10, /**< SMPTE ST 428-1 */ 379 SDL_COLOR_PRIMARIES_SMPTE431 = 11, /**< SMPTE RP 431-2 */ 380 SDL_COLOR_PRIMARIES_SMPTE432 = 12, /**< SMPTE EG 432-1 / DCI P3 */ 381 SDL_COLOR_PRIMARIES_EBU3213 = 22, /**< EBU Tech. 3213-E */ 382 SDL_COLOR_PRIMARIES_CUSTOM = 31 383 } 384 385 /** 386 Colorspace transfer characteristics. 387 388 These are as described by https://www.itu.int/rec/T-REC-H.273-201612-S/en 389 */ 390 enum SDL_TransferCharacteristics { 391 SDL_TRANSFER_CHARACTERISTICS_UNKNOWN = 0, 392 SDL_TRANSFER_CHARACTERISTICS_BT709 = 1, /**< Rec. ITU-R BT.709-6 / ITU-R BT1361 */ 393 SDL_TRANSFER_CHARACTERISTICS_UNSPECIFIED = 2, 394 SDL_TRANSFER_CHARACTERISTICS_GAMMA22 = 4, /**< ITU-R BT.470-6 System M / ITU-R BT1700 625 PAL & SECAM */ 395 SDL_TRANSFER_CHARACTERISTICS_GAMMA28 = 5, /**< ITU-R BT.470-6 System B, G */ 396 SDL_TRANSFER_CHARACTERISTICS_BT601 = 6, /**< SMPTE ST 170M / ITU-R BT.601-7 525 or 625 */ 397 SDL_TRANSFER_CHARACTERISTICS_SMPTE240 = 7, /**< SMPTE ST 240M */ 398 SDL_TRANSFER_CHARACTERISTICS_LINEAR = 8, 399 SDL_TRANSFER_CHARACTERISTICS_LOG100 = 9, 400 SDL_TRANSFER_CHARACTERISTICS_LOG100_SQRT10 = 10, 401 SDL_TRANSFER_CHARACTERISTICS_IEC61966 = 11, /**< IEC 61966-2-4 */ 402 SDL_TRANSFER_CHARACTERISTICS_BT1361 = 12, /**< ITU-R BT1361 Extended Colour Gamut */ 403 SDL_TRANSFER_CHARACTERISTICS_SRGB = 13, /**< IEC 61966-2-1 (sRGB or sYCC) */ 404 SDL_TRANSFER_CHARACTERISTICS_BT2020_10BIT = 14, /**< ITU-R BT2020 for 10-bit system */ 405 SDL_TRANSFER_CHARACTERISTICS_BT2020_12BIT = 15, /**< ITU-R BT2020 for 12-bit system */ 406 SDL_TRANSFER_CHARACTERISTICS_PQ = 16, /**< SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems */ 407 SDL_TRANSFER_CHARACTERISTICS_SMPTE428 = 17, /**< SMPTE ST 428-1 */ 408 SDL_TRANSFER_CHARACTERISTICS_HLG = 18, /**< ARIB STD-B67, known as "hybrid log-gamma" (HLG) */ 409 SDL_TRANSFER_CHARACTERISTICS_CUSTOM = 31 410 } 411 412 /** 413 Colorspace matrix coefficients. 414 415 These are as described by https://www.itu.int/rec/T-REC-H.273-201612-S/en 416 */ 417 enum SDL_MatrixCoefficients { 418 SDL_MATRIX_COEFFICIENTS_IDENTITY = 0, 419 SDL_MATRIX_COEFFICIENTS_BT709 = 1, /**< ITU-R BT.709-6 */ 420 SDL_MATRIX_COEFFICIENTS_UNSPECIFIED = 2, 421 SDL_MATRIX_COEFFICIENTS_FCC = 4, /**< US FCC Title 47 */ 422 SDL_MATRIX_COEFFICIENTS_BT470BG = 5, /**< ITU-R BT.470-6 System B, G / ITU-R BT.601-7 625, functionally the same as SDL_MATRIX_COEFFICIENTS_BT601 */ 423 SDL_MATRIX_COEFFICIENTS_BT601 = 6, /**< ITU-R BT.601-7 525 */ 424 SDL_MATRIX_COEFFICIENTS_SMPTE240 = 7, /**< SMPTE 240M */ 425 SDL_MATRIX_COEFFICIENTS_YCGCO = 8, 426 SDL_MATRIX_COEFFICIENTS_BT2020_NCL = 9, /**< ITU-R BT.2020-2 non-constant luminance */ 427 SDL_MATRIX_COEFFICIENTS_BT2020_CL = 10, /**< ITU-R BT.2020-2 constant luminance */ 428 SDL_MATRIX_COEFFICIENTS_SMPTE2085 = 11, /**< SMPTE ST 2085 */ 429 SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_NCL = 12, 430 SDL_MATRIX_COEFFICIENTS_CHROMA_DERIVED_CL = 13, 431 SDL_MATRIX_COEFFICIENTS_ICTCP = 14, /**< ITU-R BT.2100-0 ICTCP */ 432 SDL_MATRIX_COEFFICIENTS_CUSTOM = 31 433 } 434 435 /** 436 Colorspace chroma sample location. 437 */ 438 enum SDL_ChromaLocation { 439 SDL_CHROMA_LOCATION_NONE = 0, /**< RGB, no chroma sampling */ 440 SDL_CHROMA_LOCATION_LEFT = 1, /**< In MPEG-2, MPEG-4, and AVC, Cb and Cr are taken on midpoint of the left-edge of the 2x2 square. In other words, they have the same horizontal location as the top-left pixel, but is shifted one-half pixel down vertically. */ 441 SDL_CHROMA_LOCATION_CENTER = 2, /**< In JPEG/JFIF, H.261, and MPEG-1, Cb and Cr are taken at the center of the 2x2 square. In other words, they are offset one-half pixel to the right and one-half pixel down compared to the top-left pixel. */ 442 SDL_CHROMA_LOCATION_TOPLEFT = 3 /**< In HEVC for BT.2020 and BT.2100 content (in particular on Blu-rays), Cb and Cr are sampled at the same location as the group's top-left Y pixel ("co-sited", "co-located"). */ 443 } 444 445 /** 446 Colorspace definitions. 447 448 Since similar colorspaces may vary in their details (matrix, transfer 449 function, etc.), this is not an exhaustive list, but rather a 450 representative sample of the kinds of colorspaces supported in SDL. 451 452 See_Also: 453 $(D SDL_ColorPrimaries) 454 $(D SDL_ColorRange) 455 $(D SDL_ColorType) 456 $(D SDL_MatrixCoefficients) 457 $(D SDL_TransferCharacteristics) 458 */ 459 enum SDL_Colorspace { 460 SDL_COLORSPACE_UNKNOWN = 0, 461 462 /* sRGB is a gamma corrected colorspace, and the default colorspace for SDL rendering and 8-bit RGB surfaces */ 463 SDL_COLORSPACE_SRGB = 0x120005a0u, /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709 */ 464 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB, 465 SDL_COLOR_RANGE_FULL, 466 SDL_COLOR_PRIMARIES_BT709, 467 SDL_TRANSFER_CHARACTERISTICS_SRGB, 468 SDL_MATRIX_COEFFICIENTS_IDENTITY, 469 SDL_CHROMA_LOCATION_NONE), */ 470 471 /* This is a linear colorspace and the default colorspace for floating point surfaces. On Windows this is the scRGB colorspace, and on Apple platforms this is kCGColorSpaceExtendedLinearSRGB for EDR content */ 472 SDL_COLORSPACE_SRGB_LINEAR = 0x12000500u, /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709 */ 473 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB, 474 SDL_COLOR_RANGE_FULL, 475 SDL_COLOR_PRIMARIES_BT709, 476 SDL_TRANSFER_CHARACTERISTICS_LINEAR, 477 SDL_MATRIX_COEFFICIENTS_IDENTITY, 478 SDL_CHROMA_LOCATION_NONE), */ 479 480 /* HDR10 is a non-linear HDR colorspace and the default colorspace for 10-bit surfaces */ 481 SDL_COLORSPACE_HDR10 = 0x12002600u, /**< Equivalent to DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020 */ 482 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_RGB, 483 SDL_COLOR_RANGE_FULL, 484 SDL_COLOR_PRIMARIES_BT2020, 485 SDL_TRANSFER_CHARACTERISTICS_PQ, 486 SDL_MATRIX_COEFFICIENTS_IDENTITY, 487 SDL_CHROMA_LOCATION_NONE), */ 488 489 SDL_COLORSPACE_JPEG = 0x220004c6u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601 */ 490 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, 491 SDL_COLOR_RANGE_FULL, 492 SDL_COLOR_PRIMARIES_BT709, 493 SDL_TRANSFER_CHARACTERISTICS_BT601, 494 SDL_MATRIX_COEFFICIENTS_BT601, 495 SDL_CHROMA_LOCATION_NONE), */ 496 497 SDL_COLORSPACE_BT601_LIMITED = 0x211018c6u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601 */ 498 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, 499 SDL_COLOR_RANGE_LIMITED, 500 SDL_COLOR_PRIMARIES_BT601, 501 SDL_TRANSFER_CHARACTERISTICS_BT601, 502 SDL_MATRIX_COEFFICIENTS_BT601, 503 SDL_CHROMA_LOCATION_LEFT), */ 504 505 SDL_COLORSPACE_BT601_FULL = 0x221018c6u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601 */ 506 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, 507 SDL_COLOR_RANGE_FULL, 508 SDL_COLOR_PRIMARIES_BT601, 509 SDL_TRANSFER_CHARACTERISTICS_BT601, 510 SDL_MATRIX_COEFFICIENTS_BT601, 511 SDL_CHROMA_LOCATION_LEFT), */ 512 513 SDL_COLORSPACE_BT709_LIMITED = 0x21100421u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709 */ 514 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, 515 SDL_COLOR_RANGE_LIMITED, 516 SDL_COLOR_PRIMARIES_BT709, 517 SDL_TRANSFER_CHARACTERISTICS_BT709, 518 SDL_MATRIX_COEFFICIENTS_BT709, 519 SDL_CHROMA_LOCATION_LEFT), */ 520 521 SDL_COLORSPACE_BT709_FULL = 0x22100421u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709 */ 522 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, 523 SDL_COLOR_RANGE_FULL, 524 SDL_COLOR_PRIMARIES_BT709, 525 SDL_TRANSFER_CHARACTERISTICS_BT709, 526 SDL_MATRIX_COEFFICIENTS_BT709, 527 SDL_CHROMA_LOCATION_LEFT), */ 528 529 SDL_COLORSPACE_BT2020_LIMITED = 0x21102609u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020 */ 530 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, 531 SDL_COLOR_RANGE_LIMITED, 532 SDL_COLOR_PRIMARIES_BT2020, 533 SDL_TRANSFER_CHARACTERISTICS_PQ, 534 SDL_MATRIX_COEFFICIENTS_BT2020_NCL, 535 SDL_CHROMA_LOCATION_LEFT), */ 536 537 SDL_COLORSPACE_BT2020_FULL = 0x22102609u, /**< Equivalent to DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020 */ 538 /* SDL_DEFINE_COLORSPACE(SDL_COLOR_TYPE_YCBCR, 539 SDL_COLOR_RANGE_FULL, 540 SDL_COLOR_PRIMARIES_BT2020, 541 SDL_TRANSFER_CHARACTERISTICS_PQ, 542 SDL_MATRIX_COEFFICIENTS_BT2020_NCL, 543 SDL_CHROMA_LOCATION_LEFT), */ 544 545 SDL_COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_SRGB, /**< The default colorspace for RGB surfaces if no colorspace is specified */ 546 SDL_COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_JPEG /**< The default colorspace for YUV surfaces if no colorspace is specified */ 547 } 548 549 /** 550 A structure that represents a color as RGBA components. 551 552 The bits of this structure can be directly reinterpreted as an 553 integer-packed color which uses the SDL_PIXELFORMAT_RGBA32 format 554 (SDL_PIXELFORMAT_ABGR8888 on little-endian systems and 555 SDL_PIXELFORMAT_RGBA8888 on big-endian systems). 556 */ 557 struct SDL_Color { 558 Uint8 r; 559 Uint8 g; 560 Uint8 b; 561 Uint8 a; 562 } 563 564 /** 565 * The bits of this structure can be directly reinterpreted as a float-packed 566 * color which uses the SDL_PIXELFORMAT_RGBA128_FLOAT format 567 */ 568 struct SDL_FColor { 569 float r; 570 float g; 571 float b; 572 float a; 573 } 574 575 /** 576 A set of indexed colors representing a palette. 577 578 See_Also: 579 $(D SDL_SetPaletteColors) 580 */ 581 struct SDL_Palette { 582 int ncolors; /**< number of elements in `colors`. */ 583 SDL_Color* colors; /**< an array of colors, `ncolors` long. */ 584 Uint32 version_; /**< internal use only, do not touch. */ 585 int refcount; /**< internal use only, do not touch. */ 586 } 587 588 /** 589 Details about the format of a pixel. 590 */ 591 struct SDL_PixelFormatDetails { 592 SDL_PixelFormat format; 593 Uint8 bits_per_pixel; 594 Uint8 bytes_per_pixel; 595 Uint8[2] padding; 596 Uint32 Rmask; 597 Uint32 Gmask; 598 Uint32 Bmask; 599 Uint32 Amask; 600 Uint8 Rbits; 601 Uint8 Gbits; 602 Uint8 Bbits; 603 Uint8 Abits; 604 Uint8 Rshift; 605 Uint8 Gshift; 606 Uint8 Bshift; 607 Uint8 Ashift; 608 } 609 610 /** 611 Get the human readable name of a pixel format. 612 613 Params: 614 format = the pixel format to query. 615 616 Returns: 617 The human readable name of the specified pixel format or 618 "SDL_PIXELFORMAT_UNKNOWN" if the format isn't recognized. 619 620 Threadsafety: 621 It is safe to call this function from any thread. 622 */ 623 extern const(char)* SDL_GetPixelFormatName(SDL_PixelFormat format); 624 625 /** 626 Convert one of the enumerated pixel formats to a bpp value and RGBA masks. 627 628 Params: 629 format = one of the SDL_PixelFormat values. 630 bpp = a bits per pixel value; usually 15, 16, or 32. 631 Rmask = a pointer filled in with the red mask for the format. 632 Gmask = a pointer filled in with the green mask for the format. 633 Bmask = a pointer filled in with the blue mask for the format. 634 Amask = a pointer filled in with the alpha mask for the format. 635 636 Returns: 637 true on success or false on failure; call SDL_GetError() for more 638 information. 639 640 Threadsafety: 641 It is safe to call this function from any thread. 642 643 See_Also: 644 $(D SDL_GetPixelFormatForMasks) 645 */ 646 extern bool SDL_GetMasksForPixelFormat(SDL_PixelFormat format, int* bpp, Uint32* Rmask, Uint32* Gmask, Uint32* Bmask, Uint32* Amask); 647 648 /** 649 Convert a bpp value and RGBA masks to an enumerated pixel format. 650 651 This will return `SDL_PIXELFORMAT_UNKNOWN` if the conversion wasn't 652 possible. 653 654 Params: 655 bpp = a bits per pixel value; usually 15, 16, or 32. 656 Rmask = the red mask for the format. 657 Gmask = the green mask for the format. 658 Bmask = the blue mask for the format. 659 Amask = the alpha mask for the format. 660 661 Returns: 662 the SDL_PixelFormat value corresponding to the format masks, or 663 SDL_PIXELFORMAT_UNKNOWN if there isn't a match. 664 665 Threadsafety: 666 It is safe to call this function from any thread. 667 668 See_Also: 669 $(D SDL_GetMasksForPixelFormat) 670 */ 671 extern SDL_PixelFormat SDL_GetPixelFormatForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); 672 673 /** 674 Create an SDL_PixelFormatDetails structure corresponding to a pixel format. 675 676 Returned structure may come from a shared global cache (i.e. not newly 677 allocated), and hence should not be modified, especially the palette. Weird 678 errors such as `Blit combination not supported` may occur. 679 680 Params: 681 format = one of the SDL_PixelFormat values. 682 683 Returns: 684 a pointer to a SDL_PixelFormatDetails structure or NULL on 685 failure; call SDL_GetError() for more information. 686 687 Threadsafety: 688 It is safe to call this function from any thread. 689 */ 690 extern const(SDL_PixelFormatDetails)* SDL_GetPixelFormatDetails(SDL_PixelFormat format); 691 692 /** 693 Create a palette structure with the specified number of color entries. 694 695 The palette entries are initialized to white. 696 697 Params: 698 ncolors = represents the number of color entries in the color palette. 699 700 Returns: 701 a new SDL_Palette structure on success or NULL on failure (e.g. if 702 there wasn't enough memory); call SDL_GetError() for more 703 information. 704 705 Threadsafety: 706 It is safe to call this function from any thread. 707 708 See_Also: 709 $(D SDL_DestroyPalette) 710 $(D SDL_SetPaletteColors) 711 $(D SDL_SetSurfacePalette) 712 */ 713 extern SDL_Palette* SDL_CreatePalette(int ncolors); 714 715 /** 716 Set a range of colors in a palette. 717 718 Params: 719 palette = the SDL_Palette structure to modify. 720 colors = an array of SDL_Color structures to copy into the palette. 721 firstcolor = the index of the first palette entry to modify. 722 ncolors = the number of entries to modify. 723 724 Returns: 725 true on success or false on failure; call SDL_GetError() for more 726 information. 727 728 Threadsafety: 729 It is safe to call this function from any thread, as long as 730 the palette is not modified or destroyed in another thread. 731 */ 732 extern bool SDL_SetPaletteColors(SDL_Palette* palette, const(SDL_Color)* colors, int firstcolor, int ncolors); 733 734 /** 735 Free a palette created with SDL_CreatePalette(). 736 737 Params: 738 palette the SDL_Palette structure to be freed. 739 740 Threadsafety: 741 It is safe to call this function from any thread, as long as 742 the palette is not modified or destroyed in another thread. 743 744 See_Also: 745 $(D SDL_CreatePalette) 746 */ 747 extern void SDL_DestroyPalette(SDL_Palette* palette); 748 749 /** 750 Map an RGB triple to an opaque pixel value for a given pixel format. 751 752 This function maps the RGB color value to the specified pixel format and 753 returns the pixel value best approximating the given RGB color value for 754 the given pixel format. 755 756 If the format has a palette (8-bit) the index of the closest matching color 757 in the palette will be returned. 758 759 If the specified pixel format has an alpha component it will be returned as 760 all 1 bits (fully opaque). 761 762 If the pixel format bpp (color depth) is less than 32-bpp then the unused 763 upper bits of the return value can safely be ignored (e.g., with a 16-bpp 764 format the return value can be assigned to a Uint16, and similarly a Uint8 765 for an 8-bpp format). 766 767 Params: 768 format = a pointer to SDL_PixelFormatDetails describing the pixel 769 format. 770 palette = an optional palette for indexed formats, may be NULL. 771 r = the red component of the pixel in the range 0-255. 772 g = the green component of the pixel in the range 0-255. 773 b = the blue component of the pixel in the range 0-255. 774 775 Returns: 776 a pixel value. 777 778 Threadsafety: 779 It is safe to call this function from any thread, as long as 780 the palette is not modified. 781 782 See_Also: 783 $(D SDL_GetPixelFormatDetails) 784 $(D SDL_GetRGB) 785 $(D SDL_MapRGBA) 786 $(D SDL_MapSurfaceRGB) 787 */ 788 extern Uint32 SDL_MapRGB(const(SDL_PixelFormatDetails)* format, const(SDL_Palette)* palette, Uint8 r, Uint8 g, Uint8 b); 789 790 /** 791 Map an RGBA quadruple to a pixel value for a given pixel format. 792 793 This function maps the RGBA color value to the specified pixel format and 794 returns the pixel value best approximating the given RGBA color value for 795 the given pixel format. 796 797 If the specified pixel format has no alpha component the alpha value will 798 be ignored (as it will be in formats with a palette). 799 800 If the format has a palette (8-bit) the index of the closest matching color 801 in the palette will be returned. 802 803 If the pixel format bpp (color depth) is less than 32-bpp then the unused 804 upper bits of the return value can safely be ignored (e.g., with a 16-bpp 805 format the return value can be assigned to a Uint16, and similarly a Uint8 806 for an 8-bpp format). 807 808 Params: 809 format a pointer to SDL_PixelFormatDetails describing the pixel 810 format. 811 palette = an optional palette for indexed formats, may be NULL. 812 r = the red component of the pixel in the range 0-255. 813 g = the green component of the pixel in the range 0-255. 814 b = the blue component of the pixel in the range 0-255. 815 a = the alpha component of the pixel in the range 0-255. 816 817 Returns: 818 a pixel value. 819 820 Threadsafety: 821 It is safe to call this function from any thread, as long as 822 the palette is not modified. 823 824 See_Also: 825 $(D SDL_GetPixelFormatDetails) 826 $(D SDL_GetRGBA) 827 $(D SDL_MapRGB) 828 $(D SDL_MapSurfaceRGBA) 829 */ 830 extern Uint32 SDL_MapRGBA(const(SDL_PixelFormatDetails)* format, const(SDL_Palette)* palette, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 831 832 /** 833 Get RGB values from a pixel in the specified format. 834 835 This function uses the entire 8-bit [0..255] range when converting color 836 components from pixel formats with less than 8-bits per RGB component 837 (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, 838 0xff, 0xff] not [0xf8, 0xfc, 0xf8]). 839 840 Params: 841 pixel = a pixel value. 842 format = a pointer to SDL_PixelFormatDetails describing the pixel 843 format. 844 palette = an optional palette for indexed formats, may be NULL. 845 r = a pointer filled in with the red component, may be NULL. 846 g = a pointer filled in with the green component, may be NULL. 847 b = a pointer filled in with the blue component, may be NULL. 848 849 Threadsafety: 850 It is safe to call this function from any thread, as long as 851 the palette is not modified. 852 853 See_Also: 854 $(D SDL_GetPixelFormatDetails) 855 $(D SDL_GetRGBA) 856 $(D SDL_MapRGB) 857 $(D SDL_MapRGBA) 858 */ 859 extern void SDL_GetRGB(Uint32 pixel, const(SDL_PixelFormatDetails)* format, const(SDL_Palette)* palette, Uint8* r, Uint8* g, Uint8* b); 860 861 /** 862 Get RGBA values from a pixel in the specified format. 863 864 This function uses the entire 8-bit [0..255] range when converting color 865 components from pixel formats with less than 8-bits per RGB component 866 (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, 867 0xff, 0xff] not [0xf8, 0xfc, 0xf8]). 868 869 If the surface has no alpha component, the alpha will be returned as 0xff 870 (100% opaque). 871 872 Params: 873 pixel = a pixel value. 874 format = a pointer to SDL_PixelFormatDetails describing the pixel 875 format. 876 palette = an optional palette for indexed formats, may be NULL. 877 r = a pointer filled in with the red component, may be NULL. 878 g = a pointer filled in with the green component, may be NULL. 879 b = a pointer filled in with the blue component, may be NULL. 880 a = a pointer filled in with the alpha component, may be NULL. 881 882 Threadsafety: 883 It is safe to call this function from any thread, as long as 884 the palette is not modified. 885 886 See_Also: 887 $(D SDL_GetPixelFormatDetails) 888 $(D SDL_GetRGB) 889 $(D SDL_MapRGB) 890 $(D SDL_MapRGBA) 891 */ 892 extern void SDL_GetRGBA(Uint32 pixel, const(SDL_PixelFormatDetails)* format, const(SDL_Palette)* palette, Uint8* r, Uint8* g, Uint8* b, Uint8* a);