Fill Palette if needed

This commit is contained in:
jaby 2022-09-28 19:53:50 +02:00
parent 92760cfce1
commit 176ac89e6b
1 changed files with 8 additions and 1 deletions

View File

@ -4,7 +4,7 @@ use color_clut::IndexedImage;
use color_full16::{RgbaImage, RgbImage};
use std::io::Cursor;
use tool_helper::{Error, Input, Output};
use types::{Header, PSXImageConverter};
use types::{Header, Color as PSXColor, PSXImageConverter};
mod types;
mod color_clut;
@ -51,8 +51,15 @@ fn encode<T: PSXImageConverter>(image: T, clut_align: ClutAlignment, mut output:
tool_helper::raw::write_generic(&mut output, header)?;
if let Some(palette) = palette {
let mut color_count = pal_width*pal_height;
for color in palette {
tool_helper::raw::write_generic(&mut output, color)?;
color_count -= 1;
}
while color_count > 0 {
tool_helper::raw::write_generic(&mut output, PSXColor::black())?;
color_count -= 1;
}
}