From d12a0e142305d77a3850552a402a0f07343ea34b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 1 Feb 2013 01:55:16 +0100 Subject: WINTERMUTE: Apply color-key if no alpha-channel is present (Instead of using the bpp to detect it). --- .../base/gfx/osystem/base_surface_osystem.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'engines/wintermute/base/gfx') diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index e00b347ecc..6e29a1f756 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -140,23 +140,28 @@ bool BaseSurfaceOSystem::finishLoad() { // Well, actually, we don't convert via 24-bit as the color-key application overwrites the Alpha-channel anyhow. _surface->free(); delete _surface; + + bool needsColorKey = false; if (_filename.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) { _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); - TransparentSurface trans(*_surface); - trans.applyColorKey(_ckRed, _ckGreen, _ckBlue); + needsColorKey = true; } else if (image->getSurface()->format.bytesPerPixel == 1 && image->getPalette()) { _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); - TransparentSurface trans(*_surface); - trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, true); + needsColorKey = true; } else if (image->getSurface()->format.bytesPerPixel >= 3 && image->getSurface()->format != g_system->getScreenFormat()) { _surface = image->getSurface()->convertTo(g_system->getScreenFormat()); - if (image->getSurface()->format.bytesPerPixel == 3) { - TransparentSurface trans(*_surface); - trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, true); - } + needsColorKey = true; } else { _surface = new Graphics::Surface(); _surface->copyFrom(*image->getSurface()); + if (_surface->format.aBits() == 0) { + needsColorKey = true; + } + } + + if (needsColorKey) { + TransparentSurface trans(*_surface); + trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, true); } _hasAlpha = hasTransparency(_surface); -- cgit v1.2.3