MOHAWK: Change bitmaps to use RGB palettes.

Thanks to clone2727 for reviewing this patch.
This commit is contained in:
Johannes Schickel 2011-02-19 23:01:40 +01:00
parent e21d6e0d11
commit accab0e00f
3 changed files with 14 additions and 33 deletions

View file

@ -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();
}
}

View file

@ -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;
}
}

View file

@ -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