This commit is contained in:
Tharo 2025-05-24 20:17:47 +01:00
parent d909321b8f
commit 9f43c48c69
2 changed files with 4 additions and 6 deletions

View File

@ -463,9 +463,7 @@ static bool handle_ci_shared_tlut(const char* png_p, const struct fmt_info* fmt,
sprintf(pal_inc_c_p, "%s/%s.tlut.rgba16%s.inc.c", out_dir_p, tlut_name, tlut_elem_size == 8 ? "" : ".u32");
const bool is_split_palette = subfmt == SUBFMT_SPLIT_LO || subfmt == SUBFMT_SPLIT_HI;
const unsigned int max_colors = fmt->siz == G_IM_SIZ_4b ? 16
: is_split_palette ? 128
: 256;
const unsigned int max_colors = fmt->siz == G_IM_SIZ_4b ? 16 : is_split_palette ? 128 : 256;
if (all_other_pngs_match_ref_img_pal && ref_img->pal->count <= max_colors) {
// write matching palette, and matching color indices for all pngs
@ -475,9 +473,9 @@ static bool handle_ci_shared_tlut(const char* png_p, const struct fmt_info* fmt,
if (is_split_palette && ref_img->pal->count < max_colors) {
// split palettes must be exactly 128 colors, resize to full size
void *old_pal = ref_img->pal;
struct n64_palette* old_pal = ref_img->pal;
ref_img->pal = n64texconv_palette_resize(ref_img->pal, max_colors);
free(old_pal);
n64texconv_palette_free(old_pal);
}
// pass pad_to_8b=true to account for the case where this is in fact not matching data

View File

@ -246,9 +246,9 @@ class N64Palette(Structure):
return deref(pal)
def resize(self, new_count : int) -> Optional["N64Palette"]:
pal = ln64texconv.n64texconv_palette_resize(byref(self), new_count)
if new_count > 256:
raise ValueError("The largest possible palette size is 256")
pal = ln64texconv.n64texconv_palette_resize(byref(self), new_count)
_object_refcount.add_ref(pal)
return deref(pal)