include/SDL_pixels.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 12 Jan 2011 15:42:26 -0800
changeset 4986 8431f59485d0
parent 4982 660d3a432102
child 5156 307ccc9c135e
permissions -rw-r--r--
Renderer didn't advertise texture format SDL_PIXELFORMAT_ABGR8888
slouken@1895
     1
/*
slouken@1895
     2
    SDL - Simple DirectMedia Layer
slouken@3697
     3
    Copyright (C) 1997-2010 Sam Lantinga
slouken@1895
     4
slouken@1895
     5
    This library is free software; you can redistribute it and/or
slouken@1895
     6
    modify it under the terms of the GNU Lesser General Public
slouken@1895
     7
    License as published by the Free Software Foundation; either
slouken@1895
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@1895
     9
slouken@1895
    10
    This library is distributed in the hope that it will be useful,
slouken@1895
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@1895
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1895
    13
    Lesser General Public License for more details.
slouken@1895
    14
slouken@1895
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1895
    16
    License along with this library; if not, write to the Free Software
slouken@1895
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@1895
    18
slouken@1895
    19
    Sam Lantinga
slouken@1895
    20
    slouken@libsdl.org
slouken@1895
    21
*/
slouken@1895
    22
slouken@1895
    23
/**
slouken@3407
    24
 *  \file SDL_pixels.h
slouken@3407
    25
 *  
slouken@3407
    26
 *  Header for the enumerated pixel format definitions.
slouken@1895
    27
 */
slouken@1895
    28
slouken@1895
    29
#ifndef _SDL_pixels_h
slouken@1895
    30
#define _SDL_pixels_h
slouken@1895
    31
slouken@1895
    32
#include "begin_code.h"
slouken@1895
    33
/* Set up for C function definitions, even when using C++ */
slouken@1895
    34
#ifdef __cplusplus
slouken@1895
    35
/* *INDENT-OFF* */
slouken@1895
    36
extern "C" {
slouken@1895
    37
/* *INDENT-ON* */
slouken@1895
    38
#endif
slouken@1895
    39
slouken@3407
    40
/**
slouken@3407
    41
 *  \name Transparency definitions
slouken@3407
    42
 *  
slouken@3407
    43
 *  These define alpha as the opacity of a surface.
slouken@3407
    44
 */
slouken@3407
    45
/*@{*/
slouken@2275
    46
#define SDL_ALPHA_OPAQUE 255
slouken@2275
    47
#define SDL_ALPHA_TRANSPARENT 0
slouken@3407
    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. */
slouken@1895
    90
enum
slouken@3407
    91
{
slouken@1965
    92
    SDL_ARRAYORDER_NONE,
slouken@1965
    93
    SDL_ARRAYORDER_RGB,
slouken@1965
    94
    SDL_ARRAYORDER_RGBA,
slouken@1965
    95
    SDL_ARRAYORDER_ARGB,
slouken@1965
    96
    SDL_ARRAYORDER_BGR,
slouken@1965
    97
    SDL_ARRAYORDER_BGRA,
slouken@2208
    98
    SDL_ARRAYORDER_ABGR
slouken@1895
    99
};
slouken@1895
   100
slouken@3407
   101
/** Packed component layout. */
slouken@1895
   102
enum
slouken@3407
   103
{
slouken@1965
   104
    SDL_PACKEDLAYOUT_NONE,
slouken@1965
   105
    SDL_PACKEDLAYOUT_332,
slouken@1965
   106
    SDL_PACKEDLAYOUT_4444,
slouken@1965
   107
    SDL_PACKEDLAYOUT_1555,
slouken@1965
   108
    SDL_PACKEDLAYOUT_5551,
slouken@1965
   109
    SDL_PACKEDLAYOUT_565,
slouken@1965
   110
    SDL_PACKEDLAYOUT_8888,
slouken@1965
   111
    SDL_PACKEDLAYOUT_2101010,
slouken@2208
   112
    SDL_PACKEDLAYOUT_1010102
slouken@1895
   113
};
slouken@1895
   114
slouken@4492
   115
#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D)
slouken@1895
   116
slouken@1895
   117
#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
slouken@1895
   118
    ((1 << 31) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
slouken@1895
   119
     ((bits) << 8) | ((bytes) << 0))
slouken@1895
   120
slouken@1895
   121
#define SDL_PIXELTYPE(X)	(((X) >> 24) & 0x0F)
slouken@1895
   122
#define SDL_PIXELORDER(X)	(((X) >> 20) & 0x0F)
slouken@1895
   123
#define SDL_PIXELLAYOUT(X)	(((X) >> 16) & 0x0F)
slouken@1895
   124
#define SDL_BITSPERPIXEL(X)	(((X) >> 8) & 0xFF)
slouken@1895
   125
#define SDL_BYTESPERPIXEL(X)	(((X) >> 0) & 0xFF)
slouken@1895
   126
slouken@1895
   127
#define SDL_ISPIXELFORMAT_INDEXED(format)   \
slouken@1965
   128
    ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
slouken@1965
   129
     (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
slouken@1965
   130
     (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8))
slouken@1895
   131
slouken@3054
   132
#define SDL_ISPIXELFORMAT_ALPHA(format)   \
slouken@3054
   133
    ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
slouken@3054
   134
     (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
slouken@3054
   135
     (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
slouken@3054
   136
     (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))
slouken@3054
   137
slouken@1895
   138
#define SDL_ISPIXELFORMAT_FOURCC(format)    \
slouken@1895
   139
    ((format) && !((format) & 0x80000000))
slouken@1895
   140
slouken@4982
   141
/* Note: If you modify this list, update SDL_GetPixelFormatName() */
slouken@1895
   142
enum
slouken@1895
   143
{
slouken@1965
   144
    SDL_PIXELFORMAT_UNKNOWN,
slouken@1965
   145
    SDL_PIXELFORMAT_INDEX1LSB =
slouken@1965
   146
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0,
slouken@1895
   147
                               1, 0),
slouken@1965
   148
    SDL_PIXELFORMAT_INDEX1MSB =
slouken@1965
   149
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0,
slouken@1895
   150
                               1, 0),
slouken@1965
   151
    SDL_PIXELFORMAT_INDEX4LSB =
slouken@1965
   152
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0,
slouken@3177
   153
                               4, 0),
