zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_pixels.c File Reference
#include "SDL_config.h"
#include "SDL_endian.h"
#include "SDL_video.h"
#include "SDL_sysvideo.h"
#include "SDL_blit.h"
#include "SDL_pixels_c.h"
#include "SDL_RLEaccel_c.h"

Go to the source code of this file.

Macros

#define CASE(X)   case X: return #X;
 

Functions

static Uint8Map1to1 (SDL_Palette *src, SDL_Palette *dst, int *identical)
 
static Uint8Map1toN (SDL_PixelFormat *src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod, SDL_PixelFormat *dst)
 
static Uint8MapNto1 (SDL_PixelFormat *src, SDL_PixelFormat *dst, int *identical)
 
SDL_BlitMapSDL_AllocBlitMap (void)
 
SDL_PixelFormatSDL_AllocFormat (Uint32 pixel_format)
 Create an SDL_PixelFormat structure from a pixel format enum. More...
 
SDL_PaletteSDL_AllocPalette (int ncolors)
 Create a palette structure with the specified number of color entries. More...
 
void SDL_CalculateGammaRamp (float gamma, Uint16 *ramp)
 Calculate a 256 entry gamma ramp for a gamma value. More...
 
int SDL_CalculatePitch (SDL_Surface *surface)
 
void SDL_DitherColors (SDL_Color *colors, int bpp)
 
