include/SDL_pixels.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 31 Dec 2011 09:28:07 -0500
changeset 6138 4c64952a58fb
parent 6074 3e1323cbb807
child 6683 b1124b32b07d
permissions -rw-r--r--
Happy New Year!
slouken@1895
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6138
     3
  Copyright (C) 1997-2012 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@3407
    24
 *  
slouken@3407
    25
 *  Header for the enumerated pixel format definitions.
slouken@1895
    26
 */
slouken@1895
    27
slouken@1895
    28
#ifndef _SDL_pixels_h
slouken@1895
    29
#define _SDL_pixels_h
slouken@1895
    30
slouken@1895
    31
#include "begin_code.h"
slouken@1895
    32
/* Set up for C function definitions, even when using C++ */
slouken@1895
    33
#ifdef __cplusplus
slouken@1895
    34
/* *INDENT-OFF* */
slouken@1895
    35
extern "C" {
slouken@1895
    36
/* *INDENT-ON* */
slouken@1895
    37
#endif
slouken@1895
    38
slouken@3407
    39
/**
slouken@3407
    40
 *  \name Transparency definitions
slouken@3407
    41
 *  
slouken@3407
    42
 *  These define alpha as the opacity of a surface.
slouken@3407
    43
 */
slouken@3407
    44
/*@{*/
slouken@2275
    45
#define SDL_ALPHA_OPAQUE 255
slouken@2275
    46
#define SDL_ALPHA_TRANSPARENT 0
slouken@3407
    47
/*@}*/
slouken@2275
    48
slouken@3407
    49
/** Pixel type. */
slouken@1895
    50
enum
slouken@3407
    51
{
slouken@1965
    52
    SDL_PIXELTYPE_UNKNOWN,
slouken@1965
    53
    SDL_PIXELTYPE_INDEX1,
slouken@1965
    54
    SDL_PIXELTYPE_INDEX4,
slouken@1965
    55
    SDL_PIXELTYPE_INDEX8,
slouken@1965
    56
    SDL_PIXELTYPE_PACKED8,
slouken@1965
    57
    SDL_PIXELTYPE_PACKED16,
slouken@1965
    58
    SDL_PIXELTYPE_PACKED32,
slouken@1965
    59
    SDL_PIXELTYPE_ARRAYU8,
slouken@1965
    60
    SDL_PIXELTYPE_ARRAYU16,
slouken@1965
    61
    SDL_PIXELTYPE_ARRAYU32,
slouken@1965
    62
    SDL_PIXELTYPE_ARRAYF16,
slouken@2208
    63
    SDL_PIXELTYPE_ARRAYF32
slouken@1895
    64
};
slouken@1895
    65
slouken@3407
    66
/** Bitmap pixel order, high bit -> low bit. */
slouken@1895
    67
enum
slouken@3407
    68
{
slouken@1965
    69
    SDL_BITMAPORDER_NONE,
slouken@1965
    70
    SDL_BITMAPORDER_4321,
slouken@2208
    71
    SDL_BITMAPORDER_1234
slouken@1895
    72
};
slouken@3407
    73
slouken@3407
    74
/** Packed component order, high bit -> low bit. */
slouken@1895
    75
enum
slouken@3407
    76
{
slouken@1965
    77
    SDL_PACKEDORDER_NONE,
slouken@1965
    78
    SDL_PACKEDORDER_XRGB,
slouken@1965
    79
    SDL_PACKEDORDER_RGBX,
slouken@1965
    80
    SDL_PACKEDORDER_ARGB,
slouken@1965
    81
    SDL_PACKEDORDER_RGBA,
slouken@1965
    82
    SDL_PACKEDORDER_XBGR,
slouken@1965
    83
    SDL_PACKEDORDER_BGRX,
slouken@1965
    84
    SDL_PACKEDORDER_ABGR,
slouken@2208
    85
    SDL_PACKEDORDER_BGRA
slouken@1895
    86
};
slouken@3407
    87
slouken@3407
    88
/** Array component order, low byte -> high byte. */
slouken@1895
    89
enum
slouken@3407
    90
{
slouken@1965
    91
    SDL_ARRAYORDER_NONE,
slouken@1965
    92
    SDL_ARRAYORDER_RGB,
slouken@1965
    93
    SDL_ARRAYORDER_RGBA,
slouken@1965
    94
    SDL_ARRAYORDER_ARGB,
slouken@1965
    95
    SDL_ARRAYORDER_BGR,
slouken@1965
    96
    SDL_ARRAYORDER_BGRA,
slouken@2208
    97
    SDL_ARRAYORDER_ABGR
slouken@1895
    98
};
slouken@1895
    99
slouken@3407
   100
/** Packed component layout. */
slouken@1895
   101
enum
slouken@3407
   102
{
slouken@1965
   103
    SDL_PACKEDLAYOUT_NONE,
slouken@1965
   104
    SDL_PACKEDLAYOUT_332,
slouken@1965
   105
    SDL_PACKEDLAYOUT_4444,
slouken@1965
   106
    SDL_PACKEDLAYOUT_1555,
slouken@1965
   107
    SDL_PACKEDLAYOUT_5551,
slouken@1965
   108
    SDL_PACKEDLAYOUT_565,
slouken@1965
   109
    SDL_PACKEDLAYOUT_8888,
slouken@1965
   110
    SDL_PACKEDLAYOUT_2101010,
slouken@2208
   111
    SDL_PACKEDLAYOUT_1010102
slouken@1895
   112
};
slouken@1895
   113
slouken@4492
   114
#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D)
slouken@1895
   115
slouken@1895
   116
#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
slouken@1895
   117
    ((1 << 31) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
slouken@1895
   118
     ((bits) << 8) | ((bytes) << 0))
slouken@1895
   119
slouken@1895
   120
#define SDL_PIXELTYPE(X)	(((X) >> 24) & 0x0F)
slouken@1895
   121
#define SDL_PIXELORDER(X)	(((X) >> 20) & 0x0F)
slouken@1895
   122
#define SDL_PIXELLAYOUT(X)	(((X) >> 16) & 0x0F)
slouken@1895
   123
#define SDL_BITSPERPIXEL(X)	(((X) >> 8) & 0xFF)
slouken@5156
   124
#define SDL_BYTESPERPIXEL(X) \
slouken@5156
   125
    (SDL_ISPIXELFORMAT_FOURCC(X) ? \
slouken@5264
   126
        ((((X) == SDL_PIXELFORMAT_YUY2) || \
slouken@5156
   127
          ((X) == SDL_PIXELFORMAT_UYVY) || \
slouken@5156
   128
          ((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF))
slouken@1895
   129
slouken@1895
   130
#define SDL_ISPIXELFORMAT_INDEXED(format)   \
slouken@5156
   131
    (!SDL_ISPIXELFORMAT_FOURCC(format) && \
slouken@5156
   132
     ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
slouken@5156
   133
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
slouken@5156
   134
      (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8)))
slouken@1895
   135
slouken@3054
   136
#define SDL_ISPIXELFORMAT_ALPHA(format)   \
slouken@5156
   137
    (!SDL_ISPIXELFORMAT_FOURCC(format) && \
slouken@5156
   138
     ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
slouken@5156
   139
      (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
slouken@5156
   140
      (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
slouken@5156
   141
      (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA)))
slouken@3054
   142
slouken@1895
   143
#define SDL_ISPIXELFORMAT_FOURCC(format)    \
slouken@1895
   144
    ((format) && !((format) & 0x80000000))
slouken@1895
   145
slouken@4982
   146
/* Note: If you modify this list, update SDL_GetPixelFormatName() */
slouken@1895
   147
enum
slouken@1895
   148
{
slouken@1965
   149
    SDL_PIXELFORMAT_UNKNOWN,
slouken@1965
   150
    SDL_PIXELFORMAT_INDEX1LSB =
slouken@5438
   151
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0,
slouken@5438
   152
                               1, 0),
slouken@5438
   153
    SDL_PIXELFORMAT_INDEX1MSB =
slouken@1965
   154
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0,
slouken@1895
   155
                               1, 0),
slouken@1965
   156
    SDL_PIXELFORMAT_INDEX4LSB =
slouken@5438
   157
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0,
slouken@3177
   158
                               4, 0),
slouken@1965
   159
    SDL_PIXELFORMAT_INDEX4MSB =
slouken@5438
   160
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0,
slouken@3177
   161
                               4, 0),
slouken@1965
   162
    SDL_PIXELFORMAT_INDEX8 =
slouken@1965
   163
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1),
slouken@1965
   164
    SDL_PIXELFORMAT_RGB332 =
