Hello,
I’m trying to display a simple saliency map but it doesn’t seem to work.
This is what I am doing,
SDL_Surface saliencymap = SDL_CreateRGBSurface(SDL_SWSURFACE, width,
height, 8, 0xFF, 0, 0, 0);
…
memcpy(saliencymap->pixels, sm, widthheight);
…
SDL_BlitSurface(saliencymap, &srcrect, screen, &saliencymap_dstrect);
SDL_UpdateRect(screen, 0, 0, width, height);
I get absolutly nothing if I set it to use 8 bit per pixel (which is what
my saliency map has. values between 0 and 255). However if I use 16, or 24
bits per pixel in SDL_CreateRGBSurface() then I will see something, but it
is distorted (as would be expected).
Anyone else have this problem or know what I am doing wrong?
Thanks!
Ryan Dahl
Define a palette.
(Specifically, from the SDL headers:)
/*
- Sets a portion of the colormap for the given 8-bit surface. If ‘surface’
- is not a palettized surface, this function does nothing, returning 0.
- If all of the colors were set as passed to SDL_SetColors(), 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.*
- 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_SetColors()
- 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.
*/
extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface *surface,
SDL_Color *colors, int firstcolor, int ncolors);
/*
*/
extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface *surface, int flags,
SDL_Color *colors, int firstcolor,
int ncolors);
–ryan.