Mercurial > sdl-ios-xcode
comparison docs/html/sdlpixelformat.html @ 55:55f1f1b3e27d
Added new docs for SDL 1.2.1
author | Sam Lantinga <slouken@lokigames.com> |
---|---|
date | Sun, 10 Jun 2001 19:31:57 +0000 |
parents | 74212992fb08 |
children | e5bc29de3f0a |
comparison
equal
deleted
inserted
replaced
54:028447a8a758 | 55:55f1f1b3e27d |
---|---|
2 ><HEAD | 2 ><HEAD |
3 ><TITLE | 3 ><TITLE |
4 >SDL_PixelFormat</TITLE | 4 >SDL_PixelFormat</TITLE |
5 ><META | 5 ><META |
6 NAME="GENERATOR" | 6 NAME="GENERATOR" |
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.61 | 7 CONTENT="Modular DocBook HTML Stylesheet Version 1.64 |
8 "><LINK | 8 "><LINK |
9 REL="HOME" | 9 REL="HOME" |
10 TITLE="SDL Library Documentation" | 10 TITLE="SDL Library Documentation" |
11 HREF="index.html"><LINK | 11 HREF="index.html"><LINK |
12 REL="UP" | 12 REL="UP" |
71 >SDL_PixelFormat</A | 71 >SDL_PixelFormat</A |
72 ></H1 | 72 ></H1 |
73 ><DIV | 73 ><DIV |
74 CLASS="REFNAMEDIV" | 74 CLASS="REFNAMEDIV" |
75 ><A | 75 ><A |
76 NAME="AEN2677" | 76 NAME="AEN2756" |
77 ></A | 77 ></A |
78 ><H2 | 78 ><H2 |
79 >Name</H2 | 79 >Name</H2 |
80 >SDL_PixelFormat -- Stores surface format information</DIV | 80 >SDL_PixelFormat -- Stores surface format information</DIV |
81 ><DIV | 81 ><DIV |
82 CLASS="REFSECT1" | 82 CLASS="REFSECT1" |
83 ><A | 83 ><A |
84 NAME="AEN2680" | 84 NAME="AEN2759" |
85 ></A | 85 ></A |
86 ><H2 | 86 ><H2 |
87 >Structure Definition</H2 | 87 >Structure Definition</H2 |
88 ><PRE | 88 ><PRE |
89 CLASS="PROGRAMLISTING" | 89 CLASS="PROGRAMLISTING" |
99 } SDL_PixelFormat;</PRE | 99 } SDL_PixelFormat;</PRE |
100 ></DIV | 100 ></DIV |
101 ><DIV | 101 ><DIV |
102 CLASS="REFSECT1" | 102 CLASS="REFSECT1" |
103 ><A | 103 ><A |
104 NAME="AEN2683" | 104 NAME="AEN2762" |
105 ></A | 105 ></A |
106 ><H2 | 106 ><H2 |
107 >Structure Data</H2 | 107 >Structure Data</H2 |
108 ><DIV | 108 ><DIV |
109 CLASS="INFORMALTABLE" | 109 CLASS="INFORMALTABLE" |
110 ><A | 110 ><A |
111 NAME="AEN2685" | 111 NAME="AEN2764" |
112 ></A | 112 ></A |
113 ><P | 113 ><P |
114 ></P | 114 ></P |
115 ><TABLE | 115 ><TABLE |
116 BORDER="0" | 116 BORDER="0" |
256 ></DIV | 256 ></DIV |
257 ></DIV | 257 ></DIV |
258 ><DIV | 258 ><DIV |
259 CLASS="REFSECT1" | 259 CLASS="REFSECT1" |
260 ><A | 260 ><A |
261 NAME="AEN2724" | 261 NAME="AEN2803" |
262 ></A | 262 ></A |
263 ><H2 | 263 ><H2 |
264 >Description</H2 | 264 >Description</H2 |
265 ><P | 265 ><P |
266 >A <SPAN | 266 >A <SPAN |
381 color->r, color->g, color->b, index); | 381 color->r, color->g, color->b, index); |
382 . | 382 . |
383 .</PRE | 383 .</PRE |
384 ></P | 384 ></P |
385 ><P | 385 ><P |
386 >Pixel formats above 8-bit are an entirely different experience. They are considered to be "TrueColor" formats and the color information is stored in the pixels themselves, not in a palette (packed-pixel). The mask, shift and loss fields tell us how the color information is encoded. The mask fields allow us to isolate each color component, the shift fields tell us how far left we have to shift the masked value and the loss fields tell us for far right we have to shift the final value to convert it to a full 8-bit color component. | 386 >Pixel formats above 8-bit are an entirely different experience. They are |
387 considered to be "TrueColor" formats and the color information is stored in the | |
388 pixels themselves, not in a palette. The mask, shift and loss fields tell us | |
389 how the color information is encoded. The mask fields allow us to isolate each | |
390 color component, the shift fields tell us the number of bits to the right of | |
391 each component in the pixel value and the loss fields tell us the number of | |
392 bits lost from each component when packing 8-bit color component in a pixel. | |
387 <PRE | 393 <PRE |
388 CLASS="PROGRAMLISTING" | 394 CLASS="PROGRAMLISTING" |
389 >/* Extracting color components from a 32-bit color value */ | 395 >/* Extracting color components from a 32-bit color value */ |
390 SDL_PixelFormat *fmt; | 396 SDL_PixelFormat *fmt; |
391 SDL_Surface *surface; | 397 SDL_Surface *surface; |
394 . | 400 . |
395 . | 401 . |
396 . | 402 . |
397 fmt=surface->format; | 403 fmt=surface->format; |
398 SDL_LockSurface(surface); | 404 SDL_LockSurface(surface); |
399 pixel=(Uint32*)surface->pixels; | 405 pixel=*((Uint32*)surface->pixels); |
400 SDL_UnlockSurface(surface); | 406 SDL_UnlockSurface(surface); |
401 | 407 |
402 /* Get Red component */ | 408 /* Get Red component */ |
403 temp=pixel&fmt->Rmask; /* Isolate red component */ | 409 temp=pixel&fmt->Rmask; /* Isolate red component */ |
404 temp=temp>>fmt->Rshift;/* Shift it down to 8-bit */ | 410 temp=temp>>fmt->Rshift;/* Shift it down to 8-bit */ |
430 ></P | 436 ></P |
431 ></DIV | 437 ></DIV |
432 ><DIV | 438 ><DIV |
433 CLASS="REFSECT1" | 439 CLASS="REFSECT1" |
434 ><A | 440 ><A |
435 NAME="AEN2751" | 441 NAME="AEN2830" |
436 ></A | 442 ></A |
437 ><H2 | 443 ><H2 |
438 >See Also</H2 | 444 >See Also</H2 |
439 ><P | 445 ><P |
440 ><A | 446 ><A |