slouken@1965
   165
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB,
slouken@1965
   166
                               SDL_PACKEDLAYOUT_332, 8, 1),
slouken@1965
   167
    SDL_PIXELFORMAT_RGB444 =
slouken@1965
   168
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
slouken@1965
   169
                               SDL_PACKEDLAYOUT_4444, 12, 2),
slouken@1965
   170
    SDL_PIXELFORMAT_RGB555 =
slouken@1965
   171
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
slouken@1965
   172
                               SDL_PACKEDLAYOUT_1555, 15, 2),
slouken@2735
   173
    SDL_PIXELFORMAT_BGR555 =
slouken@2735
   174
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
slouken@2735
   175
                               SDL_PACKEDLAYOUT_1555, 15, 2),
slouken@1965
   176
    SDL_PIXELFORMAT_ARGB4444 =
slouken@1965
   177
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
slouken@1965
   178
                               SDL_PACKEDLAYOUT_4444, 16, 2),
slouken@4982
   179
    SDL_PIXELFORMAT_RGBA4444 =
slouken@4982
   180
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
slouken@4982
   181
                               SDL_PACKEDLAYOUT_4444, 16, 2),
lestat@3163
   182
    SDL_PIXELFORMAT_ABGR4444 =
lestat@3163
   183
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
lestat@3163
   184
                               SDL_PACKEDLAYOUT_4444, 16, 2),
