Merge pull request #511 from GriffinRichards/fix-tilemap
Support 8BPP images for 4BPP tilemaps
This commit is contained in:
commit
63734aec7c
3 changed files with 8 additions and 2 deletions
|
@ -14,6 +14,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
|
||||||
- Fix bug which caused encounter configurator to crash if slots in fields containing groups were deleted.
|
- Fix bug which caused encounter configurator to crash if slots in fields containing groups were deleted.
|
||||||
- Fix bug which caused encounter configurator to crash if last field was deleted.
|
- Fix bug which caused encounter configurator to crash if last field was deleted.
|
||||||
- Fix map render when collision view was active while map changed.
|
- Fix map render when collision view was active while map changed.
|
||||||
|
- Fix the updated pokefirered region map graphics appearing in grayscale.
|
||||||
|
|
||||||
## [5.1.0] - 2023-01-22
|
## [5.1.0] - 2023-01-22
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -126,6 +126,12 @@ public:
|
||||||
TilemapTileSelector(QString tilesetFilepath, TilemapFormat format, QString palFilepath): SelectablePixmapItem(8, 8, 1, 1) {
|
TilemapTileSelector(QString tilesetFilepath, TilemapFormat format, QString palFilepath): SelectablePixmapItem(8, 8, 1, 1) {
|
||||||
this->tileset = QImage(tilesetFilepath);
|
this->tileset = QImage(tilesetFilepath);
|
||||||
this->format = format;
|
this->format = format;
|
||||||
|
if (this->tileset.format() == QImage::Format::Format_Indexed8 && this->format == TilemapFormat::BPP_4) {
|
||||||
|
// Squash pixel data to fit 4BPP. Allows project repo to use 8BPP images for 4BPP tilemaps
|
||||||
|
uchar * pixel = this->tileset.bits();
|
||||||
|
for (int i = 0; i < this->tileset.sizeInBytes(); i++, pixel++)
|
||||||
|
*pixel %= 16;
|
||||||
|
}
|
||||||
bool err;
|
bool err;
|
||||||
if (!palFilepath.isEmpty()) {
|
if (!palFilepath.isEmpty()) {
|
||||||
this->palette = PaletteUtil::parse(palFilepath, &err);
|
this->palette = PaletteUtil::parse(palFilepath, &err);
|
||||||
|
|
|
@ -51,8 +51,7 @@ QImage TilemapTileSelector::setPalette(int paletteIndex) {
|
||||||
{
|
{
|
||||||
QVector<QRgb> newColorTable;
|
QVector<QRgb> newColorTable;
|
||||||
int palMinLength = paletteIndex * 16 + 16;
|
int palMinLength = paletteIndex * 16 + 16;
|
||||||
if ((this->palette.count() < palMinLength) || (tilesetImage.colorTable().count() != 16)) {
|
if (this->palette.count() < palMinLength) {
|
||||||
// either a) the palette has less than 256 colors, or b) the image is improperly indexed
|
|
||||||
for (QRgb color : tilesetImage.colorTable()) {
|
for (QRgb color : tilesetImage.colorTable()) {
|
||||||
int gray = qGray(color);
|
int gray = qGray(color);
|
||||||
newColorTable.append(qRgb(gray, gray, gray));
|
newColorTable.append(qRgb(gray, gray, gray));
|
||||||
|
|
Loading…
Reference in a new issue