include/SDL_pixels.h
author Steven M. Vascellaro <svascellaro@gmail.com>
Mon, 22 Oct 2018 10:55:18 -0400
changeset 12379 5dc13016cf34
parent 11811 5d94cb6b24d3
child 12408 b590d04d5cf7
permissions -rw-r--r--
joystick: Add Linux mappings for "Xbox One Wireless Controller (Model 1708)"

Adds controller bindings to support the "Xbox One Wireless Controller
(Model 1708)" on Linux. The Model 1708 was released in 2016 alongside the
Xbox One S. It is the current model being sold by Microsoft as of writing.
(October 22, 2018)
slouken@1895
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@11811
     3
  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
slouken@1895
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@1895
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@1895
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@1895
    20
*/
slouken@1895
    21
slouken@1895
    22
/**
slouken@3407
    23
 *  \file SDL_pixels.h
slouken@7191
    24
 *
slouken@3407
    25
 *  Header for the enumerated pixel format definitions.
slouken@1895
    26
 */
slouken@1895
    27
slouken@10638
    28
#ifndef SDL_pixels_h_
slouken@10638
    29
#define SDL_pixels_h_
slouken@1895
    30
icculus@8175
    31
#include "SDL_stdinc.h"
slouken@10512
    32
#include "SDL_endian.h"
icculus@8175
    33
slouken@1895
    34
#include "begin_code.h"
slouken@1895
    35
/* Set up for C function definitions, even when using C++ */
slouken@1895
    36
#ifdef __cplusplus
slouken@1895
    37
