Integrate all the progress into master #6

Merged
jaby merged 595 commits from ToolBox into main 2025-01-01 13:17:44 +00:00
1 changed files with 12 additions and 2 deletions
Showing only changes of commit e101657ed7 - Show all commits

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),
}
}