home *** CD-ROM | disk | FTP | other *** search
- <!-- manual page source format generated by PolyglotMan v3.0.8+X.Org, -->
- <!-- available at http://polyglotman.sourceforge.net/ -->
-
- <html>
- <head>
- <title>"SDL_SetPalette"("3") manual page</title>
- </head>
- <body bgcolor='#efefef' text='black' link='blue' vlink='#551A8B' alink='red'>
- <a href='#toc'>Table of Contents</a><p>
-
- <h2><a name='sect0' href='#toc0'>Name</a></h2>
- SDL_SetPalette- Sets the colors in the palette of an 8-bit surface.
- <h2><a name='sect1' href='#toc1'>Synopsis</a></h2>
- <p>
- <b>#include
- "SDL.h" <p>
- </b><b>int <b>SDL_SetPalette</b></b>(<b>SDL_Surface *surface, int flags, SDL_Color *colors,
- int firstcolor, int ncolors</b>);
- <h2><a name='sect2' href='#toc2'>Description</a></h2>
- <p>
- Sets a portion of the palette
- for the given 8-bit surface. <p>
- Palettized (8-bit) screen surfaces with the <b>SDL_HWPALETTE</b>
- flag have two palettes, a logical palette that is used for mapping blits
- to/from the surface and a physical palette (that determines how the hardware
- will map the colors to the display). <i>SDL_BlitSurface</i> always uses the logical
- palette when blitting surfaces (if it has to convert between surface pixel
- formats). Because of this, it is often useful to modify only one or the
- other palette to achieve various special color effects (e.g., screen fading,
- color flashes, screen dimming). <p>
- This function can modify either the logical
- or physical palette by specifing <b>SDL_LOGPAL</b> or <b>SDL_PHYSPAL</b>the in the <b>flags</b>
- parameter. <p>
- When <b>surface</b> is the surface associated with the current display,
- the display colormap will be updated with the requested colors. If <b>SDL_HWPALETTE</b>
- was set in <i>SDL_SetVideoMode</i> flags, <b>SDL_SetPalette</b> will always return <b>1</b>,
- and the palette is guaranteed to be set the way you desire, even if the
- window colormap has to be warped or run under emulation. <p>
- The color components
- of a <i><b>SDL_Color</b></i> structure are 8-bits in size, giving you a total of 256^3=16777216
- colors.
- <h2><a name='sect3' href='#toc3'>Return Value</a></h2>
- <p>
- If <b>surface</b> is not a palettized surface, this function
- does nothing, returning <b>0</b>. If all of the colors were set as passed to <b>SDL_SetPalette</b>,
- it will return <b>1</b>. If not all the color entries were set exactly as given,
- it will return <b>0</b>, and you should look at the surface palette to determine
- the actual color palette.
- <h2><a name='sect4' href='#toc4'>Example</a></h2>
- <p>
- <br>
- <pre>CW /* Create a display surface with a grayscale palette */
- SDL_Surface *screen;
- SDL_Color colors[256];
- int i;
- .
- .
- .
- /* Fill colors with color information */
- for(i=0;i<256;i++){
- colors[i].r=i;
- colors[i].g=i;
- colors[i].b=i;
- }
- /* Create display */
- screen=SDL_SetVideoMode(640, 480, 8, SDL_HWPALETTE);
- if(!screen){
- printf("Couldn't set video mode: %s
- ", SDL_GetError());
- exit(-1);
- }
- /* Set palette */
- SDL_SetPalette(screen, SDL_LOGPAL|SDL_PHYSPAL, colors, 0, 256);
- .
- .
- .
- .
- </pre><p>
-
- <h2><a name='sect5' href='#toc5'>See Also</a></h2>
- <p>
- <i>SDL_SetColors</i>, <i>SDL_SetVideoMode</i>, <i>SDL_Surface</i>, <i>SDL_Color</i>
- <!--
-
- <p>
-
- <hr><p>
- <a name='toc'><b>Table of Contents</b></a><p>
- <ul>
- <li><a name='toc0' href='#sect0'>Name</a></li>
- <li><a name='toc1' href='#sect1'>Synopsis</a></li>
- <li><a name='toc2' href='#sect2'>Description</a></li>
- <li><a name='toc3' href='#sect3'>Return Value</a></li>
- <li><a name='toc4' href='#sect4'>Example</a></li>
- <li><a name='toc5' href='#sect5'>See Also</a></li>
- </ul>
- </body>
- </html>
-