TONY: Simplify thumbnail loading code.

This commit is contained in:
Alyssa Milburn 2013-08-01 21:56:01 +02:00
parent 9db17152c1
commit 275c65c272

View file

@ -154,26 +154,16 @@ void TonyMetaEngine::removeSaveState(const char *target, int slot) const {
SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
Common::String saveName;
byte difficulty;
byte thumbData[160 * 120 * 2];
if (Tony::RMOptionScreen::loadThumbnailFromSaveState(slot, thumbData, saveName, difficulty)) {
// Convert the 565 thumbnail data to the needed overlay format
Common::MemoryReadStream thumbStream(thumbData, 160 * 120 * 2);
Graphics::PixelFormat destFormat = g_system->getOverlayFormat();
Graphics::Surface *to = new Graphics::Surface();
to->create(160, 120, destFormat);
OverlayColor *pixels = (OverlayColor *)to->pixels;
for (int y = 0; y < to->h; ++y) {
for (int x = 0; x < to->w; ++x) {
uint8 r, g, b;
Graphics::colorToRGB<Graphics::ColorMasks<555> >(thumbStream.readUint16LE(), r, g, b);
// converting to current OSystem Color
*pixels++ = destFormat.RGBToColor(r, g, b);
}
}
Graphics::Surface *to = new Graphics::Surface();
to->create(160, 120, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0));
if (Tony::RMOptionScreen::loadThumbnailFromSaveState(slot, (byte *)to->pixels, saveName, difficulty)) {
#ifdef SCUMM_BIG_ENDIAN
uint16 *pixels = (uint16 *)to->pixels;
for (int i = 0; i < to->w * to->h; ++i)
pixels[i] = READ_LE_UINT16(pixels + i);
#endif
// Create the return descriptor
SaveStateDescriptor desc(slot, saveName);
desc.setDeletableFlag(true);
@ -183,6 +173,7 @@ SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int s
return desc;
}
delete to;
return SaveStateDescriptor();
}