36 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
40 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 255
44 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 85, 89, 93, 97, 101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 170, 174, 178, 182, 186, 190, 194, 198, 202, 206, 210, 214, 218, 222, 226, 230, 234, 238, 242, 246, 250, 255
48 0, 8, 16, 24, 32, 41, 49, 57, 65, 74, 82, 90, 98, 106, 115, 123, 131, 139, 148, 156, 164, 172, 180, 189, 197, 205, 213, 222, 230, 238, 246, 255
52 0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255
56 0, 36, 72, 109, 145, 182, 218, 255
89 #define CASE(X) case X: return #X;
127 return "SDL_PIXELFORMAT_UNKNOWN";
149 *Rmask = *Gmask = *Bmask = *Amask = 0;
152 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
165 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
186 masks[0] = 0x00000000;
187 masks[1] = 0x000000E0;
188 masks[2] = 0x0000001C;
189 masks[3] = 0x00000003;
192 masks[0] = 0x0000F000;
193 masks[1] = 0x00000F00;
194 masks[2] = 0x000000F0;
195 masks[3] = 0x0000000F;
198 masks[0] = 0x00008000;
199 masks[1] = 0x00007C00;
200 masks[2] = 0x000003E0;
201 masks[3] = 0x0000001F;
204 masks[0] = 0x0000F800;
205 masks[1] = 0x000007C0;
206 masks[2] = 0x0000003E;
207 masks[3] = 0x00000001;
210 masks[0] = 0x00000000;
211 masks[1] = 0x0000F800;
212 masks[2] = 0x000007E0;
213 masks[3] = 0x0000001F;
216 masks[0] = 0xFF000000;
217 masks[1] = 0x00FF0000;
218 masks[2] = 0x0000FF00;
219 masks[3] = 0x000000FF;
222 masks[0] = 0xC0000000;
223 masks[1] = 0x3FF00000;
224 masks[2] = 0x000FFC00;
225 masks[3] = 0x000003FF;
228 masks[0] = 0xFFC00000;
229 masks[1] = 0x003FF000;
230 masks[2] = 0x00000FFC;
231 masks[3] = 0x00000003;
316 if (Rmask == 0x0F00 &&
332 if (Rmask == 0x7C00 &&
338 if (Rmask == 0x001F &&
344 if (Rmask == 0x0F00 &&
350 if (Rmask == 0xF000 &&
356 if (Rmask == 0x000F &&
362 if (Rmask == 0x00F0 &&
368 if (Rmask == 0x7C00 &&
374 if (Rmask == 0xF800 &&
380 if (Rmask == 0x001F &&
386 if (Rmask == 0x003E &&
392 if (Rmask == 0xF800 &&
398 if (Rmask == 0x001F &&
409 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
415 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
425 if (Rmask == 0x00FF0000 &&
426 Gmask == 0x0000FF00 &&
427 Bmask == 0x000000FF &&
428 Amask == 0x00000000) {
431 if (Rmask == 0xFF000000 &&
432 Gmask == 0x00FF0000 &&
433 Bmask == 0x0000FF00 &&
434 Amask == 0x00000000) {
437 if (Rmask == 0x000000FF &&
438 Gmask == 0x0000FF00 &&
439 Bmask == 0x00FF0000 &&
440 Amask == 0x00000000) {
443 if (Rmask == 0x0000FF00 &&
444 Gmask == 0x00FF0000 &&
445 Bmask == 0xFF000000 &&
446 Amask == 0x00000000) {
449 if (Rmask == 0x00FF0000 &&
450 Gmask == 0x0000FF00 &&
451 Bmask == 0x000000FF &&
452 Amask == 0xFF000000) {
455 if (Rmask == 0xFF000000 &&
456 Gmask == 0x00FF0000 &&
457 Bmask == 0x0000FF00 &&
458 Amask == 0x000000FF) {
461 if (Rmask == 0x000000FF &&
462 Gmask == 0x0000FF00 &&
463 Bmask == 0x00FF0000 &&
464 Amask == 0xFF000000) {
467 if (Rmask == 0x0000FF00 &&
468 Gmask == 0x00FF0000 &&
469 Bmask == 0xFF000000 &&
470 Amask == 0x000000FF) {
473 if (Rmask == 0x3FF00000 &&
474 Gmask == 0x000FFC00 &&
475 Bmask == 0x000003FF &&
476 Amask == 0xC0000000) {
491 for (format = formats;
format; format = format->
next) {
492 if (pixel_format == format->
format) {
500 if (format ==
NULL) {
522 Uint32 Rmask, Gmask, Bmask, Amask;
526 &Rmask, &Gmask, &Bmask, &Amask)) {
532 format->
format = pixel_format;
536 format->
Rmask = Rmask;
540 for (mask = Rmask; !(mask & 0x01); mask >>= 1)
542 for (; (mask & 0x01); mask >>= 1)
546 format->
Gmask = Gmask;
550 for (mask = Gmask; !(mask & 0x01); mask >>= 1)
552 for (; (mask & 0x01); mask >>= 1)
556 format->
Bmask = Bmask;
560 for (mask = Bmask; !(mask & 0x01); mask >>= 1)
562 for (; (mask & 0x01); mask >>= 1)
566 format->
Amask = Amask;
570 for (mask = Amask; !(mask & 0x01); mask >>= 1)
572 for (; (mask & 0x01); mask >>= 1)
597 if (format == formats) {
598 formats = format->
next;
599 }
else if (formats) {
600 for (prev = formats; prev->
next; prev = prev->
next) {
601 if (prev->
next == format) {
649 return SDL_SetError(
"SDL_SetPixelFormatPalette() passed NULL format");
653 return SDL_SetError(
"SDL_SetPixelFormatPalette() passed a palette that doesn't match the format");
656 if (format->
palette == palette) {
675 int firstcolor,
int ncolors)
683 if (ncolors > (palette->
ncolors - firstcolor)) {
684 ncolors = (palette->
ncolors - firstcolor);
688 if (colors != (palette->
colors + firstcolor)) {
690 ncolors *
sizeof(*colors));
724 for (i = 0; i < 256; i++) {
729 r |= r >> 3 | r >> 6;
732 g |= g >> 3 | g >> 6;
754 pitch = (pitch + 7) / 8;
757 pitch = (pitch + 1) / 2;
762 pitch = (pitch + 3) & ~3;
773 unsigned int smallest;
780 for (i = 0; i < pal->
ncolors; ++
i) {
785 distance = (rd * rd) + (gd * gd) + (bd * bd) + (ad * ad);
786 if (distance < smallest) {
869 *r = *g = *b = *a = 0;
900 for (i = 0; i < src->
ncolors; ++
i) {
926 for (i = 0; i < pal->
ncolors; ++
i) {
948 return (
Map1to1(&dithered, pal, identical));
1041 if (srcfmt == dstfmt) {
1091 if (gamma < 0.0
f ) {
1101 if (gamma == 0.0
f) {
1102 for (i = 0; i < 256; ++
i) {
1106 }
else if (gamma == 1.0
f) {
1108 for (i = 0; i < 256; ++
i) {
1109 ramp[
i] = (i << 8) | i;
1115 gamma = 1.0f / gamma;
1116 for (i = 0; i < 256; ++
i) {
1118 (
int) (
SDL_pow((
double) i / 256.0, gamma) * 65535.0 + 0.5);
1119 if (value > 65535) {
DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface)
void SDL_DitherColors(SDL_Color *colors, int bpp)
DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size)
DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format)
Free an SDL_PixelFormat structure.
DECLSPEC double SDLCALL SDL_pow(double x, double y)
DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat *format, SDL_Palette *palette)
Set the palette for a pixel format structure.
#define SDL_PIXELLAYOUT(X)
#define SDL_ISPIXELFORMAT_INDEXED(format)
static SDL_PixelFormat * formats
DECLSPEC const char *SDLCALL SDL_GetPixelFormatName(Uint32 format)
Get the human readable name of a pixel format.
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a)
A collection of pixels used in software blitting.
DECLSPEC void SDLCALL SDL_free(void *mem)
DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette *palette)
Free a palette created with SDL_AllocPalette().
void SDL_UnRLESurface(SDL_Surface *surface, int recode)
DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
Convert a bpp and RGBA masks to an enumerated pixel format.
GLboolean GLboolean GLboolean GLboolean a
#define SDL_BYTESPERPIXEL(X)
Uint32 dst_palette_version
DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len)
#define SDL_InvalidParamError(param)
DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Maps an RGBA quadruple to a pixel value for a given pixel format.
Uint32 src_palette_version
void SDL_InvalidateMap(SDL_BlitMap *map)
uint32_t Uint32
An unsigned 32-bit integer type.
DECLSPEC SDL_PixelFormat *SDLCALL SDL_AllocFormat(Uint32 pixel_format)
Create an SDL_PixelFormat structure from a pixel format enum.
static Uint8 * Map1to1(SDL_Palette *src, SDL_Palette *dst, int *identical)
int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
Uint8 * SDL_expand_byte[9]
Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
GLsizei GLsizei GLfloat distance
DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len)
#define SDL_PIXELORDER(X)
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
DECLSPEC void *SDLCALL SDL_malloc(size_t size)
int SDL_CalculateBlit(SDL_Surface *surface)
int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
static Uint8 * MapNto1(SDL_PixelFormat *src, SDL_PixelFormat *dst, int *identical)
#define SDL_OutOfMemory()
EGLSurface EGLint void ** value
DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 *ramp)
Calculate a 256 entry gamma ramp for a gamma value.
DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Get the RGBA components from a pixel of the specified format.
DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, size_t len)
static Uint8 * Map1toN(SDL_PixelFormat *src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod, SDL_PixelFormat *dst)
DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors)
Create a palette structure with the specified number of color entries.
uint8_t Uint8
An unsigned 8-bit integer type.
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask)
Convert one of the enumerated pixel formats to a bpp and RGBA masks.
DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b)
Maps an RGB triple to an opaque pixel value for a given pixel format.
DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, Uint8 *b)
Get the RGB components from a pixel of the specified format.
SDL_BlitMap * SDL_AllocBlitMap(void)
GLdouble GLdouble GLdouble r
GLdouble GLdouble GLdouble b
uint16_t Uint16
An unsigned 16-bit integer type.
int SDL_CalculatePitch(SDL_Surface *surface)
#define SDL_ISPIXELFORMAT_FOURCC(format)
const GLubyte GLuint GLuint GLuint GLuint alpha GLboolean GLboolean GLboolean GLboolean alpha GLint GLint GLsizei GLsizei GLenum type GLenum GLint GLenum GLint GLint GLsizei GLsizei GLint border GLenum GLint GLint GLint GLint GLint GLsizei GLsizei height GLsizei GLsizei GLenum GLenum const GLvoid *pixels GLenum GLint GLint GLint GLint j2 GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLint *params GLenum GLenum GLfloat *params GLenum GLint GLenum GLenum GLvoid *pixels GLenum GLint GLenum GLint *params GLenum GLenum GLint *params GLenum GLsizei const GLvoid *pointer GLenum GLenum const GLint *params GLenum GLfloat GLfloat GLint GLint const GLfloat *points GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat *points GLint GLfloat GLfloat GLint GLfloat GLfloat v2 GLenum GLenum const GLint *params GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum map
void SDL_FreeBlitMap(SDL_BlitMap *map)
#define SDL_BITSPERPIXEL(X)
DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors)
Set a range of colors in a palette.