SDL_SetPalette - Online Linux Manual PageSection : 3
Updated : Tue 11 Sep 2001, 23:01
Source : SDL
Note : SDL API Reference

NAMESDL_SetPalette − Sets the colors in the palette of an 8-bit surface​.

SYNOPSIS#include "SDL​.h" int SDL_SetPalette(SDL_Surface *surface, int flags, SDL_Color *colors, int firstcolor, int ncolors);

DESCRIPTIONSets a portion of the palette for the given 8-bit surface​. Palettized (8-bit) screen surfaces with the SDL_HWPALETTE 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)​. SDL_BlitSurface 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)​. This function can modify either the logical or physical palette by specifing SDL_LOGPAL or SDL_PHYSPALthe in the flags parameter​. When surface is the surface associated with the current display, the display colormap will be updated with the requested colors​. If SDL_HWPALETTE was set in SDL_SetVideoMode flags, SDL_SetPalette will always return 1, 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​. The color components of a SDL_Color structure are 8-bits in size, giving you a total of 256^3=16777216 colors​.

RETURN VALUEIf surface is not a palettized surface, this function does nothing, returning 0​. If all of the colors were set as passed to SDL_SetPalette, it will return 1​. If not all the color entries were set exactly as given, it will return 0, and you should look at the surface palette to determine the actual color palette​.

EXAMPLE /* 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); ​. ​. ​. ​.

SEE ALSOSDL_SetColors, SDL_SetVideoMode, SDL_Surface, SDL_Color
0
Johanes Gumabo
Data Size   :   8,685 byte
man-SDL_SetPalette.3Build   :   2024-12-29, 07:25   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   5 / 255,769
Visitor ID   :     :  
Visitor IP   :   18.217.128.191   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.29
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.