extern "C" {
slouken@1895
    38
#endif
slouken@1895
    39
slouken@3407
    40
/**
slouken@3407
    41
 *  \name Transparency definitions
slouken@7191
    42
 *
slouken@3407
    43
 *  These define alpha as the opacity of a surface.
slouken@3407
    44
 */
gabomdq@7678
    45
/* @{ */
slouken@2275
    46
#define SDL_ALPHA_OPAQUE 255
slouken@2275
    47
#define SDL_ALPHA_TRANSPARENT 0
gabomdq@7678
    48
/* @} */
slouken@2275
    49
slouken@3407
    50
/** Pixel type. */
slouken@1895
    51
enum
slouken@3407
    52
{
slouken@1965
    53
    SDL_PIXELTYPE_UNKNOWN,
slouken@1965
    54
    SDL_PIXELTYPE_INDEX1,
slouken@1965
    55
    SDL_PIXELTYPE_INDEX4,
slouken@1965
    56
    SDL_PIXELTYPE_INDEX8,
slouken@1965
    57
    SDL_PIXELTYPE_PACKED8,
slouken@1965
    58
    SDL_PIXELTYPE_PACKED16,
slouken@1965
    59
    SDL_PIXELTYPE_PACKED32,
slouken@1965
    60
    SDL_PIXELTYPE_ARRAYU8,
slouken@1965
    61
    SDL_PIXELTYPE_ARRAYU16,
slouken@1965
    62
    SDL_PIXELTYPE_ARRAYU32,
slouken@1965
    63
    SDL_PIXELTYPE_ARRAYF16,
slouken@2208
    64
    SDL_PIXELTYPE_ARRAYF32
slouken@1895
    65
};
slouken@1895
    66
slouken@3407
    67
/** Bitmap pixel order, high bit -> low bit. */
slouken@1895
    68
enum
slouken@3407
    69
{
slouken@1965
    70
    SDL_BITMAPORDER_NONE,
slouken@1965
    71
    SDL_BITMAPORDER_4321,
slouken@2208
    72
    SDL_BITMAPORDER_1234
slouken@1895
    73
};
slouken@3407
    74
slouken@3407
    75
/** Packed component order, high bit -> low bit. */
slouken@1895
    76
enum
slouken@3407
    77
{
slouken@1965
    78
    SDL_PACKEDORDER_NONE,
slouken@1965
    79
    SDL_PACKEDORDER_XRGB,
slouken@1965
    80
    SDL_PACKEDORDER_RGBX,
slouken@1965
    81
    SDL_PACKEDORDER_ARGB,
slouken@1965
    82
    SDL_PACKEDORDER_RGBA,
slouken@1965
    83
    SDL_PACKEDORDER_XBGR,
slouken@1965
    84
    SDL_PACKEDORDER_BGRX,
slouken@1965
    85
    SDL_PACKEDORDER_ABGR,
slouken@2208
    86
    SDL_PACKEDORDER_BGRA
slouken@1895
    87
};
slouken@3407
    88
slouken@3407
    89
/** Array component order, low byte -> high byte. */
icculus@9687
    90
/* !!! FIXME: in 2.1, make these not overlap differently with
icculus@9687
    91
   !!! FIXME:  SDL_PACKEDORDER_*, so we can simplify SDL_ISPIXELFORMAT_ALPHA */
slouken@1895
    92
enum
slouken@3407
    93
{
slouken@1965
    94
    SDL_ARRAYORDER_NONE,
slouken@1965
    95
    SDL_ARRAYORDER_RGB,
slouken@1965
    96
    SDL_ARRAYORDER_RGBA,
slouken@1965
    97
    SDL_ARRAYORDER_ARGB,
slouken@1965
    98
    SDL_ARRAYORDER_BGR,
slouken@1965
    99
    SDL_ARRAYORDER_BGRA,
slouken@2208
   100
    SDL_ARRAYORDER_ABGR
slouken@1895
   101
};
slouken@1895
   102
slouken@3407
   103
/** Packed component layout. */
slouken@1895
   104
enum
slouken@3407
   105
{
slouken@1965
   106
    SDL_PACKEDLAYOUT_NONE,
slouken@1965
   107
    SDL_PACKEDLAYOUT_332,
slouken@1965
   108
    SDL_PACKEDLAYOUT_4444,
slouken@1965
   109
    SDL_PACKEDLAYOUT_1555,
slouken@1965
   110
    SDL_PACKEDLAYOUT_5551,
slouken@1965
   111
    SDL_PACKEDLAYOUT_565,
slouken@1965
   112
    SDL_PACKEDLAYOUT_8888,
slouken@1965
   113
    SDL_PACKEDLAYOUT_2101010,
slouken@2208
   114
    SDL_PACKEDLAYOUT_1010102
slouken@1895
   115
};
slouken@1895
   116
slouken@4492
   117
#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D)
slouken@1895
   118
slouken@1895
   119
#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
slouken@6683
   120
    ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
slouken@1895
   121
     ((bits) << 8) | ((bytes) << 0))
slouken@1895
   122
slouken@7191
   123
#define SDL_PIXELFLAG(X)    (((X) >> 28) & 0x0F)
slouken@7191
   124
#define SDL_PIXELTYPE(X)    (((X) >> 24) & 0x0F)
slouken@7191
   125
#define SDL_PIXELORDER(X)   (((X) >> 20) & 0x0F)
slouken@7191
   126
#define SDL_PIXELLAYOUT(X)  (((X) >> 16) & 0x0F)
slouken@7191
   127
#define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF)
slouken@5156
   128
#define SDL_BYTESPERPIXEL(X) \
slouken@5156
   129
    (SDL_ISPIXELFORMAT_FOURCC(X) ? \
slouken@5264
   130
        ((((X) == SDL_PIXELFORMAT_YUY2) || \
slouken@5156
   131
          ((X) == SDL_PIXELFORMAT_UYVY) || \
slouken@5156
   132
          ((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF))
slouken@1895
   133
slouken@1895
   134
#define SDL_ISPIXELFORMAT_INDEXED(format)   \
slouken@5156
   135
    (!SDL_ISPIXELFORMAT_FOURCC(format) && \
slouken@5156
   136
     ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
slouken@5156
   137
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
slouken@5156
   138
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8)))
slouken@1895
   139
icculus@9687
   140
#define SDL_ISPIXELFORMAT_PACKED(format) \
icculus@9687
   141
    (!SDL_ISPIXELFORMAT_FOURCC(format) && \
icculus@9687
   142
     ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED8) || \
icculus@9687
   143
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED16) || \
icculus@9687
   144
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32)))
icculus@9687
   145
