1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

More correct usage of SDL_Palette

This commit is contained in:
AlexVinS 2015-09-05 15:03:37 +03:00
parent 8f2da66a18
commit 28087099b8
2 changed files with 10 additions and 7 deletions

View File

@ -174,13 +174,12 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const ui8 * FDef, const SDL_Co
BaseOffset += sizeof(SSpriteDef);
int BaseOffsetor = BaseOffset;
if(SDL_SetPaletteColors(ret->format->palette,palette,0,256) != 0)
{
logGlobal->errorStream() << __FUNCTION__ <<": Unable to set palette";
logGlobal->errorStream() << SDL_GetError();
}
SDL_Palette * p = SDL_AllocPalette(256);
SDL_SetPaletteColors(p, palette, 0, 256);
SDL_SetSurfacePalette(ret, p);
SDL_FreePalette(p);
int ftcp=0;
// If there's a margin anywhere, just blank out the whole surface.

View File

@ -355,7 +355,11 @@ void SDLImageLoader::init(Point SpriteSize, Point Margins, Point FullSize, SDL_C
image->fullSize = FullSize;
//Prepare surface
SDL_SetColors(image->surf, pal, 0, 256);
SDL_Palette * p = SDL_AllocPalette(256);
SDL_SetPaletteColors(p, pal, 0, 256);
SDL_SetSurfacePalette(image->surf, p);
SDL_FreePalette(p);
SDL_LockSurface(image->surf);
lineStart = position = (ui8*)image->surf->pixels;
}