Add compatibility check for future tilemaps w/unsupported tile formats

This commit is contained in:
David Capello 2023-06-01 13:02:35 -03:00
parent 5c41d96db3
commit fc24613b81

View File

@ -946,7 +946,7 @@ doc::Cel* AsepriteDecoder::readCelChunk(doc::Sprite* sprite,
// Read width and height
int w = read16();
int h = read16();
int bitsPerTile = read16(); // TODO add support for more bpp
int bitsPerTile = read16();
uint32_t tileIDMask = read32();
uint32_t flipxMask = read32();
uint32_t flipyMask = read32();
@ -954,6 +954,14 @@ doc::Cel* AsepriteDecoder::readCelChunk(doc::Sprite* sprite,
uint32_t flagsMask = (flipxMask | flipyMask | rot90Mask);
readPadding(10);
// We only support 32bpp at the moment
// TODO add support for other bpp (8-bit, 16-bpp)
if (bitsPerTile != 32) {
delegate()->incompatibilityError(
fmt::format("Unsupported tile format: {0} bits per tile", bitsPerTile));
break;
}
if (w > 0 && h > 0) {
doc::ImageRef image(doc::Image::create(doc::IMAGE_TILEMAP, w, h));
image->setMaskColor(doc::notile);