Fix TIM conversion bug in palette count

This commit is contained in:
Jaby 2023-11-26 18:41:31 -05:00
parent 57798eec9f
commit e101657ed7
1 changed files with 12 additions and 2 deletions

View File

@ -96,10 +96,20 @@ fn encode<T: PSXImageConverter>(image: T, color_depth: ColorType, clut_align: Cl
let palette = image.get_palette();
let (pal_width, pal_height) = {
if let Some(palette) = &palette {
let pal_length_adjusted = {
let pal_length = palette.len();
if pal_length <= 16 {
16u16
}
else {
256u16
}
};
match clut_align {
ClutAlignment::None |
ClutAlignment::Linear => (palette.len() as u16, 1u16),
ClutAlignment::Block => (16u16, (palette.len()/16) as u16),
ClutAlignment::Linear => (pal_length_adjusted, 1u16),
ClutAlignment::Block => (16u16, pal_length_adjusted/16u16),
}
}