aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-06-02 13:48:26 +0200
committerEinar Johan Trøan Sømåen2012-06-02 13:48:26 +0200
commite7a802700c3872215049d304fb6898549eef56f5 (patch)
tree8e96ebd61110e5c085f817808f57b7bd594d5ef0 /engines
parent2db256605539b82ed4ace20d41c6046f50792706 (diff)
downloadscummvm-rg350-e7a802700c3872215049d304fb6898549eef56f5.tar.gz
scummvm-rg350-e7a802700c3872215049d304fb6898549eef56f5.tar.bz2
scummvm-rg350-e7a802700c3872215049d304fb6898549eef56f5.zip
WINTERMUTE: Add color-keying for BSurfaceSDL BMPs
Diffstat (limited to 'engines')
-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];