icculus@9687
   146
#define SDL_ISPIXELFORMAT_ARRAY(format) \
icculus@9687
   147
    (!SDL_ISPIXELFORMAT_FOURCC(format) && \
icculus@9687
   148
     ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU8) || \
icculus@9687
   149
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU16) || \
icculus@9687
   150
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU32) || \
icculus@9687
   151
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \
icculus@9687
   152
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32)))
icculus@9687
   153
slouken@3054
   154
#define SDL_ISPIXELFORMAT_ALPHA(format)   \
icculus@9687
   155
    ((SDL_ISPIXELFORMAT_PACKED(format) && \
slouken@5156
   156
     ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
slouken@5156
   157
      (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
slouken@5156
   158
      (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
icculus@9687
   159
      (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))) || \
icculus@9687
   160
    (SDL_ISPIXELFORMAT_ARRAY(format) && \
icculus@9687
   161
     ((SDL_PIXELORDER(format) == SDL_ARRAYORDER_ARGB) || \
icculus@9687
   162
      (SDL_PIXELORDER(format) == SDL_ARRAYORDER_RGBA) || \
icculus@9687
   163
      (SDL_PIXELORDER(format) == SDL_ARRAYORDER_ABGR) || \
icculus@9687
   164
      (SDL_PIXELORDER(format) == SDL_ARRAYORDER_BGRA))))
slouken@3054
   165
slouken@6683
   166
/* The flag is set to 1 because 0x1? is not in the printable ASCII range */
slouken@1895
   167
#define SDL_ISPIXELFORMAT_FOURCC(format)    \
slouken@6683
   168
    ((format) && (SDL_PIXELFLAG(format) != 1))
slouken@1895
   169
slouken@4982
   170
/* Note: If you modify this list, update SDL_GetPixelFormatName() */
slouken@1895
   171
enum
slouken@1895
   172
{
slouken@1965
   173
    SDL_PIXELFORMAT_UNKNOWN,
slouken@1965
   174
    SDL_PIXELFORMAT_INDEX1LSB =
slouken@5438
   175
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0,
slouken@5438
   176
                               1, 0),
slouken@5438
   177
    SDL_PIXELFORMAT_INDEX1MSB =
slouken@1965
   178
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0,
slouken@1895
   179
                               1, 0),
slouken@1965
   180
    SDL_PIXELFORMAT_INDEX4LSB =
slouken@5438
   181
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0,
slouken@3177
   182
                               4, 0),
slouken@1965
   183
    SDL_PIXELFORMAT_INDEX4MSB =
slouken@5438
   184
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0,
slouken@3177
   185
                               4, 0),
slouken@1965
   186
    SDL_PIXELFORMAT_INDEX8 =
slouken@1965
   187
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1),
slouken@1965
   188
    SDL_PIXELFORMAT_RGB332 =
slouken@1965
   189
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB,
slouken@1965
   190
                               SDL_PACKEDLAYOUT_332, 8, 1),
slouken@1965
   191
    SDL_PIXELFORMAT_RGB444 =
slouken@1965
   192
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
slouken@1965
   193
                               SDL_PACKEDLAYOUT_4444, 12, 2),
slouken@1965
   194
    SDL_PIXELFORMAT_RGB555 =
slouken@1965
   195
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
slouken@1965
   196
                               SDL_PACKEDLAYOUT_1555, 15, 2),
slouken@2735
   197
    SDL_PIXELFORMAT_BGR555 =