slouken@1965
   154
    SDL_PIXELFORMAT_INDEX4MSB =
slouken@1965
   155
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0,
slouken@3177
   156
                               4, 0),
slouken@1965
   157
    SDL_PIXELFORMAT_INDEX8 =
slouken@1965
   158
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1),
slouken@1965
   159
    SDL_PIXELFORMAT_RGB332 =
slouken@1965
   160
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB,
slouken@1965
   161
                               SDL_PACKEDLAYOUT_332, 8, 1),
slouken@1965
   162
    SDL_PIXELFORMAT_RGB444 =
slouken@1965
   163
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
slouken@1965
   164
                               SDL_PACKEDLAYOUT_4444, 12, 2),
slouken@1965
   165
    SDL_PIXELFORMAT_RGB555 =
slouken@1965
   166
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
slouken@1965
   167
                               SDL_PACKEDLAYOUT_1555, 15, 2),
slouken@2735
   168
    SDL_PIXELFORMAT_BGR555 =
slouken@2735
   169
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
slouken@2735
   170
                               SDL_PACKEDLAYOUT_1555, 15, 2),
slouken@1965
   171
    SDL_PIXELFORMAT_ARGB4444 =
slouken@1965
   172
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
slouken@1965
   173
                               SDL_PACKEDLAYOUT_4444, 16, 2),
slouken@4982
   174
    SDL_PIXELFORMAT_RGBA4444 =
slouken@4982
   175
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
slouken@4982
   176
                               SDL_PACKEDLAYOUT_4444, 16, 2),
lestat@3163
   177
    SDL_PIXELFORMAT_ABGR4444 =
lestat@3163
   178
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
lestat@3163
   179
                               SDL_PACKEDLAYOUT_4444, 16, 2),
slouken@4982
   180
    SDL_PIXELFORMAT_BGRA4444 =
slouken@4982
   181
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA,
slouken@4982
   182
                               SDL_PACKEDLAYOUT_4444, 16, 2),
slouken@1965
   183
    SDL_PIXELFORMAT_ARGB1555 =
slouken@1965
   184
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
slouken@1965
   185
                               SDL_PACKEDLAYOUT_1555, 16, 2),
slouken@4982
   186
    SDL_PIXELFORMAT_RGBA5551 =
slouken@4982
   187
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
slouken@4982
   188
                               SDL_PACKEDLAYOUT_5551, 16, 2),
