SDL
2.0
|
#include "../SDL_internal.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 | |
const char * | SDL_GetPixelFormatName (Uint32 format) |
Get the human readable name of a 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... | |
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_PixelFormat * | SDL_AllocFormat (Uint32 pixel_format) |
Create an SDL_PixelFormat structure from a pixel format enum. More... | |
int | SDL_InitFormat (SDL_PixelFormat *format, Uint32 pixel_format) |
void | SDL_FreeFormat (SDL_PixelFormat *format) |
Free an SDL_PixelFormat structure. More... | |
SDL_Palette * | SDL_AllocPalette (int ncolors) |
Create a palette structure with the specified number of color entries. More... | |
int | SDL_SetPixelFormatPalette (SDL_PixelFormat *format, SDL_Palette *palette) |
Set the palette for a pixel format structure. More... | |
int | SDL_SetPaletteColors (SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors) |
Set a range of colors in a palette. More... | |
void | SDL_FreePalette (SDL_Palette *palette) |
Free a palette created with SDL_AllocPalette(). More... | |
void | SDL_DitherColors (SDL_Color *colors, int bpp) |
Uint8 | SDL_FindColor (SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a) |
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... | |
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... | |
static Uint8 * | Map1to1 (SDL_Palette *src, SDL_Palette *dst, int *identical) |
static Uint8 * | Map1toN (SDL_PixelFormat *src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod, SDL_PixelFormat *dst) |
static Uint8 * | MapNto1 (SDL_PixelFormat *src, SDL_PixelFormat *dst, int *identical) |
SDL_BlitMap * | SDL_AllocBlitMap (void) |
void | SDL_InvalidateMap (SDL_BlitMap *map) |
int | SDL_MapSurface (SDL_Surface *src, SDL_Surface *dst) |
void | SDL_FreeBlitMap (SDL_BlitMap *map) |
void | SDL_CalculateGammaRamp (float gamma, Uint16 *ramp) |
Calculate a 256 entry gamma ramp for a gamma value. More... | |
Variables | |
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 [] |
Uint8 * | SDL_expand_byte [9] |
static SDL_PixelFormat * | formats |
static SDL_SpinLock | formats_lock = 0 |
#define CASE | ( | X | ) | case X: return #X; |
Referenced by SDL_GetPixelFormatName().
|
static |
Definition at line 876 of file SDL_pixels.c.
References SDL_Color::a, SDL_Color::b, SDL_Palette::colors, SDL_Color::g, i, map, SDL_Palette::ncolors, NULL, SDL_Color::r, SDL_FindColor(), SDL_malloc, SDL_memcmp, and SDL_OutOfMemory.
Referenced by MapNto1(), and SDL_MapSurface().
|
static |
Definition at line 910 of file SDL_pixels.c.
References SDL_Color::a, ASSEMBLE_RGBA, SDL_Color::b, SDL_PixelFormat::BytesPerPixel, SDL_Palette::colors, G, SDL_Color::g, i, map, SDL_Palette::ncolors, NULL, SDL_PixelFormat::palette, SDL_Color::r, SDL_malloc, and SDL_OutOfMemory.
Referenced by SDL_MapSurface().
|
static |
Definition at line 938 of file SDL_pixels.c.
References colors, SDL_Palette::colors, Map1to1(), SDL_Palette::ncolors, SDL_PixelFormat::palette, and SDL_DitherColors().
Referenced by SDL_MapSurface().
SDL_BlitMap* SDL_AllocBlitMap | ( | void | ) |
Definition at line 952 of file SDL_pixels.c.
References SDL_BlitInfo::a, SDL_BlitInfo::b, SDL_BlitInfo::g, SDL_BlitMap::info, map, NULL, SDL_BlitInfo::r, SDL_calloc, and SDL_OutOfMemory.
Referenced by SDL_CreateRGBSurfaceWithFormat().
SDL_PixelFormat* SDL_AllocFormat | ( | Uint32 | pixel_format | ) |
Create an SDL_PixelFormat structure from a pixel format enum.
Definition at line 496 of file SDL_pixels.c.
References SDL_PixelFormat::format, formats, formats_lock, SDL_PixelFormat::next, NULL, SDL_PixelFormat::refcount, SDL_AtomicLock, SDL_AtomicUnlock, SDL_free, SDL_InitFormat(), SDL_InvalidParamError, SDL_ISPIXELFORMAT_INDEXED, SDL_malloc, and SDL_OutOfMemory.
SDL_Palette* SDL_AllocPalette | ( | int | ncolors | ) |
Create a palette structure with the specified number of color entries.
Definition at line 639 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.
Calculate a 256 entry gamma ramp for a gamma value.
Definition at line 1086 of file SDL_pixels.c.
References i, NULL, SDL_InvalidParamError, SDL_memset, and SDL_pow.
Definition at line 742 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().
Definition at line 770 of file SDL_pixels.c.
References SDL_Color::a, SDL_Color::b, SDL_Palette::colors, SDL_Color::g, i, SDL_Palette::ncolors, and SDL_Color::r.
Referenced by Map1to1(), SDL_MapRGB(), and SDL_MapRGBA().
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_FreeFormat | ( | SDL_PixelFormat * | format | ) |
Free an SDL_PixelFormat structure.
Definition at line 602 of file SDL_pixels.c.
References formats_lock, SDL_PixelFormat::next, SDL_PixelFormat::palette, SDL_PixelFormat::refcount, SDL_AtomicLock, SDL_AtomicUnlock, SDL_free, SDL_FreePalette(), and SDL_InvalidParamError.
void SDL_FreePalette | ( | SDL_Palette * | palette | ) |
Free a palette created with SDL_AllocPalette().
Definition at line 725 of file SDL_pixels.c.
References SDL_Palette::colors, SDL_Palette::refcount, SDL_free, and SDL_InvalidParamError.
Referenced by SDL_FreeFormat(), and SDL_SetPixelFormatPalette().
const char* SDL_GetPixelFormatName | ( | Uint32 | format | ) |
Get the human readable name of a pixel format.
Definition at line 86 of file SDL_pixels.c.
References CASE, SDL_PIXELFORMAT_ABGR1555, SDL_PIXELFORMAT_ABGR4444, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB1555, SDL_PIXELFORMAT_ARGB2101010, SDL_PIXELFORMAT_ARGB4444, SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR24, SDL_PIXELFORMAT_BGR555, SDL_PIXELFORMAT_BGR565, SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGRA4444, SDL_PIXELFORMAT_BGRA5551, SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGRX8888, SDL_PIXELFORMAT_INDEX1LSB, SDL_PIXELFORMAT_INDEX1MSB, SDL_PIXELFORMAT_INDEX4LSB, SDL_PIXELFORMAT_INDEX4MSB, SDL_PIXELFORMAT_INDEX8, SDL_PIXELFORMAT_IYUV, SDL_PIXELFORMAT_NV12, SDL_PIXELFORMAT_NV21, SDL_PIXELFORMAT_RGB24, SDL_PIXELFORMAT_RGB332, SDL_PIXELFORMAT_RGB444, SDL_PIXELFORMAT_RGB555, SDL_PIXELFORMAT_RGB565, SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGBA4444, SDL_PIXELFORMAT_RGBA5551, SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGBX8888, SDL_PIXELFORMAT_UYVY, SDL_PIXELFORMAT_YUY2, SDL_PIXELFORMAT_YV12, and SDL_PIXELFORMAT_YVYU.
Get the RGB components from a pixel of the specified format.
Definition at line 826 of file SDL_pixels.c.
References SDL_Color::b, SDL_PixelFormat::Bloss, SDL_PixelFormat::Bmask, SDL_PixelFormat::Bshift, SDL_Palette::colors, SDL_Color::g, SDL_PixelFormat::Gloss, SDL_PixelFormat::Gmask, SDL_PixelFormat::Gshift, SDL_Palette::ncolors, NULL, SDL_PixelFormat::palette, SDL_Color::r, SDL_PixelFormat::Rloss, SDL_PixelFormat::Rmask, SDL_PixelFormat::Rshift, and SDL_expand_byte.
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.
Definition at line 849 of file SDL_pixels.c.
References SDL_Color::a, SDL_PixelFormat::Aloss, SDL_PixelFormat::Amask, SDL_PixelFormat::Ashift, SDL_Color::b, SDL_PixelFormat::Bloss, SDL_PixelFormat::Bmask, SDL_PixelFormat::Bshift, SDL_Palette::colors, SDL_Color::g, SDL_PixelFormat::Gloss, SDL_PixelFormat::Gmask, SDL_PixelFormat::Gshift, SDL_Palette::ncolors, NULL, SDL_PixelFormat::palette, SDL_Color::r, SDL_PixelFormat::Rloss, SDL_PixelFormat::Rmask, SDL_PixelFormat::Rshift, and SDL_expand_byte.
int SDL_InitFormat | ( | SDL_PixelFormat * | format, |
Uint32 | pixel_format | ||
) |
Definition at line 537 of file SDL_pixels.c.
References SDL_PixelFormat::Aloss, SDL_PixelFormat::Amask, SDL_PixelFormat::Ashift, SDL_PixelFormat::BitsPerPixel, SDL_PixelFormat::Bloss, SDL_PixelFormat::Bmask, SDL_PixelFormat::Bshift, SDL_PixelFormat::BytesPerPixel, SDL_PixelFormat::format, SDL_PixelFormat::Gloss, SDL_PixelFormat::Gmask, SDL_PixelFormat::Gshift, SDL_PixelFormat::next, NULL, SDL_PixelFormat::palette, SDL_PixelFormat::refcount, SDL_PixelFormat::Rloss, SDL_PixelFormat::Rmask, SDL_PixelFormat::Rshift, SDL_PixelFormatEnumToMasks(), and SDL_zerop.
Referenced by SDL_AllocFormat(), SDL_CreateSurfaceOnStack(), and SDL_SaveBMP_RW().
void SDL_InvalidateMap | ( | SDL_BlitMap * | map | ) |
Definition at line 972 of file SDL_pixels.c.
References SDL_BlitMap::dst, SDL_BlitMap::dst_palette_version, SDL_BlitMap::info, NULL, SDL_Surface::refcount, SDL_free, SDL_FreeSurface, SDL_BlitMap::src_palette_version, and SDL_BlitInfo::table.
Referenced by SDL_CalculateBlit(), SDL_ConvertSurface(), SDL_FreeBlitMap(), SDL_FreeSurface(), SDL_LowerBlitScaled(), SDL_MapSurface(), SDL_SetColorKey(), SDL_SetSurfaceAlphaMod(), SDL_SetSurfaceBlendMode(), SDL_SetSurfaceColorMod(), SDL_SetSurfacePalette(), SDL_SetSurfaceRLE(), and SDL_UpperBlit().
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.
Definition at line 799 of file SDL_pixels.c.
References SDL_PixelFormat::Amask, SDL_PixelFormat::Bloss, SDL_PixelFormat::Bshift, SDL_PixelFormat::Gloss, SDL_PixelFormat::Gshift, NULL, SDL_PixelFormat::palette, SDL_PixelFormat::Rloss, SDL_PixelFormat::Rshift, SDL_ALPHA_OPAQUE, and SDL_FindColor().
Maps an RGBA quadruple to a pixel value for a given pixel format.
Definition at line 812 of file SDL_pixels.c.
References SDL_PixelFormat::Aloss, SDL_PixelFormat::Amask, SDL_PixelFormat::Ashift, SDL_PixelFormat::Bloss, SDL_PixelFormat::Bshift, SDL_PixelFormat::Gloss, SDL_PixelFormat::Gshift, NULL, SDL_PixelFormat::palette, SDL_PixelFormat::Rloss, SDL_PixelFormat::Rshift, and SDL_FindColor().
int SDL_MapSurface | ( | SDL_Surface * | src, |
SDL_Surface * | dst | ||
) |
Definition at line 991 of file SDL_pixels.c.
References SDL_BlitInfo::a, SDL_BlitInfo::b, SDL_PixelFormat::BitsPerPixel, SDL_BlitMap::dst, SDL_BlitMap::dst_palette_version, SDL_Surface::flags, SDL_Surface::format, SDL_PixelFormat::format, SDL_BlitInfo::g, SDL_BlitMap::identity, SDL_BlitMap::info, SDL_Surface::map, map, Map1to1(), Map1toN(), MapNto1(), NULL, SDL_PixelFormat::palette, SDL_BlitInfo::r, SDL_Surface::refcount, SDL_CalculateBlit(), SDL_InvalidateMap(), SDL_ISPIXELFORMAT_INDEXED, SDL_RLEACCEL, SDL_UnRLESurface(), SDL_BlitMap::src_palette_version, SDL_BlitInfo::table, and SDL_Palette::version.
Referenced by SDL_LowerBlit().
Uint32 SDL_MasksToPixelFormatEnum | ( | int | bpp, |
Uint32 | Rmask, | ||
Uint32 | Gmask, | ||
Uint32 | Bmask, | ||
Uint32 | Amask | ||
) |
Convert a bpp and RGBA masks to an enumerated pixel format.
Definition at line 293 of file SDL_pixels.c.
References SDL_PIXELFORMAT_ABGR1555, SDL_PIXELFORMAT_ABGR4444, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB1555, SDL_PIXELFORMAT_ARGB2101010, SDL_PIXELFORMAT_ARGB4444, SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR24, SDL_PIXELFORMAT_BGR555, SDL_PIXELFORMAT_BGR565, SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGRA4444, SDL_PIXELFORMAT_BGRA5551, SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGRX8888, SDL_PIXELFORMAT_INDEX1MSB, SDL_PIXELFORMAT_INDEX4MSB, SDL_PIXELFORMAT_INDEX8, SDL_PIXELFORMAT_RGB24, SDL_PIXELFORMAT_RGB332, SDL_PIXELFORMAT_RGB444, SDL_PIXELFORMAT_RGB555, SDL_PIXELFORMAT_RGB565, SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGBA4444, SDL_PIXELFORMAT_RGBA5551, SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGBX8888, and SDL_PIXELFORMAT_UNKNOWN.
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.
Definition at line 134 of file SDL_pixels.c.
References SDL_BITSPERPIXEL, SDL_BYTESPERPIXEL, SDL_FALSE, SDL_ISPIXELFORMAT_FOURCC, SDL_PACKEDLAYOUT_1010102, SDL_PACKEDLAYOUT_1555, SDL_PACKEDLAYOUT_2101010, SDL_PACKEDLAYOUT_332, SDL_PACKEDLAYOUT_4444, SDL_PACKEDLAYOUT_5551, SDL_PACKEDLAYOUT_565, SDL_PACKEDLAYOUT_8888, SDL_PACKEDORDER_ABGR, SDL_PACKEDORDER_ARGB, SDL_PACKEDORDER_BGRA, SDL_PACKEDORDER_BGRX, SDL_PACKEDORDER_RGBA, SDL_PACKEDORDER_RGBX, SDL_PACKEDORDER_XBGR, SDL_PACKEDORDER_XRGB, SDL_PIXELFORMAT_BGR24, SDL_PIXELFORMAT_RGB24, SDL_PIXELLAYOUT, SDL_PIXELORDER, SDL_PIXELTYPE, SDL_PIXELTYPE_PACKED16, SDL_PIXELTYPE_PACKED32, SDL_PIXELTYPE_PACKED8, SDL_SetError, and SDL_TRUE.
Referenced by SDL_InitFormat().
int SDL_SetPaletteColors | ( | SDL_Palette * | palette, |
const SDL_Color * | colors, | ||
int | firstcolor, | ||
int | ncolors | ||
) |
Set a range of colors in a palette.
palette | The palette to modify. |
colors | An array of colors to copy into the palette. |
firstcolor | The index of the first palette entry to modify. |
ncolors | The number of entries to modify. |
Definition at line 698 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 670 of file SDL_pixels.c.
References SDL_PixelFormat::BitsPerPixel, SDL_Palette::ncolors, SDL_PixelFormat::palette, SDL_Palette::refcount, SDL_FreePalette(), and SDL_SetError.
|
static |
Definition at line 492 of file SDL_pixels.c.
Referenced by SDL_AllocFormat().
|
static |
Definition at line 493 of file SDL_pixels.c.
Referenced by SDL_AllocFormat(), and SDL_FreeFormat().
|
static |
Definition at line 35 of file SDL_pixels.c.
|
static |
Definition at line 39 of file SDL_pixels.c.
|
static |
Definition at line 43 of file SDL_pixels.c.
|
static |
Definition at line 47 of file SDL_pixels.c.
|
static |
Definition at line 51 of file SDL_pixels.c.
|
static |
Definition at line 55 of file SDL_pixels.c.
|
static |
Definition at line 59 of file SDL_pixels.c.
|
static |
Definition at line 63 of file SDL_pixels.c.
|
static |
Definition at line 67 of file SDL_pixels.c.
Uint8* SDL_expand_byte[9] |
Definition at line 71 of file SDL_pixels.c.
Referenced by SDL_GetRGB(), and SDL_GetRGBA().