slouken@2735
   198
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
slouken@2735
   199
                               SDL_PACKEDLAYOUT_1555, 15, 2),
slouken@1965
   200
    SDL_PIXELFORMAT_ARGB4444 =
slouken@1965
   201
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
slouken@1965
   202
                               SDL_PACKEDLAYOUT_4444, 16, 2),
slouken@4982
   203
    SDL_PIXELFORMAT_RGBA4444 =
slouken@4982
   204
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
slouken@4982
   205
                               SDL_PACKEDLAYOUT_4444, 16, 2),
lestat@3163
   206
    SDL_PIXELFORMAT_ABGR4444 =
lestat@3163
   207
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
lestat@3163
   208
                               SDL_PACKEDLAYOUT_4444, 16, 2),
slouken@4982
   209
    SDL_PIXELFORMAT_BGRA4444 =
slouken@4982
   210
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA,
slouken@4982
   211
                               SDL_PACKEDLAYOUT_4444, 16, 2),
slouken@1965
   212
    SDL_PIXELFORMAT_ARGB1555 =
slouken@1965
   213
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
slouken@1965
   214
                               SDL_PACKEDLAYOUT_1555, 16, 2),
slouken@4982
   215
    SDL_PIXELFORMAT_RGBA5551 =
slouken@4982
   216
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
slouken@4982
   217
                               SDL_PACKEDLAYOUT_5551, 16, 2),
slouken@2735
   218
    SDL_PIXELFORMAT_ABGR1555 =
slouken@2735
   219
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
slouken@2735
   220
                               SDL_PACKEDLAYOUT_1555, 16, 2),
slouken@4982
   221
    SDL_PIXELFORMAT_BGRA5551 =
slouken@4982
   222
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA,
slouken@4982
   223
                               SDL_PACKEDLAYOUT_5551, 16, 2),
slouken@1965
   224
    SDL_PIXELFORMAT_RGB565 =
slouken@1965
   225
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
slouken@1965
   226
                               SDL_PACKEDLAYOUT_565, 16, 2),
lestat@3163
   227
    SDL_PIXELFORMAT_BGR565 =
lestat@3163
   228
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
lestat@3163
   229
                               SDL_PACKEDLAYOUT_565, 16, 2),
slouken@1965
   230
    SDL_PIXELFORMAT_RGB24 =
slouken@1965
   231
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0,
slouken@1895
   232
                               24, 3),
slouken@1965
   233
    SDL_PIXELFORMAT_BGR24 =
slouken@1965
   234
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0,
slouken@1895
   235
                               24, 3),
slouken@1965
   236
    SDL_PIXELFORMAT_RGB888 =
slouken@1965
   237
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB,
slouken@1965
   238
                               SDL_PACKEDLAYOUT_8888, 24, 4),
slouken@6074
   239
    SDL_PIXELFORMAT_RGBX8888 =
slouken@6074
   240
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX,
slouken@6074
   241
                               SDL_PACKEDLAYOUT_8888, 24, 4),
slouken@1965
   242
    SDL_PIXELFORMAT_BGR888 =
slouken@1965
   243
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR,
slouken@1965
   244
                               SDL_PACKEDLAYOUT_8888, 24, 4),
slouken@6074
   245
    SDL_PIXELFORMAT_BGRX8888 =
slouken@6074
   246
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX,
slouken@6074
   247
                               SDL_PACKEDLAYOUT_8888, 24, 4),
slouken@1965
   248
    SDL_PIXELFORMAT_ARGB8888 =
slouken@1965
   249
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
slouken@1965
   250
                               SDL_PACKEDLAYOUT_8888, 32, 4),
slouken@1965
   251
    SDL_PIXELFORMAT_RGBA8888 =
slouken@1965
   252
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA,
slouken@1965
   253
                               SDL_PACKEDLAYOUT_8888, 32, 4),
slouken@1965
   254
    SDL_PIXELFORMAT_ABGR8888 =
