1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-16 08:52:40 +01:00

Feature: Support converting 32bpp-only sprites to indexed 8bpp.

This uses nearest colour lookup to convert 32bpp-only sprites to indexed 8bpp on the fly. This provides a reasonable usable sprite instead of being incompatible.
This commit is contained in:
Peter Nelson
2025-01-15 17:36:31 +00:00
committed by Peter Nelson
parent c5d3ac7a71
commit 7b091000b0
6 changed files with 129 additions and 0 deletions

View File

@@ -10,6 +10,7 @@
#include "stdafx.h"
#include "random_access_file_type.h"
#include "spriteloader/grf.hpp"
#include "spriteloader/makeindexed.h"
#include "gfx_func.h"
#include "error.h"
#include "error_func.h"
@@ -488,6 +489,11 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty
}
if (sprite_avail == 0) {
sprite_avail = sprite_loader.LoadSprite(sprite, file, file_pos, sprite_type, false, sc->control_flags, avail_8bpp, avail_32bpp);
if (sprite_type == SpriteType::Normal && avail_32bpp != 0 && !encoder->Is32BppSupported() && sprite_avail == 0) {
/* No 8bpp available, try converting from 32bpp. */
SpriteLoaderMakeIndexed make_indexed(sprite_loader);
sprite_avail = make_indexed.LoadSprite(sprite, file, file_pos, sprite_type, true, sc->control_flags, sprite_avail, avail_32bpp);
}
}
if (sprite_avail == 0) {