slouken@2735
   189
    SDL_PIXELFORMAT_ABGR1555 =
slouken@2735
   190
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
slouken@2735
   191
                               SDL_PACKEDLAYOUT_1555, 16, 2),
slouken@4982
   192
    SDL_PIXELFORMAT_BGRA5551 =
slouken@4982
   193
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA,
slouken@4982
   194
                               SDL_PACKEDLAYOUT_5551, 16, 2),
slouken@1965
   195
    SDL_PIXELFORMAT_RGB565 =
slouken@1965
   196
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
slouken@1965
   197
                               SDL_PACKEDLAYOUT_565, 16, 2),
lestat@3163
   198
    SDL_PIXELFORMAT_BGR565 =
lestat@3163
   199
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
lestat@3163
   200
                               SDL_PACKEDLAYOUT_565, 16, 2),
slouken@1965
   201
    SDL_PIXELFORMAT_RGB24 =
slouken@1965
   202
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0,
slouken@1895
   203
                               24, 3),
slouken@1965
   204
    SDL_PIXELFORMAT_BGR24 =
slouken@1965
   205
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0,
slouken@1895
   206
                               24, 3),
slouken@1965
   207
    SDL_PIXELFORMAT_RGB888 =
slouken@1965
   208
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB,
slouken@1965
   209
                               SDL_PACKEDLAYOUT_8888, 24, 4),
slouken@1965
   210
    SDL_PIXELFORMAT_BGR888 =
slouken@1965
   211
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR,
slouken@1965
   212
                               SDL_PACKEDLAYOUT_8888, 24, 4),
slouken@1965
   213
    SDL_PIXELFORMAT_ARGB8888 =
slouken@1965
   214
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
slouken@1965
   215
                               SDL_PACKEDLAYOUT_8888, 32, 4),
slouken@1965
   216
    SDL_PIXELFORMAT_RGBA8888 =
slouken@1965
   217
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA,
slouken@1965
   218
                               SDL_PACKEDLAYOUT_8888, 32, 4),
slouken@1965
   219
    SDL_PIXELFORMAT_ABGR8888 =
slouken@1965
   220
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR,
slouken@1965
   221
                               SDL_PACKEDLAYOUT_8888, 32, 4),
slouken@1965
   222
    SDL_PIXELFORMAT_BGRA8888 =
slouken@1965
   223
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA,
slouken@1965
   224
                               SDL_PACKEDLAYOUT_8888, 32, 4),
slouken@1965
   225
    SDL_PIXELFORMAT_ARGB2101010 =
slouken@1965
   226
        SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
slouken@1965
   227
                               SDL_PACKEDLAYOUT_2101010, 32, 4),
slouken@1895
   228
slouken@3407
   229
    SDL_PIXELFORMAT_YV12 =      /**< Planar mode: Y + V + U  (3 planes) */
slouken@1895
   230
        SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'),
slouken@3407
   231
    SDL_PIXELFORMAT_IYUV =      /**< Planar mode: Y + U + V  (3 planes) */
slouken@1895
   232
        SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'),
slouken@3407
   233
    SDL_PIXELFORMAT_YUY2 =      /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
slouken@1895
   234
        SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'),
slouken@3407
   235
    SDL_PIXELFORMAT_UYVY =      /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
slouken@1895
   236
        SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'),
slouken@3407
   237
    SDL_PIXELFORMAT_YVYU =      /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
slouken@2208
   238
        SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U')
slouken@1895
   239
};
slouken@1895
   240
slouken@1895
   241
typedef struct SDL_Color
slouken@1895
   242
{
slouken@1895
   243
    Uint8 r;
slouken@1895
   244
    Uint8 g;
slouken@1895
   245
    Uint8 b;
slouken@1895
   246
    Uint8 unused;
slouken@1895
   247
} SDL_Color;
slouken@1895
   248
#define SDL_Colour SDL_Color
slouken@1895
   249
slouken@1895
   250
typedef struct SDL_Palette SDL_Palette;
slouken@1895
   251
typedef int (*SDL_PaletteChangedFunc) (void *userdata, SDL_Palette * palette);
slouken@3555
   252
typedef struct SDL_PaletteWatch SDL_PaletteWatch;
slouken@1895
   253
slouken@1895
   254
