mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
More correct usage of SDL_Palette
This commit is contained in:
@ -175,11 +175,10 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const ui8 * FDef, const SDL_Co
|
|||||||
BaseOffset += sizeof(SSpriteDef);
|
BaseOffset += sizeof(SSpriteDef);
|
||||||
int BaseOffsetor = BaseOffset;
|
int BaseOffsetor = BaseOffset;
|
||||||
|
|
||||||
if(SDL_SetPaletteColors(ret->format->palette,palette,0,256) != 0)
|
SDL_Palette * p = SDL_AllocPalette(256);
|
||||||
{
|
SDL_SetPaletteColors(p, palette, 0, 256);
|
||||||
logGlobal->errorStream() << __FUNCTION__ <<": Unable to set palette";
|
SDL_SetSurfacePalette(ret, p);
|
||||||
logGlobal->errorStream() << SDL_GetError();
|
SDL_FreePalette(p);
|
||||||
}
|
|
||||||
|
|
||||||
int ftcp=0;
|
int ftcp=0;
|
||||||
|
|
||||||
|
@ -355,7 +355,11 @@ void SDLImageLoader::init(Point SpriteSize, Point Margins, Point FullSize, SDL_C
|
|||||||
image->fullSize = FullSize;
|
image->fullSize = FullSize;
|
||||||
|
|
||||||
//Prepare surface
|
//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);
|
SDL_LockSurface(image->surf);
|
||||||
lineStart = position = (ui8*)image->surf->pixels;
|
lineStart = position = (ui8*)image->surf->pixels;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user