slouken@4982
   185
    SDL_PIXELFORMAT_BGRA4444 =
slouken@4982
   186
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA,
slouken@4982
   187
                               SDL_PACKEDLAYOUT_4444, 16, 2),
slouken@1965
   188
    SDL_PIXELFORMAT_ARGB1555 =
slouken@1965
   189
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
slouken@1965
   190
                               SDL_PACKEDLAYOUT_1555, 16, 2),
slouken@4982
   191
    SDL_PIXELFORMAT_RGBA5551 =
slouken@4982
   192
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
slouken@4982
   193
                               SDL_PACKEDLAYOUT_5551, 16, 2),
slouken@2735
   194
    SDL_PIXELFORMAT_ABGR1555 =
slouken@2735
   195
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
slouken@2735
   196
                               SDL_PACKEDLAYOUT_1555, 16, 2),
slouken@4982
   197
    SDL_PIXELFORMAT_BGRA5551 =
slouken@4982
   198
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA,
slouken@4982
   199
                               SDL_PACKEDLAYOUT_5551, 16, 2),
slouken@1965
   200
    SDL_PIXELFORMAT_RGB565 =
slouken@1965
   201
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
slouken@1965
   202
                               SDL_PACKEDLAYOUT_565, 16, 2),
lestat@3163
   203
    SDL_PIXELFORMAT_BGR565 =
lestat@3163
   204
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
lestat@3163
   205
                               SDL_PACKEDLAYOUT_565, 16, 2),
slouken@1965
   206
    SDL_PIXELFORMAT_RGB24 =
slouken@1965
   207
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0,
slouken@1895
   208
                               24, 3),
slouken@1965
   209
    SDL_PIXELFORMAT_BGR24 =
slouken@1965
   210
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0,
slouken@1895
   211
                               24, 3),
