aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/wintermute/Base/BSurfaceSDL.cpp14
-rw-r--r--engines/wintermute/graphics/transparentSurface.cpp1
2 files changed, 12 insertions, 3 deletions
diff --git a/engines/wintermute/Base/BSurfaceSDL.cpp b/engines/wintermute/Base/BSurfaceSDL.cpp
index c0157696d6..0b16f3d39b 100644
--- a/engines/wintermute/Base/BSurfaceSDL.cpp
+++ b/engines/wintermute/Base/BSurfaceSDL.cpp
@@ -137,10 +137,18 @@ HRESULT CBSurfaceSDL::Create(const char *Filename, bool default_ck, byte ck_red,
// no alpha, set color key
/* if (surface->format.bytesPerPixel != 4)
SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/
- if (surface->format.bytesPerPixel == 1 && palette) {
+
+ // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?)
+ // Well, actually, we don't convert via 24-bit as the color-key application overwrites the Alpha-channel anyhow.
+ if (strFileName.hasSuffix(".bmp") && surface->format.bytesPerPixel == 4) {
_surface = surface->convertTo(g_system->getScreenFormat(), palette);
- }
- else if (surface->format.bytesPerPixel == 4 && surface->format != g_system->getScreenFormat()) {
+ TransparentSurface trans(*_surface);
+ trans.applyColorKey(ck_red, ck_green, ck_blue);
+ } else if (surface->format.bytesPerPixel == 1 && palette) {
+ _surface = surface->convertTo(g_system->getScreenFormat(), palette);
+ TransparentSurface trans(*_surface);
+ trans.applyColorKey(ck_red, ck_green, ck_blue, true);
+ } else if (surface->format.bytesPerPixel == 4 && surface->format != g_system->getScreenFormat()) {
_surface = surface->convertTo(g_system->getScreenFormat());
} else {
_surface = new Graphics::Surface();
diff --git a/engines/wintermute/graphics/transparentSurface.cpp b/engines/wintermute/graphics/transparentSurface.cpp
index d7f8719b6e..33f2043839 100644
--- a/engines/wintermute/graphics/transparentSurface.cpp
+++ b/engines/wintermute/graphics/transparentSurface.cpp
@@ -278,6 +278,7 @@ TransparentSurface *TransparentSurface::scale(int xSize, int ySize) const {
* @param overwriteAlpha if true, all other alpha will be set fully opaque
*/
void TransparentSurface::applyColorKey(uint8 rKey, uint8 gKey, uint8 bKey, bool overwriteAlpha) {
+ assert(format.bytesPerPixel == 4);
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
uint32 pix = ((uint32 *)pixels)[i * w + j];