struct SDL_Palette
slouken@1895
   255
{
slouken@1895
   256
    int ncolors;
slouken@1895
   257
    SDL_Color *colors;
slouken@1895
   258
slouken@1895
   259
    int refcount;
slouken@1895
   260
    SDL_PaletteWatch *watch;
slouken@1895
   261
};
slouken@1895
   262
slouken@3407
   263
/**
slouken@3407
   264
 *  \note Everything in the pixel format structure is read-only.
slouken@3407
   265
 */
slouken@1895
   266
typedef struct SDL_PixelFormat
slouken@1895
   267
{
slouken@1895
   268
    SDL_Palette *palette;
slouken@1895
   269
    Uint8 BitsPerPixel;
slouken@1895
   270
    Uint8 BytesPerPixel;
slouken@1895
   271
    Uint8 Rloss;
slouken@1895
   272
    Uint8 Gloss;
slouken@1895
   273
    Uint8 Bloss;
slouken@1895
   274
    Uint8 Aloss;
slouken@1895
   275
    Uint8 Rshift;
slouken@1895
   276
    Uint8 Gshift;
slouken@1895
   277
    Uint8 Bshift;
slouken@1895
   278
    Uint8 Ashift;
slouken@1895
   279
    Uint32 Rmask;
slouken@1895
   280
    Uint32 Gmask;
slouken@1895
   281
    Uint32 Bmask;
slouken@1895
   282
    Uint32 Amask;
slouken@1895
   283
} SDL_PixelFormat;
slouken@1895
   284
slouken@1895
   285
/**
slouken@4982
   286
 * \brief Get the human readable name of a pixel format
slouken@4982
   287
 */
slouken@4982
   288
extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format);
slouken@4982
   289
slouken@4982
   290
/**
slouken@3407
   291
 *  \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks.
slouken@3407
   292
 *  
slouken@3407
   293
 *  \return SDL_TRUE, or SDL_FALSE if the conversion wasn't possible.
slouken@3407
   294
 *  
slouken@3407
   295
 *  \sa SDL_MasksToPixelFormatEnum()
slouken@1895
   296
 */
slouken@1895
   297
extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
slouken@1895
   298
                                                            int *bpp,
slouken@1895
   299
                                                            Uint32 * Rmask,
slouken@1895
   300
                                                            Uint32 * Gmask,
slouken@1895
   301
                                                            Uint32 * Bmask,
slouken@1895
   302
                                                            Uint32 * Amask);
slouken@1895
   303
slouken@1895
   304
/**
slouken@3407
   305
 *  \brief Convert a bpp and RGBA masks to an enumerated pixel format.
slouken@3407
   306
 *  
slouken@3407
   307
 *  \return The pixel format, or ::SDL_PIXELFORMAT_UNKNOWN if the conversion 
slouken@3407
   308
 *          wasn't possible.
slouken@3407
   309
 *  
slouken@3407
   310
 *  \sa SDL_PixelFormatEnumToMasks()
slouken@1895
   311
 */
slouken@1895
   312
extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
slouken@1895
   313
                                                          Uint32 Rmask,
slouken@1895
   314
                                                          Uint32 Gmask,
slouken@1895
   315
                                                          Uint32 Bmask,
slouken@1895
   316
                                                          Uint32 Amask);
slouken@1895
   317
slouken@1895
   318
/**
slouken@3407
   319
 *  \brief Create a palette structure with the specified number of color 
slouken@3407
   320
 *         entries.
slouken@3407
   321
 *  
slouken@3407
   322
 *  \return A new palette, or NULL if there wasn't enough memory.
slouken@3407
   323
 *  
slouken@3407
   324
 *  \note The palette entries are initialized to white.
slouken@3407
   325
 *  
slouken@3407
   326
 *  \sa SDL_FreePalette()
slouken@1895
   327
 */
slouken@1895
   328
extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
slouken@1895
   329
slouken@1895
   330
/**
slouken@3407
   331
 *  \brief Add a callback function which is called when the palette changes.
slouken@3407
   332
 *  
slouken@3407
   333
 *  \sa SDL_DelPaletteWatch()
slouken@1895
   334
 */
slouken@1895
   335
extern DECLSPEC int SDLCALL SDL_AddPaletteWatch(SDL_Palette * palette,
slouken@1895
   336
                                                SDL_PaletteChangedFunc
slouken@1895
   337
                                                callback, void *userdata);
