00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00029 #ifndef _SDL_pixels_h
00030 #define _SDL_pixels_h
00031
00032 #include "begin_code.h"
00033
00034 #ifdef __cplusplus
00035
00036 extern "C" {
00037
00038 #endif
00039
00040
00041 #define SDL_ALPHA_OPAQUE 255
00042 #define SDL_ALPHA_TRANSPARENT 0
00043
00044 enum
00045 {
00046 SDL_PIXELTYPE_UNKNOWN,
00047 SDL_PIXELTYPE_INDEX1,
00048 SDL_PIXELTYPE_INDEX4,
00049 SDL_PIXELTYPE_INDEX8,
00050 SDL_PIXELTYPE_PACKED8,
00051 SDL_PIXELTYPE_PACKED16,
00052 SDL_PIXELTYPE_PACKED32,
00053 SDL_PIXELTYPE_ARRAYU8,
00054 SDL_PIXELTYPE_ARRAYU16,
00055 SDL_PIXELTYPE_ARRAYU32,
00056 SDL_PIXELTYPE_ARRAYF16,
00057 SDL_PIXELTYPE_ARRAYF32
00058 };
00059
00060 enum
00061 {
00062 SDL_BITMAPORDER_NONE,
00063 SDL_BITMAPORDER_4321,
00064 SDL_BITMAPORDER_1234
00065 };
00066 enum
00067 {
00068 SDL_PACKEDORDER_NONE,
00069 SDL_PACKEDORDER_XRGB,
00070 SDL_PACKEDORDER_RGBX,
00071 SDL_PACKEDORDER_ARGB,
00072 SDL_PACKEDORDER_RGBA,
00073 SDL_PACKEDORDER_XBGR,
00074 SDL_PACKEDORDER_BGRX,
00075 SDL_PACKEDORDER_ABGR,
00076 SDL_PACKEDORDER_BGRA
00077 };
00078 enum
00079 {
00080 SDL_ARRAYORDER_NONE,
00081 SDL_ARRAYORDER_RGB,
00082 SDL_ARRAYORDER_RGBA,
00083 SDL_ARRAYORDER_ARGB,
00084 SDL_ARRAYORDER_BGR,
00085 SDL_ARRAYORDER_BGRA,
00086 SDL_ARRAYORDER_ABGR
00087 };
00088
00089 enum
00090 {
00091 SDL_PACKEDLAYOUT_NONE,
00092 SDL_PACKEDLAYOUT_332,
00093 SDL_PACKEDLAYOUT_4444,
00094 SDL_PACKEDLAYOUT_1555,
00095 SDL_PACKEDLAYOUT_5551,
00096 SDL_PACKEDLAYOUT_565,
00097 SDL_PACKEDLAYOUT_8888,
00098 SDL_PACKEDLAYOUT_2101010,
00099 SDL_PACKEDLAYOUT_1010102
00100 };
00101
00102 #define SDL_DEFINE_PIXELFOURCC(A, B, C, D) \
00103 ((A) | ((B) << 8) | ((C) << 16) | ((D) << 24))
00104
00105 #define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
00106 ((1 << 31) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
00107 ((bits) << 8) | ((bytes) << 0))
00108
00109 #define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F)
00110 #define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F)
00111 #define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F)
00112 #define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF)
00113 #define SDL_BYTESPERPIXEL(X) (((X) >> 0) & 0xFF)
00114
00115 #define SDL_ISPIXELFORMAT_INDEXED(format) \
00116 ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
00117 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
00118 (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8))
00119
00120 #define SDL_ISPIXELFORMAT_ALPHA(format) \
00121 ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
00122 (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
00123 (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
00124 (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))
00125
00126 #define SDL_ISPIXELFORMAT_FOURCC(format) \
00127 ((format) && !((format) & 0x80000000))
00128
00129 enum
00130 {
00131 SDL_PIXELFORMAT_UNKNOWN,
00132 SDL_PIXELFORMAT_INDEX1LSB =
00133 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0,
00134 1, 0),
00135 SDL_PIXELFORMAT_INDEX1MSB =
00136 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0,
00137 1, 0),
00138 SDL_PIXELFORMAT_INDEX4LSB =
00139 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0,
00140 4, 0),
00141 SDL_PIXELFORMAT_INDEX4MSB =
00142 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0,
00143 4, 0),
00144 SDL_PIXELFORMAT_INDEX8 =
00145 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1),
00146 SDL_PIXELFORMAT_RGB332 =
00147 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB,
00148 SDL_PACKEDLAYOUT_332, 8, 1),
00149 SDL_PIXELFORMAT_RGB444 =
00150 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
00151 SDL_PACKEDLAYOUT_4444, 12, 2),
00152 SDL_PIXELFORMAT_RGB555 =
00153 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
00154 SDL_PACKEDLAYOUT_1555, 15, 2),
00155 SDL_PIXELFORMAT_BGR555 =
00156 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
00157 SDL_PACKEDLAYOUT_1555, 15, 2),
00158 SDL_PIXELFORMAT_ARGB4444 =
00159 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
00160 SDL_PACKEDLAYOUT_4444, 16, 2),
00161 SDL_PIXELFORMAT_ABGR4444 =
00162 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
00163 SDL_PACKEDLAYOUT_4444, 16, 2),
00164 SDL_PIXELFORMAT_ARGB1555 =
00165 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
00166 SDL_PACKEDLAYOUT_1555, 16, 2),
00167 SDL_PIXELFORMAT_ABGR1555 =
00168 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
00169 SDL_PACKEDLAYOUT_1555, 16, 2),
00170 SDL_PIXELFORMAT_RGB565 =
00171 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
00172 SDL_PACKEDLAYOUT_565, 16, 2),
00173 SDL_PIXELFORMAT_BGR565 =
00174 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
00175 SDL_PACKEDLAYOUT_565, 16, 2),
00176 SDL_PIXELFORMAT_RGB24 =
00177 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0,
00178 24, 3),
00179 SDL_PIXELFORMAT_BGR24 =
00180 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0,
00181 24, 3),
00182 SDL_PIXELFORMAT_RGB888 =
00183 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB,
00184 SDL_PACKEDLAYOUT_8888, 24, 4),
00185 SDL_PIXELFORMAT_BGR888 =
00186 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR,
00187 SDL_PACKEDLAYOUT_8888, 24, 4),
00188 SDL_PIXELFORMAT_ARGB8888 =
00189 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
00190 SDL_PACKEDLAYOUT_8888, 32, 4),
00191 SDL_PIXELFORMAT_RGBA8888 =
00192 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA,
00193 SDL_PACKEDLAYOUT_8888, 32, 4),
00194 SDL_PIXELFORMAT_ABGR8888 =
00195 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR,
00196 SDL_PACKEDLAYOUT_8888, 32, 4),
00197 SDL_PIXELFORMAT_BGRA8888 =
00198 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA,
00199 SDL_PACKEDLAYOUT_8888, 32, 4),
00200 SDL_PIXELFORMAT_ARGB2101010 =
00201 SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
00202 SDL_PACKEDLAYOUT_2101010, 32, 4),
00203
00204 SDL_PIXELFORMAT_YV12 =
00205 SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'),
00206 SDL_PIXELFORMAT_IYUV =
00207 SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'),
00208 SDL_PIXELFORMAT_YUY2 =
00209 SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'),
00210 SDL_PIXELFORMAT_UYVY =
00211 SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'),
00212 SDL_PIXELFORMAT_YVYU =
00213 SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U')
00214 };
00215
00216 typedef struct SDL_Color
00217 {
00218 Uint8 r;
00219 Uint8 g;
00220 Uint8 b;
00221 Uint8 unused;
00222 } SDL_Color;
00223 #define SDL_Colour SDL_Color
00224
00225 typedef struct SDL_Palette SDL_Palette;
00226 typedef int (*SDL_PaletteChangedFunc) (void *userdata, SDL_Palette * palette);
00227
00228 typedef struct SDL_PaletteWatch
00229 {
00230 SDL_PaletteChangedFunc callback;
00231 void *userdata;
00232 struct SDL_PaletteWatch *next;
00233 } SDL_PaletteWatch;
00234
00235 struct SDL_Palette
00236 {
00237 int ncolors;
00238 SDL_Color *colors;
00239
00240 int refcount;
00241 SDL_PaletteWatch *watch;
00242 };
00243
00244
00245 typedef struct SDL_PixelFormat
00246 {
00247 SDL_Palette *palette;
00248 Uint8 BitsPerPixel;
00249 Uint8 BytesPerPixel;
00250 Uint8 Rloss;
00251 Uint8 Gloss;
00252 Uint8 Bloss;
00253 Uint8 Aloss;
00254 Uint8 Rshift;
00255 Uint8 Gshift;
00256 Uint8 Bshift;
00257 Uint8 Ashift;
00258 Uint32 Rmask;
00259 Uint32 Gmask;
00260 Uint32 Bmask;
00261 Uint32 Amask;
00262 } SDL_PixelFormat;
00263
00273 extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
00274 int *bpp,
00275 Uint32 * Rmask,
00276 Uint32 * Gmask,
00277 Uint32 * Bmask,
00278 Uint32 * Amask);
00279
00289 extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
00290 Uint32 Rmask,
00291 Uint32 Gmask,
00292 Uint32 Bmask,
00293 Uint32 Amask);
00294
00306 extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
00307
00315 extern DECLSPEC int SDLCALL SDL_AddPaletteWatch(SDL_Palette * palette,
00316 SDL_PaletteChangedFunc
00317 callback, void *userdata);
00318
00326 extern DECLSPEC void SDLCALL SDL_DelPaletteWatch(SDL_Palette * palette,
00327 SDL_PaletteChangedFunc
00328 callback, void *userdata);
00329
00342 extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
00343 const SDL_Color * colors,
00344 int firstcolor, int ncolors);
00345
00353 extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette);
00354
00363 extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format,
00364 Uint8 r, Uint8 g, Uint8 b);
00365
00374 extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format,
00375 Uint8 r, Uint8 g, Uint8 b,
00376 Uint8 a);
00377
00386 extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel,
00387 const SDL_PixelFormat * format,
00388 Uint8 * r, Uint8 * g, Uint8 * b);
00389
00398 extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
00399 const SDL_PixelFormat * format,
00400 Uint8 * r, Uint8 * g, Uint8 * b,
00401 Uint8 * a);
00402
00403
00404 #ifdef __cplusplus
00405
00406 }
00407
00408 #endif
00409 #include "close_code.h"
00410
00411 #endif
00412
00413