Penguin
 
SDL_Pixel Format(3)
LikePages

SDL_!PixelFormat

SDL_!PixelFormat

NAME STRUCTURE DEFINITION STRUCTURE DATA DESCRIPTION SEE ALSO


NAME

SDL_!PixelFormat- Stores surface format information

STRUCTURE DEFINITION

typedef struct{ SDL_Palette *palette; Uint8 !BitsPerPixel; Uint8 !BytesPerPixel; Uint32 Rmask, Gmask, Bmask, Amask; Uint8 Rshift, Gshift, Bshift, Ashift; Uint8 Rloss, Gloss, Bloss, Aloss; Uint32 colorkey; Uint8 alpha; } SDL_!PixelFormat;

STRUCTURE DATA

palette Pointer to the palette, or NULL if the !BitsPerPixel__

!BitsPerPixel The number of bits used to represent each pixel in a surface. Usually 8, 16, 24 or 32.

!BytesPerPixel

The number of bytes used to represent each pixel in a surface. Usually one to four.

[RGBAmask Binary mask used to retrieve individual color values

[RGBAloss Precision loss of each color component (2^[RGBAloss)

[RGBAshift Binary left shift of each color component in the pixel value

colorkey Pixel value of transparent pixels

alpha Overall surface alpha value

DESCRIPTION

A SDL_!PixelFormat describes the format of the pixel data stored at the pixels field of a SDL_Surface. Every surface stores a SDL_!PixelFormat in the format field.

If you wish to do pixel level modifications on a surface, then understanding how SDL stores its color information is essential.

8-bit pixel formats are the easiest to understand. Since its an 8-bit format, we have 8 !BitsPerPixel and 1 !BytesPerPixel. Since !BytesPerPixel is 1, all pixels are represented by a Uint8 which contains an index into palette-colors. So, to determine the color of a pixel in a 8-bit surface: we read the color index from surface-pixels and we use that index to read the SDL_Color structure from surface-format-palette-colors. Like so:

SDL_Surface surface; SDL_!PixelFormat *fmt; SDL_Color *color; Uint8 index; . . / Create surface */ . . fmt=surface-

Pixel formats above 8-bit are an entirely different experience. They are considered to be

/* Extracting color components from a 32-bit color value */ SDL_!PixelFormat *fmt; SDL_Surface *surface; Uint32 temp, pixel; Uint8 red, green, blue, alpha; . . . fmt=surface-

SEE ALSO

SDL_Surface, SDL_MapRGB


This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.