Uint8 SDL_FindColor (SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
 
void SDL_FreeBlitMap (SDL_BlitMap *map)
 
void SDL_FreeFormat (SDL_PixelFormat *format)
 Free an SDL_PixelFormat structure. More...
 
void SDL_FreePalette (SDL_Palette *palette)
 Free a palette created with SDL_AllocPalette(). More...
 
const char * SDL_GetPixelFormatName (Uint32 format)
 Get the human readable name of a pixel format. More...
 
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. More...
 
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. More...
 
int SDL_InitFormat (SDL_PixelFormat *format, Uint32 pixel_format)
 
void SDL_InvalidateMap (SDL_BlitMap *map)
 
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. More...
 
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. More...
 
int SDL_MapSurface (SDL_Surface *src, SDL_Surface *dst)
 
Uint32 SDL_MasksToPixelFormatEnum (int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
 Convert a bpp and RGBA masks to an enumerated pixel format. More...
 
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. More...
 
int SDL_SetPaletteColors (SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors)
 Set a range of colors in a palette. More...
 
int SDL_SetPixelFormatPalette (SDL_PixelFormat *format, SDL_Palette *palette)
 Set the palette for a pixel format structure. More...
 

Variables

static SDL_PixelFormatformats
 
static Uint8 lookup_0 []
 
static Uint8 lookup_1 []
 
static Uint8 lookup_2 []
 
static Uint8 lookup_3 []
 
static Uint8 lookup_4 []
 
static Uint8 lookup_5 []
 
static Uint8 lookup_6 []
 
static Uint8 lookup_7 []
 
static Uint8 lookup_8 []
 
Uint8SDL_expand_byte [9]
 

Macro Definition Documentation

#define CASE (   X)    case X: return #X;

Referenced by SDL_GetPixelFormatName().

Function Documentation

static Uint8* Map1to1 ( SDL_Palette src,
SDL_Palette dst,
int identical 
)
static
static Uint8* MapNto1 ( SDL_PixelFormat src,
SDL_PixelFormat dst,
int identical 
)
static
SDL_Palette* SDL_AllocPalette ( int  ncolors)

Create a palette structure with the specified number of color entries.

Returns
A new palette, or NULL if there wasn't enough memory.
Note
The palette entries are initialized to white.
See Also
SDL_FreePalette()

Definition at line 615 of file SDL_pixels.c.

References SDL_Palette::colors, SDL_Palette::ncolors, NULL, SDL_Palette::refcount, SDL_free(), SDL_InvalidParamError, SDL_malloc(), SDL_memset(), SDL_OutOfMemory, and SDL_Palette::version.

Referenced by SDL_CreateRGBSurface().

void SDL_CalculateGammaRamp ( float  gamma,
Uint16 ramp 
)

Calculate a 256 entry gamma ramp for a gamma value.

Definition at line 1086 of file SDL_pixels.c.

References i, int, NULL, SDL_InvalidParamError, and SDL_pow().

Referenced by SDL_SetWindowBrightness().

int SDL_CalculatePitch ( SDL_Surface surface)
void SDL_DitherColors ( SDL_Color colors,
int  bpp 
)

Definition at line 718 of file SDL_pixels.c.

References SDL_Color::a, SDL_Color::b, SDL_Color::g, i, SDL_Color::r, and SDL_ALPHA_OPAQUE.

Referenced by MapNto1().

Uint8 SDL_FindColor ( SDL_Palette pal,
Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a 
)
void SDL_FreeBlitMap ( SDL_BlitMap map)

Definition at line 1077 of file SDL_pixels.c.

References SDL_free(), and SDL_InvalidateMap().

Referenced by SDL_FreeSurface().

void SDL_FreePalette ( SDL_Palette palette)
Uint32 SDL_MapRGB ( const SDL_PixelFormat format,
Uint8  r,
Uint8  g,
Uint8  b 
)
int SDL_SetPaletteColors ( SDL_Palette palette,
const SDL_Color colors,
int  firstcolor,
int  ncolors 
)

Set a range of colors in a palette.

Parameters
paletteThe palette to modify.
colorsAn array of colors to copy into the palette.
firstcolorThe index of the first palette entry to modify.
ncolorsThe number of entries to modify.
Returns
0 on success, or -1 if not all of the colors could be set.

Definition at line 674 of file SDL_pixels.c.

References SDL_Palette::colors, SDL_Palette::ncolors, SDL_memcpy(), and SDL_Palette::version.

int SDL_SetPixelFormatPalette ( SDL_PixelFormat format,
SDL_Palette palette 
)

Set the palette for a pixel format structure.

Definition at line 646 of file SDL_pixels.c.

References SDL_PixelFormat::BitsPerPixel, SDL_Palette::ncolors, SDL_PixelFormat::palette, SDL_Palette::refcount, SDL_FreePalette(), and SDL_SetError().

Referenced by SDL_SetSurfacePalette().

Variable Documentation

SDL_PixelFormat* formats
static

Definition at line 483 of file SDL_pixels.c.

Referenced by alcOpenDevice(), and SDL_AllocFormat().

Uint8 lookup_0[]
static
Initial value:
= {
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
}

Definition at line 35 of file SDL_pixels.c.

Uint8 lookup_1[]
static
Initial value:
= {
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
}

Definition at line 39 of file SDL_pixels.c.

Uint8 lookup_2[]
static
Initial value:
= {
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
}

Definition at line 43 of file SDL_pixels.c.

Uint8 lookup_3[]
static
Initial value:
= {
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
}

Definition at line 47 of file SDL_pixels.c.

Uint8 lookup_4[]
static
Initial value:
= {
0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255
}

Definition at line 51 of file SDL_pixels.c.

Uint8 lookup_5[]
static
Initial value:
= {
0, 36, 72, 109, 145, 182, 218, 255
}

Definition at line 55 of file SDL_pixels.c.

Uint8 lookup_6[]
static
Initial value:
= {
0, 85, 170, 255
}

Definition at line 59 of file SDL_pixels.c.

Uint8 lookup_7[]
static
Initial value:
= {
0, 255
}

Definition at line 63 of file SDL_pixels.c.

Uint8 lookup_8[]
static
Initial value:
= {
255
}

Definition at line 67 of file SDL_pixels.c.

Uint8* SDL_expand_byte[9]
Initial value:
= {
}
static Uint8 lookup_5[]
Definition: SDL_pixels.c:55
static Uint8 lookup_0[]
Definition: SDL_pixels.c:35
static Uint8 lookup_4[]
Definition: SDL_pixels.c:51
static Uint8 lookup_2[]
Definition: SDL_pixels.c:43
static Uint8 lookup_7[]
Definition: SDL_pixels.c:63
static Uint8 lookup_1[]
Definition: SDL_pixels.c:39
static Uint8 lookup_8[]
Definition: SDL_pixels.c:67
static Uint8 lookup_3[]
Definition: SDL_pixels.c:47
static Uint8 lookup_6[]
Definition: SDL_pixels.c:59

Definition at line 71 of file SDL_pixels.c.

Referenced by SDL_GetRGB(), and SDL_GetRGBA().