[nostalgia/core] Fix resizeSubsheet to work for both growing and shrinking

This commit is contained in:
Gary Talent 2024-11-15 01:09:48 -06:00
parent 5a8da59df1
commit 8a9ff971a1

View File

@ -163,8 +163,8 @@ unsigned pixelCnt(TileSheet::SubSheet const&ss, int8_t pBpp) noexcept {
ox::Error resizeSubsheet(TileSheet::SubSheet &ss, int8_t pBpp, ox::Size const&sz) noexcept { ox::Error resizeSubsheet(TileSheet::SubSheet &ss, int8_t pBpp, ox::Size const&sz) noexcept {
ox::Vector<uint8_t> out; ox::Vector<uint8_t> out;
oxReturnError(setPixelCount(out, pBpp, static_cast<size_t>(sz.width * sz.height) * PixelsPerTile)); oxReturnError(setPixelCount(out, pBpp, static_cast<size_t>(sz.width * sz.height) * PixelsPerTile));
auto const w = sz.width * TileWidth; auto const w = ox::min<int32_t>(ss.columns, sz.width) * TileWidth;
auto const h = sz.height * TileHeight; auto const h = ox::min<int32_t>(ss.rows, sz.height) * TileHeight;
for (auto x = 0; x < w; ++x) { for (auto x = 0; x < w; ++x) {
for (auto y = 0; y < h; ++y) { for (auto y = 0; y < h; ++y) {
auto const palIdx = getPixel(ss, pBpp, {x, y}); auto const palIdx = getPixel(ss, pBpp, {x, y});