Penguin
Blame: SDL_PixelFormat(3)
EditPageHistoryDiffInfoLikePages
Annotated edit history of SDL_PixelFormat(3) version 2, including all changes. View license author blame.
Rev Author # Line
2 perry 1 SDL_!PixelFormat
2 !!!SDL_!PixelFormat
1 perry 3 NAME
4 STRUCTURE DEFINITION
5 STRUCTURE DATA
6 DESCRIPTION
7 SEE ALSO
8 ----
9 !!NAME
10
11
2 perry 12 SDL_!PixelFormat- Stores surface format information
1 perry 13 !!STRUCTURE DEFINITION
14
15
16 typedef struct{
17 SDL_Palette *palette;
2 perry 18 Uint8 !BitsPerPixel;
19 Uint8 !BytesPerPixel;
1 perry 20 Uint32 Rmask, Gmask, Bmask, Amask;
21 Uint8 Rshift, Gshift, Bshift, Ashift;
22 Uint8 Rloss, Gloss, Bloss, Aloss;
23 Uint32 colorkey;
24 Uint8 alpha;
2 perry 25 } SDL_!PixelFormat;
1 perry 26 !!STRUCTURE DATA
27
28
29 __palette__ Pointer to the ''palette'', or __NULL__
2 perry 30 if the __!BitsPerPixel____
1 perry 31
32
2 perry 33 __!BitsPerPixel__ The number of bits used to represent
1 perry 34 each pixel in a surface. Usually 8, 16, 24 or
35 32.
36
37
2 perry 38 __!BytesPerPixel__
1 perry 39
40
41 The number of bytes used to represent each pixel in a
42 surface. Usually one to four.
43
44
45 __[[RGBA]mask__ Binary mask used to retrieve individual
46 color values
47
48
49 __[[RGBA]loss__ Precision loss of each color component
50 (2^[[RGBA]loss)
51
52
53 __[[RGBA]shift__ Binary left shift of each color component
54 in the pixel value
55
56
57 __colorkey__ Pixel value of transparent
58 pixels
59
60
61 __alpha__ Overall surface alpha value
62 !!DESCRIPTION
63
64
2 perry 65 A __SDL_!PixelFormat__ describes the format of the pixel
1 perry 66 data stored at the __pixels__ field of a
67 __SDL_Surface__. Every surface stores a
2 perry 68 __SDL_!PixelFormat__ in the __format__
1 perry 69 field.
70
71
72 If you wish to do pixel level modifications on a surface,
73 then understanding how SDL stores its color information is
74 essential.
75
76
77 8-bit pixel formats are the easiest to understand. Since its
2 perry 78 an 8-bit format, we have 8 __!BitsPerPixel__ and 1
79 __!BytesPerPixel__. Since __!BytesPerPixel__ is 1, all
1 perry 80 pixels are represented by a Uint8 which contains an index
81 into __palette__-__colors__. So, to determine the
82 color of a pixel in a 8-bit surface: we read the color index
83 from __surface__-__pixels__ and we use that index
84 to read the __SDL_Color__ structure from
85 __surface__-__format__-__palette__-__colors__.
86 Like so:
87
88
89 SDL_Surface *surface;
2 perry 90 SDL_!PixelFormat *fmt;
1 perry 91 SDL_Color *color;
92 Uint8 index;
93 .
94 .
95 /* Create surface */
96 .
97 .
98 fmt=surface-
99
100
101 Pixel formats above 8-bit are an entirely different
102 experience. They are considered to be
103
104
105 /* Extracting color components from a 32-bit color value */
2 perry 106 SDL_!PixelFormat *fmt;
1 perry 107 SDL_Surface *surface;
108 Uint32 temp, pixel;
109 Uint8 red, green, blue, alpha;
110 .
111 .
112 .
113 fmt=surface-
114 !!SEE ALSO
115
116
117 __SDL_Surface__, __SDL_MapRGB__
118 ----
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.