slouken@1965
   212
    SDL_PIXELFORMAT_RGB888 =
slouken@1965
   213
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB,
slouken@1965
   214
                               SDL_PACKEDLAYOUT_8888, 24, 4),
slouken@6074
   215
    SDL_PIXELFORMAT_RGBX8888 =
slouken@6074
   216
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX,
slouken@6074
   217
                               SDL_PACKEDLAYOUT_8888, 24, 4),
slouken@1965
   218
    SDL_PIXELFORMAT_BGR888 =
slouken@1965
   219
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR,
slouken@1965
   220
                               SDL_PACKEDLAYOUT_8888, 24, 4),
slouken@6074
   221
    SDL_PIXELFORMAT_BGRX8888 =
slouken@6074
   222
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX,
slouken@6074
   223
                               SDL_PACKEDLAYOUT_8888, 24, 4),
slouken@1965
   224
    SDL_PIXELFORMAT_ARGB8888 =
slouken@1965
   225
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
slouken@1965
   226
                               SDL_PACKEDLAYOUT_8888, 32, 4),
slouken@1965
   227
    SDL_PIXELFORMAT_RGBA8888 =
slouken@1965
   228
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA,
slouken@1965
   229
                               SDL_PACKEDLAYOUT_8888, 32, 4),
slouken@1965
   230
    SDL_PIXELFORMAT_ABGR8888 =
slouken@1965
   231
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR,
slouken@1965
   232
                               SDL_PACKEDLAYOUT_8888, 32, 4),
slouken@1965
   233
    SDL_PIXELFORMAT_BGRA8888 =
slouken@1965
   234
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA,
slouken@1965
   235
                               SDL_PACKEDLAYOUT_8888, 32, 4),
slouken@1965
   236
    SDL_PIXELFORMAT_ARGB2101010 =
slouken@1965
   237
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
slouken@1965
   238
                               SDL_PACKEDLAYOUT_2101010, 32, 4),
slouken@1895
   239
slouken@3407
   240
    SDL_PIXELFORMAT_YV12 =      /**< Planar mode: Y + V + U  (3 planes) */
slouken@1895
   241
        SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'),
slouken@3407
   242
    SDL_PIXELFORMAT_IYUV =      /**< Planar mode: Y + U + V  (3 planes) */
slouken@1895
   243
        SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'),
slouken@3407
   244
    SDL_PIXELFORMAT_YUY2 =      /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
slouken@1895
   245
        SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'),
slouken@3407
   246
    SDL_PIXELFORMAT_UYVY =      /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
slouken@1895
   247
        SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'),
slouken@3407
   248
    SDL_PIXELFORMAT_YVYU =      /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
slouken@2208
   249
        SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U')
slouken@1895
   250
};
slouken@1895
   251
slouken@1895
   252
typedef struct SDL_Color
slouken@1895
   253
{
slouken@1895
   254
    Uint8 r;
slouken@1895
   255
    Uint8 g;
slouken@1895
   256
    Uint8 b;
slouken@1895
   257
    Uint8 unused;
slouken@1895
   258
} SDL_Color;
slouken@1895
   259
#define SDL_Colour SDL_Color
slouken@1895
   260
slouken@5288
   261
typedef struct SDL_Palette
slouken@1895
   262
{
slouken@1895
   263
    int ncolors;
slouken@1895
   264
    SDL_Color *colors;
slouken@5288
   265
    Uint32 version;
slouken@1895
   266
    int refcount;
slouken@5288
   267
} SDL_Palette;
slouken@1895
   268
slouken@3407
   269
/**
slouken@3407
   270
 *  \note Everything in the pixel format structure is read-only.
slouken@3407
   271
 */
slouken@1895
   272
