[Scummvm-cvs-logs] scummvm master -> accab0e00f82ce1fe081c4f71fdab6326417620c
lordhoto
lordhoto at gmail.com
Sat Feb 19 23:03:36 CET 2011
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
accab0e00f MOHAWK: Change bitmaps to use RGB palettes.
Commit: accab0e00f82ce1fe081c4f71fdab6326417620c
https://github.com/scummvm/scummvm/commit/accab0e00f82ce1fe081c4f71fdab6326417620c
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-02-19T14:01:40-08:00
Commit Message:
MOHAWK: Change bitmaps to use RGB palettes.
Thanks to clone2727 for reviewing this patch.
Changed paths:
engines/mohawk/bitmap.cpp
engines/mohawk/cursors.cpp
engines/mohawk/graphics.cpp
diff --git a/engines/mohawk/bitmap.cpp b/engines/mohawk/bitmap.cpp
index ac4f276..7f02280 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 08f8635..eb11eb1 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 78916be..897ca79 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
More information about the Scummvm-git-logs
mailing list