chickadee » sdl2 » make-palette

make-palette #!optional ncolorsprocedure
make-palette* #!optional ncolorsprocedure

Allocate and initialize a new sdl2:palette with the given number of colors. See SDL_AllocPalette.

ncolors defaults to 256. Common values are 2 (for a 1-bit surface), 16 (for a 4-bit surface), and 256 (for an 8-bit surface).

Note: Usually you do not need to manually allocate a palette. A palette will be created for you when you create a surface with a depth of 8 or lower, and the palette will be automatically freed when the surface is freed (unless the palette is still being used by other surfaces).

  • make-palette returns a memory-managed sdl2:palette.
  • make-palette* returns an unmanaged sdl2:palette, which should be freed with free-palette! when you are done with it.

Both procedures signal an exception of kind (exn sdl2) if an error occurs.