21#include "../SDL_internal.h"
360, 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
400, 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
440, 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
480, 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
520, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255
560, 36, 72, 109, 145, 182, 218, 255
89#define CASE(X) case X: return #X;
129 return "SDL_PIXELFORMAT_UNKNOWN";
151 *Rmask = *Gmask = *Bmask = *Amask = 0;
154#if SDL_BYTEORDER == SDL_BIG_ENDIAN
167#if SDL_BYTEORDER == SDL_BIG_ENDIAN
188 masks[0] = 0x00000000;
189 masks[1] = 0x000000E0;
190 masks[2] = 0x0000001C;
191 masks[3] = 0x00000003;
194 masks[0] = 0x0000F000;
195 masks[1] = 0x00000F00;
196 masks[2] = 0x000000F0;
197 masks[3] = 0x0000000F;
200 masks[0] = 0x00008000;
201 masks[1] = 0x00007C00;
202 masks[2] = 0x000003E0;
203 masks[3] = 0x0000001F;
206 masks[0] = 0x0000F800;
207 masks[1] = 0x000007C0;
208 masks[2] = 0x0000003E;
209 masks[3] = 0x00000001;
212 masks[0] = 0x00000000;
213 masks[1] = 0x0000F800;
214 masks[2] = 0x000007E0;
215 masks[3] = 0x0000001F;
218 masks[0] = 0xFF000000;
219 masks[1] = 0x00FF0000;
220 masks[2] = 0x0000FF00;
221 masks[3] = 0x000000FF;
224 masks[0] = 0xC0000000;
225 masks[1] = 0x3FF00000;
226 masks[2] = 0x000FFC00;
227 masks[3] = 0x000003FF;
230 masks[0] = 0xFFC00000;
231 masks[1] = 0x003FF000;
232 masks[2] = 0x00000FFC;
233 masks[3] = 0x00000003;
318 if (Rmask == 0x0F00 &&
334 if (Rmask == 0x7C00 &&
340 if (Rmask == 0x001F &&
346 if (Rmask == 0x0F00 &&
352 if (Rmask == 0xF000 &&
358 if (Rmask == 0x000F &&
364 if (Rmask == 0x00F0 &&
370 if (Rmask == 0x7C00 &&
376 if (Rmask == 0xF800 &&
382 if (Rmask == 0x001F &&
388 if (Rmask == 0x003E &&
394 if (Rmask == 0xF800 &&
400 if (Rmask == 0x001F &&
406 if (Rmask == 0x003F &&
418#if SDL_BYTEORDER == SDL_BIG_ENDIAN
424#if SDL_BYTEORDER == SDL_BIG_ENDIAN
434 if (Rmask == 0x00FF0000 &&
435 Gmask == 0x0000FF00 &&
436 Bmask == 0x000000FF &&
437 Amask == 0x00000000) {
440 if (Rmask == 0xFF000000 &&
441 Gmask == 0x00FF0000 &&
442 Bmask == 0x0000FF00 &&
443 Amask == 0x00000000) {
446 if (Rmask == 0x000000FF &&
447 Gmask == 0x0000FF00 &&
448 Bmask == 0x00FF0000 &&
449 Amask == 0x00000000) {
452 if (Rmask == 0x0000FF00 &&
453 Gmask == 0x00FF0000 &&
454 Bmask == 0xFF000000 &&
455 Amask == 0x00000000) {
458 if (Rmask == 0x00FF0000 &&
459 Gmask == 0x0000FF00 &&
460 Bmask == 0x000000FF &&
461 Amask == 0xFF000000) {
464 if (Rmask == 0xFF000000 &&
465 Gmask == 0x00FF0000 &&
466 Bmask == 0x0000FF00 &&
467 Amask == 0x000000FF) {
470 if (Rmask == 0x000000FF &&
471 Gmask == 0x0000FF00 &&
472 Bmask == 0x00FF0000 &&
473 Amask == 0xFF000000) {
476 if (Rmask == 0x0000FF00 &&
477 Gmask == 0x00FF0000 &&
478 Bmask == 0xFF000000 &&
479 Amask == 0x000000FF) {
482 if (Rmask == 0x3FF00000 &&
483 Gmask == 0x000FFC00 &&
484 Bmask == 0x000003FF &&
485 Amask == 0xC0000000) {
504 if (pixel_format ==
format->format) {
540 Uint32 Rmask, Gmask, Bmask, Amask;
544 &Rmask, &Gmask, &Bmask, &Amask)) {
550 format->format = pixel_format;
551 format->BitsPerPixel = bpp;
552 format->BytesPerPixel = (bpp + 7) / 8;
613 if (--
format->refcount > 0) {
673 return SDL_SetError(
"SDL_SetPixelFormatPalette() passed NULL format");
676 if (palette && palette->
ncolors > (1 <<
format->BitsPerPixel)) {
677 return SDL_SetError(
"SDL_SetPixelFormatPalette() passed a palette that doesn't match the format");
680 if (
format->palette == palette) {
688 format->palette = palette;
699 int firstcolor,
int ncolors)
707 if (ncolors > (palette->
ncolors - firstcolor)) {
708 ncolors = (palette->
ncolors - firstcolor);
714 ncolors *
sizeof(*
colors));
748 for (
i = 0;
i < 256;
i++) {
753 r |=
r >> 3 |
r >> 6;
756 g |=
g >> 3 |
g >> 6;
773 unsigned int smallest;
785 distance = (rd * rd) + (gd * gd) + (bd * bd) + (ad * ad);
838 if (pixel < (
unsigned)
format->palette->ncolors) {
839 *
r =
format->palette->colors[pixel].r;
840 *
g =
format->palette->colors[pixel].g;
841 *
b =
format->palette->colors[pixel].b;
863 if (pixel < (
unsigned)
format->palette->ncolors) {
864 *
r =
format->palette->colors[pixel].r;
865 *
g =
format->palette->colors[pixel].g;
866 *
b =
format->palette->colors[pixel].b;
867 *
a =
format->palette->colors[pixel].a;
869 *
r = *
g = *
b = *
a = 0;
882 if (
src->ncolors <=
dst->ncolors) {
887 (
src->colors,
dst->colors,
900 for (
i = 0;
i <
src->ncolors; ++
i) {
903 src->colors[
i].b,
src->colors[
i].a);
918 bpp = ((
dst->BytesPerPixel == 3) ? 4 :
dst->BytesPerPixel);
948 return (
Map1to1(&dithered, pal, identical));
979 if (--
map->dst->refcount <= 0) {
984 map->src_palette_version = 0;
985 map->dst_palette_version = 0;
1013 if (!
map->identity) {
1014 if (
map->info.table ==
NULL) {
1024 src->map->info.b,
src->map->info.a, dstfmt);
1025 if (
map->info.table ==
NULL) {
1033 if (!
map->identity) {
1034 if (
map->info.table ==
NULL) {
1041 if (srcfmt == dstfmt) {
1057 ++
map->dst->refcount;
1063 map->dst_palette_version = 0;
1069 map->src_palette_version = 0;
1091 if (gamma < 0.0f ) {
1101 if (gamma == 0.0f) {
1104 }
else if (gamma == 1.0f) {
1106 for (
i = 0;
i < 256; ++
i) {
1107 ramp[
i] = (
i << 8) |
i;
1113 gamma = 1.0f / gamma;
1114 for (
i = 0;
i < 256; ++
i) {
1116 (int) (
SDL_pow((
double)
i / 256.0, gamma) * 65535.0 + 0.5);
1117 if (
value > 65535) {
void SDL_UnRLESurface(SDL_Surface *surface, int recode)
int SDL_CalculateBlit(SDL_Surface *surface)
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a)
#define SDL_OutOfMemory()
#define SDL_InvalidParamError(param)
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
GLdouble GLdouble GLdouble r
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
GLsizei GLsizei GLfloat distance
GLsizei const GLfloat * value
int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors)
Set a range of colors in a palette.
static SDL_PixelFormat * formats
void SDL_DitherColors(SDL_Color *colors, int bpp)
int SDL_SetPixelFormatPalette(SDL_PixelFormat *format, SDL_Palette *palette)
Set the palette for a pixel format structure.
static SDL_SpinLock formats_lock
void SDL_CalculateGammaRamp(float gamma, Uint16 *ramp)
Calculate a 256 entry gamma ramp for a gamma value.
void SDL_FreeFormat(SDL_PixelFormat *format)
Free an SDL_PixelFormat structure.
SDL_bool 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.
SDL_PixelFormat * SDL_AllocFormat(Uint32 pixel_format)
Create an SDL_PixelFormat structure from a pixel format enum.
static Uint8 * MapNto1(SDL_PixelFormat *src, SDL_PixelFormat *dst, int *identical)
const char * SDL_GetPixelFormatName(Uint32 format)
Get the human readable name of a pixel format.
int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
Uint32 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 SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
Convert a bpp and RGBA masks to an enumerated pixel format.
static Uint8 * Map1toN(SDL_PixelFormat *src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod, SDL_PixelFormat *dst)
Uint32 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.
void SDL_FreeBlitMap(SDL_BlitMap *map)
void SDL_InvalidateMap(SDL_BlitMap *map)
SDL_BlitMap * SDL_AllocBlitMap(void)
Uint8 * SDL_expand_byte[9]
SDL_Palette * SDL_AllocPalette(int ncolors)
Create a palette structure with the specified number of color entries.
void 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.
int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
void 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.
static Uint8 * Map1to1(SDL_Palette *src, SDL_Palette *dst, int *identical)
void SDL_FreePalette(SDL_Palette *palette)
Free a palette created with SDL_AllocPalette().
Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
#define SDL_BYTESPERPIXEL(X)
#define SDL_PIXELORDER(X)
#define SDL_BITSPERPIXEL(X)
#define SDL_PIXELLAYOUT(X)
#define SDL_ISPIXELFORMAT_INDEXED(format)
@ SDL_PIXELFORMAT_INDEX1LSB
@ SDL_PIXELFORMAT_ABGR4444
@ SDL_PIXELFORMAT_BGRA4444
@ SDL_PIXELFORMAT_INDEX4MSB
@ SDL_PIXELFORMAT_RGBA8888
@ SDL_PIXELFORMAT_RGBA5551
@ SDL_PIXELFORMAT_ARGB1555
@ SDL_PIXELFORMAT_BGRX8888
@ SDL_PIXELFORMAT_ABGR8888
@ SDL_PIXELFORMAT_BGRA8888
@ SDL_PIXELFORMAT_ABGR1555
@ SDL_PIXELFORMAT_ARGB8888
@ SDL_PIXELFORMAT_ARGB4444
@ SDL_PIXELFORMAT_INDEX1MSB
@ SDL_PIXELFORMAT_INDEX4LSB
@ SDL_PIXELFORMAT_RGBX8888
@ SDL_PIXELFORMAT_BGRA5551
@ SDL_PIXELFORMAT_ARGB2101010
@ SDL_PIXELFORMAT_UNKNOWN
@ SDL_PIXELFORMAT_RGBA4444
@ SDL_PACKEDLAYOUT_1010102
@ SDL_PACKEDLAYOUT_2101010
#define SDL_ISPIXELFORMAT_FOURCC(format)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
A collection of pixels used in software blitting.