slouken@1895
   338
slouken@1895
   339
/**
slouken@3407
   340
 *  \brief Remove a callback function previously added with 
slouken@3407
   341
 *         SDL_AddPaletteWatch().
slouken@3407
   342
 *  
slouken@3407
   343
 *  \sa SDL_AddPaletteWatch()
slouken@1895
   344
 */
slouken@1895
   345
extern DECLSPEC void SDLCALL SDL_DelPaletteWatch(SDL_Palette * palette,
slouken@1895
   346
                                                 SDL_PaletteChangedFunc
slouken@1895
   347
                                                 callback, void *userdata);
slouken@1895
   348
slouken@1895
   349
/**
slouken@3407
   350
 *  \brief Set a range of colors in a palette.
slouken@3407
   351
 *  
slouken@3407
   352
 *  \param palette    The palette to modify.
slouken@3407
   353
 *  \param colors     An array of colors to copy into the palette.
slouken@3407
   354
 *  \param firstcolor The index of the first palette entry to modify.
slouken@3407
   355
 *  \param ncolors    The number of entries to modify.
slouken@3407
   356
 *  
slouken@3407
   357
 *  \return 0 on success, or -1 if not all of the colors could be set.
slouken@1895
   358
 */
slouken@1895
   359
extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
slouken@1895
   360
                                                 const SDL_Color * colors,
slouken@1895
   361
                                                 int firstcolor, int ncolors);
slouken@1895
   362
slouken@1895
   363
/**
slouken@3407
   364
 *  \brief Free a palette created with SDL_AllocPalette().
slouken@3407
   365
 *  
slouken@3407
   366
 *  \sa SDL_AllocPalette()
slouken@1895
   367
 */
slouken@1895
   368
extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette);
slouken@1895
   369
slouken@2275
   370
/**
slouken@3407
   371
 *  \brief Maps an RGB triple to an opaque pixel value for a given pixel format.
slouken@3407
   372
 *  
slouken@3407
   373
 *  \sa SDL_MapRGBA
slouken@2275
   374
 */
slouken@2275
   375
extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format,
slouken@2275
   376
                                          Uint8 r, Uint8 g, Uint8 b);
slouken@2275
   377
slouken@2275
   378
/**
slouken@3407
   379
 *  \brief Maps an RGBA quadruple to a pixel value for a given pixel format.
slouken@3407
   380
 *  
slouken@3407
   381
 *  \sa SDL_MapRGB
slouken@2275
   382
 */
slouken@2275
   383
extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format,
slouken@2275
   384
                                           Uint8 r, Uint8 g, Uint8 b,
slouken@2275
   385
                                           Uint8 a);
slouken@2275
   386
slouken@2275
   387
/**
slouken@3483
   388
 *  \brief Get the RGB components from a pixel of the specified format.
slouken@3407
   389
 *  
slouken@3407
   390
 *  \sa SDL_GetRGBA
slouken@2275
   391
 */
slouken@2275
   392
extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel,
slouken@2275
   393
                                        const SDL_PixelFormat * format,
slouken@2275
   394
                                        Uint8 * r, Uint8 * g, Uint8 * b);
slouken@2275
   395
slouken@2275
   396
/**
slouken@3483
   397
 *  \brief Get the RGBA components from a pixel of the specified format.
slouken@3407
   398
 *  
slouken@3407
   399
 *  \sa SDL_GetRGB
slouken@2275
   400
 */
slouken@2275
   401
extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
slouken@2275
   402
                                         const SDL_PixelFormat * format,
slouken@2275
   403
                                         Uint8 * r, Uint8 * g, Uint8 * b,
slouken@2275
   404
                                         Uint8 * a);
slouken@2275
   405
slouken@1895
   406
/* Ends C function definitions when using C++ */
slouken@1895
   407
#ifdef __cplusplus
slouken@1895
   408
/* *INDENT-OFF* */
slouken@1895
   409
}
slouken@1895
   410
/* *INDENT-ON* */
slouken@1895
   411
#endif
slouken@1895
   412
#include "close_code.h"
slouken@1895
   413
slouken@1895
   414
#endif /* _SDL_pixels_h */
slouken@1895
   415
slouken@1895
   416
/* vi: set ts=4 sw=4 expandtab: */