diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dcd180e..199bd659 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Fix bug where layout json and blockdata could be saved separately leading to inconsistent data. - Fix crash when saving tilesets with fewer palettes than the maximum. - Fix projects not opening on Windows if the project filepath contains certain characters. +- Fix exported tile images containing garbage pixels after the end of the tiles. ## [5.4.1] - 2024-03-21 ### Fixed diff --git a/src/ui/tileseteditortileselector.cpp b/src/ui/tileseteditortileselector.cpp index 6984c0e3..2bc80f75 100644 --- a/src/ui/tileseteditortileselector.cpp +++ b/src/ui/tileseteditortileselector.cpp @@ -226,17 +226,11 @@ QImage TilesetEditorTileSelector::buildPrimaryTilesIndexedImage() { int primaryLength = this->primaryTileset->tiles.length(); int height = qCeil(primaryLength / static_cast(this->numTilesWide)); QImage image(this->numTilesWide * 8, height * 8, QImage::Format_RGBA8888); + image.fill(0); QPainter painter(&image); for (uint16_t tile = 0; tile < primaryLength; tile++) { - QImage tileImage; - if (tile < primaryLength) { - tileImage = getGreyscaleTileImage(tile, this->primaryTileset, this->secondaryTileset); - } else { - tileImage = QImage(8, 8, QImage::Format_RGBA8888); - tileImage.fill(qRgb(0, 0, 0)); - } - + QImage tileImage = getGreyscaleTileImage(tile, this->primaryTileset, this->secondaryTileset); int y = tile / this->numTilesWide; int x = tile % this->numTilesWide; QPoint origin = QPoint(x * 8, y * 8); @@ -261,18 +255,12 @@ QImage TilesetEditorTileSelector::buildSecondaryTilesIndexedImage() { int secondaryLength = this->secondaryTileset->tiles.length(); int height = qCeil(secondaryLength / static_cast(this->numTilesWide)); QImage image(this->numTilesWide * 8, height * 8, QImage::Format_RGBA8888); + image.fill(0); QPainter painter(&image); uint16_t primaryLength = static_cast(Project::getNumTilesPrimary()); for (uint16_t tile = 0; tile < secondaryLength; tile++) { - QImage tileImage; - if (tile < secondaryLength) { - tileImage = getGreyscaleTileImage(tile + primaryLength, this->primaryTileset, this->secondaryTileset); - } else { - tileImage = QImage(8, 8, QImage::Format_RGBA8888); - tileImage.fill(qRgb(0, 0, 0)); - } - + QImage tileImage = getGreyscaleTileImage(tile + primaryLength, this->primaryTileset, this->secondaryTileset); int y = tile / this->numTilesWide; int x = tile % this->numTilesWide; QPoint origin = QPoint(x * 8, y * 8);