home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / SDL / gcc346 / !SDL / man / SDL_SetPalette.3 < prev    next >
Encoding:
Text File  |  2006-09-20  |  3.6 KB  |  99 lines

  1. <!-- manual page source format generated by PolyglotMan v3.0.8+X.Org, -->
  2. <!-- available at http://polyglotman.sourceforge.net/ -->
  3.  
  4. <html>
  5. <head>
  6. <title>"SDL_SetPalette"("3") manual page</title>
  7. </head>
  8. <body bgcolor='#efefef' text='black' link='blue' vlink='#551A8B' alink='red'>
  9. <a href='#toc'>Table of Contents</a><p>
  10.  
  11. <h2><a name='sect0' href='#toc0'>Name</a></h2>
  12. SDL_SetPalette- Sets the colors in the palette of an 8-bit surface. 
  13. <h2><a name='sect1' href='#toc1'>Synopsis</a></h2>
  14. <p>
  15. <b>#include
  16. "SDL.h" <p>
  17. </b><b>int <b>SDL_SetPalette</b></b>(<b>SDL_Surface *surface, int flags, SDL_Color *colors,
  18. int firstcolor, int ncolors</b>); 
  19. <h2><a name='sect2' href='#toc2'>Description</a></h2>
  20. <p>
  21. Sets a portion of the palette
  22. for the given 8-bit surface. <p>
  23. Palettized (8-bit) screen surfaces with the <b>SDL_HWPALETTE</b>
  24. flag have two palettes, a logical palette that is used for mapping blits
  25. to/from the surface and a physical palette (that determines how the hardware
  26. will map the colors to the display). <i>SDL_BlitSurface</i> always uses the logical
  27. palette when blitting surfaces (if it has to convert between surface pixel
  28. formats). Because of this, it is often useful to modify only one or the
  29. other palette to achieve various special color effects (e.g., screen fading,
  30. color flashes, screen dimming). <p>
  31. This function can modify either the logical
  32. or physical palette by specifing <b>SDL_LOGPAL</b> or <b>SDL_PHYSPAL</b>the in the <b>flags</b>
  33. parameter. <p>
  34. When <b>surface</b> is the surface associated with the current display,
  35. the display colormap will be updated with the requested colors. If <b>SDL_HWPALETTE</b>
  36. was set in <i>SDL_SetVideoMode</i> flags, <b>SDL_SetPalette</b> will always return <b>1</b>,
  37. and the palette is guaranteed to be set the way you desire, even if the
  38. window colormap has to be warped or run under emulation. <p>
  39. The color components
  40. of a <i><b>SDL_Color</b></i> structure are 8-bits in size, giving you a total of 256^3=16777216
  41. colors. 
  42. <h2><a name='sect3' href='#toc3'>Return Value</a></h2>
  43. <p>
  44. If <b>surface</b> is not a palettized surface, this function
  45. does nothing, returning <b>0</b>. If all of the colors were set as passed to <b>SDL_SetPalette</b>,
  46. it will return <b>1</b>. If not all the color entries were set exactly as given,
  47. it will return <b>0</b>, and you should look at the surface palette to determine
  48. the actual color palette. 
  49. <h2><a name='sect4' href='#toc4'>Example</a></h2>
  50. <p>
  51. <br>
  52. <pre>CW        /* Create a display surface with a grayscale palette */
  53.         SDL_Surface *screen;
  54.         SDL_Color colors[256];
  55.         int i;
  56.         .
  57.         .
  58.         .
  59.         /* Fill colors with color information */
  60.         for(i=0;i<256;i++){
  61.           colors[i].r=i;
  62.           colors[i].g=i;
  63.           colors[i].b=i;
  64.         }
  65.         /* Create display */
  66.         screen=SDL_SetVideoMode(640, 480, 8, SDL_HWPALETTE);
  67.         if(!screen){
  68.           printf("Couldn't set video mode: %s
  69. ", SDL_GetError());
  70.           exit(-1);
  71.         }
  72.         /* Set palette */
  73.         SDL_SetPalette(screen, SDL_LOGPAL|SDL_PHYSPAL, colors, 0, 256);
  74.         .
  75.         .
  76.         .
  77.         .
  78. </pre><p>
  79.  
  80. <h2><a name='sect5' href='#toc5'>See Also</a></h2>
  81. <p>
  82. <i>SDL_SetColors</i>, <i>SDL_SetVideoMode</i>, <i>SDL_Surface</i>, <i>SDL_Color</i> 
  83. <!--
  84.   
  85.  <p>
  86.  
  87. <hr><p>
  88. <a name='toc'><b>Table of Contents</b></a><p>
  89. <ul>
  90. <li><a name='toc0' href='#sect0'>Name</a></li>
  91. <li><a name='toc1' href='#sect1'>Synopsis</a></li>
  92. <li><a name='toc2' href='#sect2'>Description</a></li>
  93. <li><a name='toc3' href='#sect3'>Return Value</a></li>
  94. <li><a name='toc4' href='#sect4'>Example</a></li>
  95. <li><a name='toc5' href='#sect5'>See Also</a></li>
  96. </ul>
  97. </body>
  98. </html>
  99.