1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

More ColorKey cleanup

This commit is contained in:
AlexVinS 2014-07-02 22:41:11 +04:00
parent 638dac90af
commit 3e4e810888
5 changed files with 5 additions and 17 deletions

View File

@ -157,15 +157,9 @@ SDL_Surface * BitmapHandler::loadBitmapFromDir(std::string path, std::string fna
// 1) Vampire mansion in Necropolis (not 1st color is transparent) // 1) Vampire mansion in Necropolis (not 1st color is transparent)
// 2) Battle background when fighting on grass/dirt, topmost sky part (NO transparent color) // 2) Battle background when fighting on grass/dirt, topmost sky part (NO transparent color)
// 3) New objects that may use 24-bit images for icons (e.g. witchking arts) // 3) New objects that may use 24-bit images for icons (e.g. witchking arts)
auto colorID = SDL_MapRGB(ret->format, 0, 255, 255);
if (ret->format->palette) if (ret->format->palette)
{ {
auto & color = ret->format->palette->colors[colorID]; CSDL_Ext::setDefaultColorKeyPresize(ret);
// set color key only if exactly such color was found
if (color.r == 0 && color.g == 255 && color.b == 255)
SDL_SetColorKey(ret, SDL_SRCCOLORKEY, colorID);
} }
else // always set else // always set
{ {

View File

@ -91,7 +91,7 @@ void CMessage::init()
delete bluePieces; delete bluePieces;
} }
background = BitmapHandler::loadBitmap("DIBOXBCK.BMP"); background = BitmapHandler::loadBitmap("DIBOXBCK.BMP");
SDL_SetColorKey(background,SDL_SRCCOLORKEY,SDL_MapRGB(background->format,0,255,255)); CSDL_Ext::setDefaultColorKey(background);
} }
ok = CDefHandler::giveDef("IOKAY.DEF"); ok = CDefHandler::giveDef("IOKAY.DEF");
cancel = CDefHandler::giveDef("ICANCEL.DEF"); cancel = CDefHandler::giveDef("ICANCEL.DEF");

View File

@ -1799,7 +1799,7 @@ void CMinorResDataBar::showAll(SDL_Surface * to)
CMinorResDataBar::CMinorResDataBar() CMinorResDataBar::CMinorResDataBar()
{ {
bg = BitmapHandler::loadBitmap("KRESBAR.bmp"); bg = BitmapHandler::loadBitmap("KRESBAR.bmp");
SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255)); CSDL_Ext::setDefaultColorKey(bg);
graphics->blueToPlayersAdv(bg,LOCPLINT->playerID); graphics->blueToPlayersAdv(bg,LOCPLINT->playerID);
pos.x = 7; pos.x = 7;
pos.y = 575; pos.y = 575;

View File

@ -265,13 +265,7 @@ void Graphics::loadHeroFlagsDetail(std::pair<std::vector<CDefEssential *> Graphi
} }
for(auto & curImg : curImgs) for(auto & curImg : curImgs)
{ {
#ifdef VCMI_SDL1 CSDL_Ext::setDefaultColorKey(curImg.bitmap);
uint32_t key = SDL_MapRGB(curImg.bitmap->format, 0, 255, 255);
#else
uint32_t key = SDL_MapRGBA(curImg.bitmap->format, 0, 255, 255, 0);
#endif
SDL_SetColorKey(curImg.bitmap, SDL_SRCCOLORKEY, key);
#ifndef VCMI_SDL1 #ifndef VCMI_SDL1
SDL_SetSurfaceBlendMode(curImg.bitmap,SDL_BLENDMODE_NONE); SDL_SetSurfaceBlendMode(curImg.bitmap,SDL_BLENDMODE_NONE);
#endif #endif

View File

@ -129,7 +129,7 @@ void CPicture::convertToScreenBPP()
{ {
SDL_Surface *hlp = bg; SDL_Surface *hlp = bg;
bg = SDL_ConvertSurface(hlp,screen->format,0); bg = SDL_ConvertSurface(hlp,screen->format,0);
SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255)); CSDL_Ext::setDefaultColorKey(bg);
SDL_FreeSurface(hlp); SDL_FreeSurface(hlp);
} }