slouken@1965
   255
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR,
slouken@1965
   256
                               SDL_PACKEDLAYOUT_8888, 32, 4),
slouken@1965
   257
    SDL_PIXELFORMAT_BGRA8888 =
slouken@1965
   258
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA,
slouken@1965
   259
                               SDL_PACKEDLAYOUT_8888, 32, 4),
slouken@1965
   260
    SDL_PIXELFORMAT_ARGB2101010 =
slouken@1965
   261
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
slouken@1965
   262
                               SDL_PACKEDLAYOUT_2101010, 32, 4),
slouken@1895
   263
slouken@10513
   264
    /* Aliases for RGBA byte arrays of color data, for the current platform */
slouken@10512
   265
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
slouken@10513
   266
    SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_RGBA8888,
slouken@10512
   267
    SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB8888,
slouken@10512
   268
    SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA8888,
slouken@10512
   269
    SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR8888,
slouken@10512
   270
#else
slouken@10512
   271
    SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_ABGR8888,
slouken@10512
   272
    SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_BGRA8888,
slouken@10512
   273
    SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_ARGB8888,
slouken@10512
   274
    SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_RGBA8888,
slouken@10512
   275
#endif
slouken@10512
   276
slouken@3407
   277
    SDL_PIXELFORMAT_YV12 =      /**< Planar mode: Y + V + U  (3 planes) */
slouken@1895
   278
        SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'),
slouken@3407
   279
    SDL_PIXELFORMAT_IYUV =      /**< Planar mode: Y + U + V  (3 planes) */
slouken@1895
   280
        SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'),
slouken@3407
   281
    SDL_PIXELFORMAT_YUY2 =      /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
slouken@1895
   282
        SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'),
slouken@3407
   283
    SDL_PIXELFORMAT_UYVY =      /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
slouken@1895
   284
        SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'),
slouken@3407
   285
    SDL_PIXELFORMAT_YVYU =      /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
slouken@9046
   286
        SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U'),
slouken@9046
   287
    SDL_PIXELFORMAT_NV12 =      /**< Planar mode: Y + U/V interleaved  (2 planes) */
slouken@9046
   288
        SDL_DEFINE_PIXELFOURCC('N', 'V', '1', '2'),
slouken@9046
   289
    SDL_PIXELFORMAT_NV21 =      /**< Planar mode: Y + V/U interleaved  (2 planes) */
slouken@11767
   290
        SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1'),
slouken@11767
   291
    SDL_PIXELFORMAT_EXTERNAL_OES =      /**< Android video texture format */
slouken@11767
   292
        SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ')
slouken@1895
   293
};
slouken@1895
   294
slouken@1895
   295
typedef struct SDL_Color
slouken@1895
   296
{
slouken@1895
   297
    Uint8 r;
slouken@1895
   298
    Uint8 g;
slouken@1895
   299
    Uint8 b;
slouken@7024
   300
    Uint8 a;
slouken@1895
   301
} SDL_Color;
slouken@1895
   302
#define SDL_Colour SDL_Color
slouken@1895
   303
slouken@5288
   304
typedef struct SDL_Palette
slouken@1895
   305
{
slouken@1895
   306
    int ncolors;
slouken@1895
   307
    SDL_Color *colors;
slouken@5288
   308
    Uint32 version;
slouken@1895
   309
    int refcount;
slouken@5288
   310
} SDL_Palette;
slouken@1895
   311
slouken@3407
   312
/**
slouken@3407
   313
 *  \note Everything in the pixel format structure is read-only.
slouken@3407
   314
 */
slouken@1895
   315
