Saliency map

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, width
height);

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

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?

Define a palette.

–ryan.

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);

/*

  • Sets a portion of the colormap for a given 8-bit surface.
  • ‘flags’ is one or both of:
  • SDL_LOGPAL – set logical palette, which controls how blits are mapped
  •            to/from the surface,
    
  • SDL_PHYSPAL – set physical palette, which controls how pixels look on
  •            the screen
    
  • Only screens have physical palettes. Separate change of physical/logical
  • palettes is only possible if the screen has SDL_HWPALETTE set.
  • The return value is 1 if all colours could be set as requested, and 0
  • otherwise.
  • SDL_SetColors() is equivalent to calling this function with
  • flags = (SDL_LOGPAL|SDL_PHYSPAL).
    

*/
extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface *surface, int flags,
SDL_Color *colors, int firstcolor,
int ncolors);

–ryan.