1
0
mirror of https://github.com/Relintai/sdl2_frt.git synced 2024-12-20 22:16:49 +01:00

surface: Make sure SDL_ConvertSurface() deals with palettes (thanks, Sylvain!).

Fixes Bugzilla .
Fixes Bugzilla .
This commit is contained in:
Ryan C. Gordon 2017-09-14 08:37:27 -04:00
parent ac782d7122
commit 76176486ce
2 changed files with 6 additions and 1 deletions

View File

@ -658,7 +658,7 @@ SDL_SetPixelFormatPalette(SDL_PixelFormat * format, SDL_Palette *palette)
return SDL_SetError("SDL_SetPixelFormatPalette() passed NULL format"); return SDL_SetError("SDL_SetPixelFormatPalette() passed NULL format");
} }
if (palette && palette->ncolors != (1 << format->BitsPerPixel)) { if (palette && palette->ncolors > (1 << format->BitsPerPixel)) {
return SDL_SetError("SDL_SetPixelFormatPalette() passed a palette that doesn't match the format"); return SDL_SetError("SDL_SetPixelFormatPalette() passed a palette that doesn't match the format");
} }

View File

@ -998,6 +998,11 @@ SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * format,
surface->format->Gmask, surface->format->Bmask, surface->format->Gmask, surface->format->Bmask,
surface->format->Amask); surface->format->Amask);
/* Share the palette, if any */
if (surface->format->palette) {
SDL_SetSurfacePalette(tmp, surface->format->palette);
}
SDL_FillRect(tmp, NULL, surface->map->info.colorkey); SDL_FillRect(tmp, NULL, surface->map->info.colorkey);
tmp->map->info.flags &= ~SDL_COPY_COLORKEY; tmp->map->info.flags &= ~SDL_COPY_COLORKEY;