typedef struct SDL_PixelFormat
slouken@1895
   316
{
slouken@5288
   317
    Uint32 format;
slouken@1895
   318
    SDL_Palette *palette;
slouken@1895
   319
    Uint8 BitsPerPixel;
slouken@1895
   320
    Uint8 BytesPerPixel;
slouken@5434
   321
    Uint8 padding[2];
slouken@5434
   322
    Uint32 Rmask;
slouken@5434
   323
    Uint32 Gmask;
slouken@5434
   324
    Uint32 Bmask;
slouken@5434
   325
    Uint32 Amask;
slouken@1895
   326
    Uint8 Rloss;
slouken@1895
   327
    Uint8 Gloss;
slouken@1895
   328
    Uint8 Bloss;
slouken@1895
   329
    Uint8 Aloss;
slouken@1895
   330
    Uint8 Rshift;
slouken@1895
   331
    Uint8 Gshift;
slouken@1895
   332
    Uint8 Bshift;
slouken@1895
   333
    Uint8 Ashift;
slouken@5288
   334
    int refcount;
slouken@5288
   335
    struct SDL_PixelFormat *next;
slouken@1895
   336
} SDL_PixelFormat;
slouken@1895
   337
slouken@1895
   338
/**
slouken@4982
   339
 * \brief Get the human readable name of a pixel format
slouken@4982
   340
 */
slouken@4982
   341
extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format);
slouken@4982
   342
slouken@4982
   343
/**
slouken@3407
   344
 *  \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks.
slouken@7191
   345
 *
slouken@3407
   346
 *  \return SDL_TRUE, or SDL_FALSE if the conversion wasn't possible.
slouken@7191
   347
 *
slouken@3407
   348
 *  \sa SDL_MasksToPixelFormatEnum()
slouken@1895
   349
 */
slouken@1895
   350
extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
slouken@1895
   351
                                                            int *bpp,
slouken@1895
   352
                                                            Uint32 * Rmask,
slouken@1895
   353
                                                            Uint32 * Gmask,
slouken@1895
   354
                                                            Uint32 * Bmask,
slouken@1895
   355
                                                            Uint32 * Amask);
slouken@1895
   356
slouken@1895
   357
/**
slouken@3407
   358
 *  \brief Convert a bpp and RGBA masks to an enumerated pixel format.
slouken@7191
   359
 *
slouken@7191
   360
 *  \return The pixel format, or ::SDL_PIXELFORMAT_UNKNOWN if the conversion
slouken@3407
   361
 *          wasn't possible.
slouken@7191
   362
 *
slouken@3407
   363
 *  \sa SDL_PixelFormatEnumToMasks()
slouken@1895
   364
 */
slouken@1895
   365
extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
slouken@1895
   366
                                                          Uint32 Rmask,
slouken@1895
   367
                                                          Uint32 Gmask,
slouken@1895
   368
                                                          Uint32 Bmask,
slouken@1895
   369
                                                          Uint32 Amask);
slouken@1895
   370
slouken@1895
   371
/**
slouken@5288
   372
 *  \brief Create an SDL_PixelFormat structure from a pixel format enum.
slouken@5288
   373
 */
slouken@5288
   374
extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format);
slouken@5288
   375
slouken@5288
   376
/**
slouken@5288
   377
 *  \brief Free an SDL_PixelFormat structure.
slouken@5288
   378
 */
slouken@5288
   379
extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format);
slouken@5288
   380
slouken@5288
   381
/**
slouken@7191
   382
 *  \brief Create a palette structure with the specified number of color
slouken@3407
   383
 *         entries.
slouken@7191
   384
 *
slouken@3407
   385
 *  \return A new palette, or NULL if there wasn't enough memory.
slouken@7191
   386
 *
slouken@3407
   387
 *  \note The palette entries are initialized to white.
slouken@7191
   388
 *
slouken@3407
   389
 *  \sa SDL_FreePalette()
slouken@1895
   390
 */
slouken@1895
   391
extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
slouken@1895
   392
slouken@1895
   393
/**
slouken@5288
   394
 *  \brief Set the palette for a pixel format structure.
slouken@1895
   395
 */