typedef struct SDL_PixelFormat
slouken@1895
   273
{
slouken@5288
   274
    Uint32 format;
slouken@1895
   275
    SDL_Palette *palette;
slouken@1895
   276
    Uint8 BitsPerPixel;
slouken@1895
   277
    Uint8 BytesPerPixel;
slouken@5434
   278
    Uint8 padding[2];
slouken@5434
   279
    Uint32 Rmask;
slouken@5434
   280
    Uint32 Gmask;
slouken@5434
   281
    Uint32 Bmask;
slouken@5434
   282
    Uint32 Amask;
slouken@1895
   283
    Uint8 Rloss;
slouken@1895
   284
    Uint8 Gloss;
slouken@1895
   285
    Uint8 Bloss;
slouken@1895
   286
    Uint8 Aloss;
slouken@1895
   287
    Uint8 Rshift;
slouken@1895
   288
    Uint8 Gshift;
slouken@1895
   289
    Uint8 Bshift;
slouken@1895
   290
    Uint8 Ashift;
slouken@5288
   291
    int refcount;
slouken@5288
   292
    struct SDL_PixelFormat *next;
slouken@1895
   293
} SDL_PixelFormat;
slouken@1895
   294
slouken@1895
   295
/**
slouken@4982
   296
 * \brief Get the human readable name of a pixel format
slouken@4982
   297
 */
slouken@4982
   298
extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format);
slouken@4982
   299
slouken@4982
   300
/**
slouken@3407
   301
 *  \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks.
slouken@3407
   302
 *  
slouken@3407
   303
 *  \return SDL_TRUE, or SDL_FALSE if the conversion wasn't possible.
slouken@3407
   304
 *  
slouken@3407
   305
 *  \sa SDL_MasksToPixelFormatEnum()
slouken@1895
   306
 */
slouken@1895
   307
extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
slouken@1895
   308
                                                            int *bpp,
slouken@1895
   309
                                                            Uint32 * Rmask,
slouken@1895
   310
                                                            Uint32 * Gmask,
slouken@1895
   311
                                                            Uint32 * Bmask,
slouken@1895
   312
                                                            Uint32 * Amask);
slouken@1895
   313
slouken@1895
   314
/**
slouken@3407
   315
 *  \brief Convert a bpp and RGBA masks to an enumerated pixel format.
slouken@3407
   316
 *  
slouken@3407
   317
 *  \return The pixel format, or ::SDL_PIXELFORMAT_UNKNOWN if the conversion 
slouken@3407
   318
 *          wasn't possible.
slouken@3407
   319
 *  
slouken@3407
   320
 *  \sa SDL_PixelFormatEnumToMasks()
slouken@1895
   321
 */
slouken@1895
   322
extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
slouken@1895
   323
                                                          Uint32 Rmask,
slouken@1895
   324
                                                          Uint32 Gmask,
slouken@1895
   325
                                                          Uint32 Bmask,
slouken@1895
   326
                                                          Uint32 Amask);
slouken@1895
   327
slouken@1895
   328
/**
slouken@5288
   329
 *  \brief Create an SDL_PixelFormat structure from a pixel format enum.
slouken@5288
   330
 */
slouken@5288
   331
extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format);
slouken@5288
   332
slouken@5288
   333
/**
slouken@5288
   334
 *  \brief Free an SDL_PixelFormat structure.
slouken@5288
   335
 */
slouken@5288
   336
extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format);
slouken@5288
   337
slouken@5288
   338
/**
slouken@3407
   339
 *  \brief Create a palette structure with the specified number of color 
slouken@3407
   340
 *         entries.
slouken@3407
   341
 *  
slouken@3407
   342
 *  \return A new palette, or NULL if there wasn't enough memory.
slouken@3407
   343
 *  
slouken@3407
   344
 *  \note The palette entries are initialized to white.
slouken@3407
   345
 *  
slouken@3407
   346
 *  \sa SDL_FreePalette()
slouken@1895
   347
 */
slouken@1895
   348
extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
slouken@1895
   349
slouken@1895
   350
/**
slouken@5288
   351
 *  \brief Set the palette for a pixel format structure.
slouken@1895
   352
 */
slouken@5288
   353
extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format,
slouken@5288
   354
                                                      SDL_Palette *palette);
slouken@1895
   355
slouken@1895
   356
/**
slouken@3407
   357
 *  \brief Set a range of colors in a palette.
slouken@3407
   358
 *  
slouken@3407
   359
 *  \param palette    The palette to modify.
slouken@3407
   360
 *  \param colors     An array of colors to copy into the palette.
slouken@3407
   361
 *  \param firstcolor The index of the first palette entry to modify.
slouken@3407
   362
 *  \param ncolors    The number of entries to modify.
slouken@3407
   363
 *  
slouken@3407
   364
 *  \return 0 on success, or -1 if not all of the colors could be set.
slouken@1895
   365
 */
slouken@1895
   366
extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
slouken@1895
   367
                                                 const SDL_Color * colors,
slouken@1895
   368
                                                 int firstcolor, int ncolors);
slouken@1895
   369
slouken@1895
   370
/**
slouken@3407
   371
 *  \brief Free a palette created with SDL_AllocPalette().
slouken@3407
   372
 *  
slouken@3407
   373
 *  \sa SDL_AllocPalette()
slouken@1895
   374
 */
slouken@1895
   375
extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette);
slouken@1895
   376
slouken@2275
   377
/**
slouken@3407
   378
 *  \brief Maps an RGB triple to an opaque pixel value for a given pixel format.
slouken@3407
   379
 *  
slouken@3407
   380
 *  \sa SDL_MapRGBA
slouken@2275
   381
 */
slouken@2275
   382
extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format,
slouken@2275
   383
                                          Uint8 r, Uint8 g, Uint8 b);
slouken@2275
   384
slouken@2275
   385
/**
slouken@3407
   386
 *  \brief Maps an RGBA quadruple to a pixel value for a given pixel format.
slouken@3407
   387
 *  
slouken@3407
   388
 *  \sa SDL_MapRGB
slouken@2275
   389
 */
slouken@2275
   390
extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format,
slouken@2275
   391
                                           Uint8 r, Uint8 g, Uint8 b,
slouken@2275
   392
                                           Uint8 a);
slouken@2275
   393
slouken@2275
   394
/**
slouken@3483
   395
 *  \brief Get the RGB components from a pixel of the specified format.
slouken@3407
   396
 *  
slouken@3407
   397
 *  \sa SDL_GetRGBA
slouken@2275
   398
 */
slouken@2275
   399
extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel,
slouken@2275
   400
                                        const SDL_PixelFormat * format,
slouken@2275
   401
                                        Uint8 * r, Uint8 * g, Uint8 * b);
slouken@2275
   402
slouken@2275
   403
/**
slouken@3483
   404
 *  \brief Get the RGBA components from a pixel of the specified format.
slouken@3407
   405
 *  
slouken@3407
   406
 *  \sa SDL_GetRGB
slouken@2275
   407
 */
slouken@2275
   408
extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
slouken@2275
   409
                                         const SDL_PixelFormat * format,
slouken@2275
   410
                                         Uint8 * r, Uint8 * g, Uint8 * b,
slouken@2275
   411
                                         Uint8 * a);
slouken@2275
   412
slouken@5466
   413
/**
slouken@5466
   414
 *  \brief Calculate a 256 entry gamma ramp for a gamma value.
slouken@5466
   415
 */
slouken@5466
   416
extern DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 * ramp);
slouken@5466
   417
slouken@5466
   418
slouken@1895
   419
/* Ends C function definitions when using C++ */
slouken@1895
   420
#ifdef __cplusplus
slouken@1895
   421
/* *INDENT-OFF* */
slouken@1895
   422
}
slouken@1895
   423
/* *INDENT-ON* */
slouken@1895
   424
#endif
slouken@1895
   425
#include "close_code.h"
slouken@1895
   426
slouken@1895
   427
#endif /* _SDL_pixels_h */
slouken@1895
   428
slouken@1895
   429
/* vi: set ts=4 sw=4 expandtab: */