include/SDL_pixels.h
branchSDL-1.3
changeset 1662 782fd950bd46
child 1668 4da1ee79c9af
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/include/SDL_pixels.h	Sun May 28 13:04:16 2006 +0000
     1.3 @@ -0,0 +1,240 @@
     1.4 +/*
     1.5 +    SDL - Simple DirectMedia Layer
     1.6 +    Copyright (C) 1997-2006 Sam Lantinga
     1.7 +
     1.8 +    This library is free software; you can redistribute it and/or
     1.9 +    modify it under the terms of the GNU Lesser General Public
    1.10 +    License as published by the Free Software Foundation; either
    1.11 +    version 2.1 of the License, or (at your option) any later version.
    1.12 +
    1.13 +    This library is distributed in the hope that it will be useful,
    1.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 +    Lesser General Public License for more details.
    1.17 +
    1.18 +    You should have received a copy of the GNU Lesser General Public
    1.19 +    License along with this library; if not, write to the Free Software
    1.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1.21 +
    1.22 +    Sam Lantinga
    1.23 +    slouken@libsdl.org
    1.24 +*/
    1.25 +
    1.26 +/**
    1.27 + * \file SDL_pixels.h
    1.28 + *
    1.29 + * Header for the enumerated pixel format definitions
    1.30 + */
    1.31 +
    1.32 +#ifndef _SDL_pixels_h
    1.33 +#define _SDL_pixels_h
    1.34 +
    1.35 +#include "begin_code.h"
    1.36 +/* Set up for C function definitions, even when using C++ */
    1.37 +#ifdef __cplusplus
    1.38 +/* *INDENT-OFF* */
    1.39 +extern "C" {
    1.40 +/* *INDENT-ON* */
    1.41 +#endif
    1.42 +
    1.43 +enum
    1.44 +{                               /* Pixel type */
    1.45 +    SDL_PixelType_Unknown,
    1.46 +    SDL_PixelType_Index1,
    1.47 +    SDL_PixelType_Index4,
    1.48 +    SDL_PixelType_Index8,
    1.49 +    SDL_PixelType_Packed8,
    1.50 +    SDL_PixelType_Packed16,
    1.51 +    SDL_PixelType_Packed32,
    1.52 +    SDL_PixelType_ArrayU8,
    1.53 +    SDL_PixelType_ArrayU16,
    1.54 +    SDL_PixelType_ArrayU32,
    1.55 +    SDL_PixelType_ArrayF16,
    1.56 +    SDL_PixelType_ArrayF32,
    1.57 +};
    1.58 +
    1.59 +enum
    1.60 +{                               /* bitmap pixel order, high bit -> low bit */
    1.61 +    SDL_BitmapOrder_None,
    1.62 +    SDL_BitmapOrder_4321,
    1.63 +    SDL_BitmapOrder_1234,
    1.64 +};
    1.65 +enum
    1.66 +{                               /* packed component order, high bit -> low bit */
    1.67 +    SDL_PackedOrder_None,
    1.68 +    SDL_PackedOrder_XRGB,
    1.69 +    SDL_PackedOrder_RGBX,
    1.70 +    SDL_PackedOrder_ARGB,
    1.71 +    SDL_PackedOrder_RGBA,
    1.72 +    SDL_PackedOrder_XBGR,
    1.73 +    SDL_PackedOrder_BGRX,
    1.74 +    SDL_PackedOrder_ABGR,
    1.75 +    SDL_PackedOrder_BGRA,
    1.76 +};
    1.77 +enum
    1.78 +{                               /* array component order, low byte -> high byte */
    1.79 +    SDL_ArrayOrder_None,
    1.80 +    SDL_ArrayOrder_RGB,
    1.81 +    SDL_ArrayOrder_RGBA,
    1.82 +    SDL_ArrayOrder_ARGB,
    1.83 +    SDL_ArrayOrder_BGR,
    1.84 +    SDL_ArrayOrder_BGRA,
    1.85 +    SDL_ArrayOrder_ABGR,
    1.86 +};
    1.87 +
    1.88 +enum
    1.89 +{                               /* Packed component layout */
    1.90 +    SDL_PackedLayout_None,
    1.91 +    SDL_PackedLayout_332,
    1.92 +    SDL_PackedLayout_4444,
    1.93 +    SDL_PackedLayout_1555,
    1.94 +    SDL_PackedLayout_5551,
    1.95 +    SDL_PackedLayout_565,
    1.96 +    SDL_PackedLayout_8888,
    1.97 +    SDL_PackedLayout_2101010,
    1.98 +    SDL_PackedLayout_1010102,
    1.99 +};
   1.100 +
   1.101 +#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
   1.102 +    ((1 << 31) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
   1.103 +     ((bits) << 8) | ((bytes) << 0))
   1.104 +
   1.105 +#define SDL_PIXELTYPE(X)	(((X) >> 24) & 0x0F)
   1.106 +#define SDL_PIXELORDER(X)	(((X) >> 20) & 0x0F)
   1.107 +#define SDL_PIXELLAYOUT(X)	(((X) >> 16) & 0x0F)
   1.108 +#define SDL_BITSPERPIXEL(X)	(((X) >> 8) & 0xFF)
   1.109 +#define SDL_BYTESPERPIXEL(X)	(((X) >> 0) & 0xFF)
   1.110 +
   1.111 +enum
   1.112 +{
   1.113 +    SDL_PixelFormat_Unknown,
   1.114 +    SDL_PixelFormat_Index1LSB =
   1.115 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Index1, SDL_BitmapOrder_1234, 0,
   1.116 +                                1, 0),
   1.117 +    SDL_PixelFormat_Index1MSB =
   1.118 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Index1, SDL_BitmapOrder_4321, 0,
   1.119 +                                1, 0),
   1.120 +    SDL_PixelFormat_Index4LSB =
   1.121 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Index4, SDL_BitmapOrder_1234, 0,
   1.122 +                                2, 0),
   1.123 +    SDL_PixelFormat_Index4MSB =
   1.124 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Index4, SDL_BitmapOrder_4321, 0,
   1.125 +                                2, 0),
   1.126 +    SDL_PixelFormat_Index8 =
   1.127 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Index8, 0, 0, 8, 1),
   1.128 +    SDL_PixelFormat_RGB332 =
   1.129 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed8, SDL_PackedOrder_XRGB,
   1.130 +                                SDL_PackedLayout_332, 8, 1),
   1.131 +    SDL_PixelFormat_RGB444 =
   1.132 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed16, SDL_PackedOrder_XRGB,
   1.133 +                                SDL_PackedLayout_4444, 12, 2),
   1.134 +    SDL_PixelFormat_RGB555 =
   1.135 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed16, SDL_PackedOrder_XRGB,
   1.136 +                                SDL_PackedLayout_1555, 15, 2),
   1.137 +    SDL_PixelFormat_ARGB4444 =
   1.138 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed16, SDL_PackedOrder_ARGB,
   1.139 +                                SDL_PackedLayout_4444, 16, 2),
   1.140 +    SDL_PixelFormat_ARGB1555 =
   1.141 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed16, SDL_PackedOrder_ARGB,
   1.142 +                                SDL_PackedLayout_1555, 16, 2),
   1.143 +    SDL_PixelFormat_RGB565 =
   1.144 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed16, SDL_PackedOrder_XRGB,
   1.145 +                                SDL_PackedLayout_565, 16, 2),
   1.146 +    SDL_PixelFormat_RGB24 =
   1.147 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_ArrayU8, SDL_ArrayOrder_RGB, 0,
   1.148 +                                24, 3),
   1.149 +    SDL_PixelFormat_BGR24 =
   1.150 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_ArrayU8, SDL_ArrayOrder_BGR, 0,
   1.151 +                                24, 3),
   1.152 +    SDL_PixelFormat_RGB888 =
   1.153 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_XRGB,
   1.154 +                                SDL_PackedLayout_8888, 24, 4),
   1.155 +    SDL_PixelFormat_BGR888 =
   1.156 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_XBGR,
   1.157 +                                SDL_PackedLayout_8888, 24, 4),
   1.158 +    SDL_PixelFormat_ARGB8888 =
   1.159 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_ARGB,
   1.160 +                                SDL_PackedLayout_8888, 32, 4),
   1.161 +    SDL_PixelFormat_RGBA8888 =
   1.162 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_RGBA,
   1.163 +                                SDL_PackedLayout_8888, 32, 4),
   1.164 +    SDL_PixelFormat_ABGR8888 =
   1.165 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_ABGR,
   1.166 +                                SDL_PackedLayout_8888, 32, 4),
   1.167 +    SDL_PixelFormat_BGRA8888 =
   1.168 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_BGRA,
   1.169 +                                SDL_PackedLayout_8888, 32, 4),
   1.170 +    SDL_PixelFormat_ARGB2101010 =
   1.171 +        SDL_DEFINE_PIXELFORMAT (SDL_PixelType_Packed32, SDL_PackedOrder_ARGB,
   1.172 +                                SDL_PackedLayout_2101010, 32, 4),
   1.173 +};
   1.174 +
   1.175 +typedef struct SDL_Color
   1.176 +{
   1.177 +    Uint8 r;
   1.178 +    Uint8 g;
   1.179 +    Uint8 b;
   1.180 +    Uint8 unused;
   1.181 +} SDL_Color;
   1.182 +#define SDL_Colour SDL_Color
   1.183 +
   1.184 +typedef struct SDL_Palette
   1.185 +{
   1.186 +    int ncolors;
   1.187 +    SDL_Color *colors;
   1.188 +} SDL_Palette;
   1.189 +
   1.190 +/* Everything in the pixel format structure is read-only */
   1.191 +typedef struct SDL_PixelFormat
   1.192 +{
   1.193 +    SDL_Palette *palette;
   1.194 +    Uint8 BitsPerPixel;
   1.195 +    Uint8 BytesPerPixel;
   1.196 +    Uint8 Rloss;
   1.197 +    Uint8 Gloss;
   1.198 +    Uint8 Bloss;
   1.199 +    Uint8 Aloss;
   1.200 +    Uint8 Rshift;
   1.201 +    Uint8 Gshift;
   1.202 +    Uint8 Bshift;
   1.203 +    Uint8 Ashift;
   1.204 +    Uint32 Rmask;
   1.205 +    Uint32 Gmask;
   1.206 +    Uint32 Bmask;
   1.207 +    Uint32 Amask;
   1.208 +
   1.209 +    /* RGB color key information */
   1.210 +    Uint32 colorkey;
   1.211 +    /* Alpha value information (per-surface alpha) */
   1.212 +    Uint8 alpha;
   1.213 +} SDL_PixelFormat;
   1.214 +
   1.215 +/*
   1.216 + * Convert one of the enumerated formats above to a bpp and RGBA masks.
   1.217 + * Returns SDL_TRUE, or SDL_FALSE if the conversion wasn't possible.
   1.218 + */
   1.219 +extern DECLSPEC SDL_bool SDL_PixelFormatEnumToMasks (Uint32 format, int *bpp,
   1.220 +                                                     Uint32 * Rmask,
   1.221 +                                                     Uint32 * Gmask,
   1.222 +                                                     Uint32 * Bmask,
   1.223 +                                                     Uint32 * Amask);
   1.224 +
   1.225 +/*
   1.226 + * Convert a bpp and RGBA masks to one of the enumerated formats above.
   1.227 + * Returns SDL_PixelFormat_Unknown if the conversion wasn't possible.
   1.228 + */
   1.229 +extern DECLSPEC Uint32 SDL_MasksToPixelFormatEnum (int bpp, Uint32 Rmask,
   1.230 +                                                   Uint32 Gmask, Uint32 Bmask,
   1.231 +                                                   Uint32 Amask);
   1.232 +
   1.233 +/* Ends C function definitions when using C++ */
   1.234 +#ifdef __cplusplus
   1.235 +/* *INDENT-OFF* */
   1.236 +}
   1.237 +/* *INDENT-ON* */
   1.238 +#endif
   1.239 +#include "close_code.h"
   1.240 +
   1.241 +#endif /* _SDL_pixels_h */
   1.242 +
   1.243 +/* vi: set ts=4 sw=4 expandtab: */