slouken@5288
   396
extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format,
slouken@5288
   397
                                                      SDL_Palette *palette);
slouken@1895
   398
slouken@1895
   399
/**
slouken@3407
   400
 *  \brief Set a range of colors in a palette.
slouken@7191
   401
 *
slouken@3407
   402
 *  \param palette    The palette to modify.
slouken@3407
   403
 *  \param colors     An array of colors to copy into the palette.
slouken@3407
   404
 *  \param firstcolor The index of the first palette entry to modify.
slouken@3407
   405
 *  \param ncolors    The number of entries to modify.
slouken@7191
   406
 *
slouken@3407
   407
 *  \return 0 on success, or -1 if not all of the colors could be set.
slouken@1895
   408
 */
slouken@1895
   409
extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
slouken@1895
   410
                                                 const SDL_Color * colors,
slouken@1895
   411
                                                 int firstcolor, int ncolors);
slouken@1895
   412
slouken@1895
   413
/**
slouken@3407
   414
 *  \brief Free a palette created with SDL_AllocPalette().
slouken@7191
   415
 *
slouken@3407
   416
 *  \sa SDL_AllocPalette()
slouken@1895
   417
 */
slouken@1895
   418
extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette);
slouken@1895
   419
slouken@2275
   420
/**
slouken@3407
   421
 *  \brief Maps an RGB triple to an opaque pixel value for a given pixel format.
slouken@7191
   422
 *
slouken@3407
   423
 *  \sa SDL_MapRGBA
slouken@2275
   424
 */
slouken@2275
   425
extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format,
slouken@2275
   426
                                          Uint8 r, Uint8 g, Uint8 b);
slouken@2275
   427
slouken@2275
   428
/**
slouken@3407
   429
 *  \brief Maps an RGBA quadruple to a pixel value for a given pixel format.
slouken@7191
   430
 *
slouken@3407
   431
 *  \sa SDL_MapRGB
slouken@2275
   432
 */
slouken@2275
   433
extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format,
slouken@2275
   434
                                           Uint8 r, Uint8 g, Uint8 b,
slouken@2275
   435
                                           Uint8 a);
slouken@2275
   436
slouken@2275
   437
/**
slouken@3483
   438
 *  \brief Get the RGB components from a pixel of the specified format.
slouken@7191
   439
 *
slouken@3407
   440
 *  \sa SDL_GetRGBA
slouken@2275
   441
 */
slouken@2275
   442
extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel,
slouken@2275
   443
                                        const SDL_PixelFormat * format,
slouken@2275
   444
                                        Uint8 * r, Uint8 * g, Uint8 * b);
slouken@2275
   445
slouken@2275
   446
/**
slouken@3483
   447
 *  \brief Get the RGBA components from a pixel of the specified format.
slouken@7191
   448
 *
slouken@3407
   449
 *  \sa SDL_GetRGB
slouken@2275
   450
 */
slouken@2275
   451
extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
slouken@2275
   452
                                         const SDL_PixelFormat * format,
slouken@2275
   453
                                         Uint8 * r, Uint8 * g, Uint8 * b,
slouken@2275
   454
                                         Uint8 * a);
slouken@2275
   455
slouken@5466
   456
/**
slouken@5466
   457
 *  \brief Calculate a 256 entry gamma ramp for a gamma value.
slouken@5466
   458
 */
slouken@5466
   459
extern DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 * ramp);
slouken@5466
   460
slouken@5466
   461
slouken@1895
   462
/* Ends C function definitions when using C++ */
slouken@1895
   463
#ifdef __cplusplus
slouken@1895
   464
}
slouken@1895
   465
#endif
slouken@1895
   466
#include "close_code.h"
slouken@1895
   467
slouken@10638
   468
#endif /* SDL_pixels_h_ */
slouken@1895
   469
slouken@1895
   470
/* vi: set ts=4 sw=4 expandtab: */