void NinePatchBitmap::blit(Graphics::Surface &target, int dx, int dy, int dw, int dh) { /* don't draw bitmaps that are smaller than the fixed area */ if (dw < _h._fix || dh < _v._fix) return; /* if the bitmap is the same size as the origin, then draw it as-is */ if (dw == _width && dh == _height) { Common::Rect r(1, 1, dw, dh); _bmp->blit(target, dx, dy, Graphics::FLIP_NONE, &r); return; } /* only recalculate the offsets if they have changed since the last draw */ if (_cached_dw != dw || _cached_dh != dh) { _h.calcOffsets(dw); _v.calcOffsets(dh); _cached_dw = dw; _cached_dh = dh; } /* draw each region */ for (uint i = 0; i < _v._m.size(); ++i) { for (uint j = 0; j < _h._m.size(); ++j) { Common::Rect r(_h._m[j]->offset, _v._m[i]->offset, _h._m[j]->offset + _h._m[j]->length, _v._m[i]->offset + _v._m[i]->length); _bmp->blit(target, dx + _h._m[j]->dest_offset, dy + _v._m[i]->dest_offset, Graphics::FLIP_NONE, &r, TS_ARGB(255, 255, 255, 255), _h._m[j]->dest_length, _v._m[i]->dest_length); } } }
void GraphicsManager::showThumbnail(const Common::String &filename, int atX, int atY) { Common::InSaveFile *fp = g_system->getSavefileManager()->openForLoading(filename); if (fp == nullptr) return; bool headerBad = false; if (fp->readByte() != 'S') headerBad = true; if (fp->readByte() != 'L') headerBad = true; if (fp->readByte() != 'U') headerBad = true; if (fp->readByte() != 'D') headerBad = true; if (fp->readByte() != 'S') headerBad = true; if (fp->readByte() != 'A') headerBad = true; if (headerBad) { fatal(ERROR_GAME_LOAD_NO, filename); return; } char c = fp->readByte(); while ((c = fp->readByte())) ; int majVersion = fp->readByte(); int minVersion = fp->readByte(); int ssgVersion = VERSION(majVersion, minVersion); if (ssgVersion >= VERSION(1, 4)) { int fileWidth = fp->readUint32LE(); int fileHeight = fp->readUint32LE(); Graphics::TransparentSurface thumbnail; if (!ImgLoader::loadPNGImage(fp, &thumbnail)) return; delete fp; fp = nullptr; if (atX < 0) { fileWidth += atX; atX = 0; } if (atY < 0) { fileHeight += atY; atY = 0; } if (fileWidth + atX > (int)_sceneWidth) fileWidth = _sceneWidth - atX; if (fileHeight + atY > (int)_sceneHeight) fileHeight = _sceneHeight - atY; thumbnail.blit(_backdropSurface, atX, atY, Graphics::FLIP_NONE, nullptr, TS_ARGB(255, 255, 255, 255), fileWidth, fileHeight); thumbnail.free(); } }