aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk
diff options
context:
space:
mode:
authorJohannes Schickel2011-02-19 23:01:40 +0100
committerJohannes Schickel2011-02-19 23:01:40 +0100
commitaccab0e00f82ce1fe081c4f71fdab6326417620c (patch)
tree11a3e669d15419ea019ec5f8946695d9e91882d4 /engines/mohawk
parente21d6e0d1120e917a4a019a4070ec4db5e988b9b (diff)
downloadscummvm-rg350-accab0e00f82ce1fe081c4f71fdab6326417620c.tar.gz
scummvm-rg350-accab0e00f82ce1fe081c4f71fdab6326417620c.tar.bz2
scummvm-rg350-accab0e00f82ce1fe081c4f71fdab6326417620c.zip
MOHAWK: Change bitmaps to use RGB palettes.
Thanks to clone2727 for reviewing this patch.
Diffstat (limited to 'engines/mohawk')
-rw-r--r--engines/mohawk/bitmap.cpp19
-rw-r--r--engines/mohawk/cursors.cpp22
-rw-r--r--engines/mohawk/graphics.cpp6
3 files changed, 14 insertions, 33 deletions
diff --git a/engines/mohawk/bitmap.cpp b/engines/mohawk/bitmap.cpp
index ac4f27619b..7f022803ed 100644
--- a/engines/mohawk/bitmap.cpp
+++ b/engines/mohawk/bitmap.cpp
@@ -80,13 +80,12 @@ void MohawkBitmap::decodeImageData(Common::SeekableReadStream *stream) {
_header.colorTable.tableSize = _data->readUint16BE();
_header.colorTable.rgbBits = _data->readByte();
_header.colorTable.colorCount = _data->readByte();
- _header.colorTable.palette = (byte *)malloc(256 * 4);
+ _header.colorTable.palette = (byte *)malloc(256 * 3);
for (uint16 i = 0; i < 256; i++) {
- _header.colorTable.palette[i * 4 + 2] = _data->readByte();
- _header.colorTable.palette[i * 4 + 1] = _data->readByte();
- _header.colorTable.palette[i * 4] = _data->readByte();
- _header.colorTable.palette[i * 4 + 3] = 0;
+ _header.colorTable.palette[i * 3 + 2] = _data->readByte();
+ _header.colorTable.palette[i * 3 + 1] = _data->readByte();
+ _header.colorTable.palette[i * 3 + 0] = _data->readByte();
}
}
@@ -671,12 +670,12 @@ MohawkSurface *MystBitmap::decodeImage(Common::SeekableReadStream* stream) {
byte *palData = NULL;
if (_info.bitsPerPixel == 8) {
- palData = (byte *)malloc(256 * 4);
+ palData = (byte *)malloc(256 * 3);
for (uint16 i = 0; i < _info.colorsUsed; i++) {
- palData[i * 4 + 2] = bmpStream->readByte();
- palData[i * 4 + 1] = bmpStream->readByte();
- palData[i * 4] = bmpStream->readByte();
- palData[i * 4 + 3] = bmpStream->readByte();
+ palData[i * 3 + 2] = bmpStream->readByte();
+ palData[i * 3 + 1] = bmpStream->readByte();
+ palData[i * 3 + 0] = bmpStream->readByte();
+ bmpStream->readByte();
}
}
diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp
index 08f863544a..eb11eb175e 100644
--- a/engines/mohawk/cursors.cpp
+++ b/engines/mohawk/cursors.cpp
@@ -153,16 +153,7 @@ void MystCursorManager::setCursor(uint16 id) {
// Myst ME stores some cursors as 24bpp images instead of 8bpp
if (surface->bytesPerPixel == 1) {
CursorMan.replaceCursor((byte *)surface->pixels, surface->w, surface->h, hotspotX, hotspotY, 0);
-
- const byte *srcPal = mhkSurface->getPalette();
- byte pal[3*256];
- for (uint i = 0; i < 256; ++i) {
- pal[i * 3 + 0] = srcPal[i * 4 + 0];
- pal[i * 3 + 1] = srcPal[i * 4 + 1];
- pal[i * 3 + 2] = srcPal[i * 4 + 2];
- }
-
- CursorMan.replaceCursorPalette(pal, 0, 256);
+ CursorMan.replaceCursorPalette(mhkSurface->getPalette(), 0, 256);
} else {
Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
CursorMan.replaceCursor((byte *)surface->pixels, surface->w, surface->h, hotspotX, hotspotY, pixelFormat.RGBToColor(255, 255, 255), 1, &pixelFormat);
@@ -311,16 +302,7 @@ void NECursorManager::setCursor(uint16 id) {
if (cursors[i].id == id) {
Common::NECursor *cursor = cursors[i].cursors[0];
CursorMan.replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(), cursor->getHotspotY(), 0);
-
- const byte *srcPal = cursor->getPalette();
- byte pal[3 * 256];
- for (uint j = 0; j < 256; ++j) {
- pal[j * 3 + 0] = srcPal[j * 4 + 0];
- pal[j * 3 + 1] = srcPal[j * 4 + 1];
- pal[j * 3 + 2] = srcPal[j * 4 + 2];
- }
-
- CursorMan.replaceCursorPalette(pal, 0, 256);
+ CursorMan.replaceCursorPalette(cursor->getPalette(), 0, 256);
return;
}
}
diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp
index 78916be85c..897ca79d0e 100644
--- a/engines/mohawk/graphics.cpp
+++ b/engines/mohawk/graphics.cpp
@@ -73,9 +73,9 @@ void MohawkSurface::convertToTrueColor() {
for (uint16 i = 0; i < _surface->h; i++) {
for (uint16 j = 0; j < _surface->w; j++) {
byte palIndex = *((byte *)_surface->pixels + i * _surface->pitch + j);
- byte r = _palette[palIndex * 4];
- byte g = _palette[palIndex * 4 + 1];
- byte b = _palette[palIndex * 4 + 2];
+ byte r = _palette[palIndex * 3 + 0];
+ byte g = _palette[palIndex * 3 + 1];
+ byte b = _palette[palIndex * 3 + 2];
if (pixelFormat.bytesPerPixel == 2)
*((uint16 *)surface->getBasePtr(j, i)) = pixelFormat.RGBToColor(r, g, b);
else