Fix fconv for clut images
This commit is contained in:
parent
1b35ab2a3f
commit
5dc83be87f
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "jaby_engine_fconv"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
|
|
@ -33,8 +33,15 @@ pub struct Arguments {
|
|||
clut_align: ClutAlignment
|
||||
}
|
||||
|
||||
fn encode<T: PSXImageConverter>(image: T, clut_align: ClutAlignment, output: &mut dyn Write) -> Result<(), Error> {
|
||||
let width = image.width();
|
||||
fn encode<T: PSXImageConverter>(image: T, color_depth: ColorType, clut_align: ClutAlignment, output: &mut dyn Write) -> Result<(), Error> {
|
||||
let width = {
|
||||
let width = image.width();
|
||||
match color_depth {
|
||||
ColorType::Clut4 => width/4,
|
||||
ColorType::Clut8 => width/2,
|
||||
ColorType::Full16 => width
|
||||
}
|
||||
};
|
||||
let height = image.height();
|
||||
let palette = image.get_palette();
|
||||
let (pal_width, pal_height) = {
|
||||
|
@ -78,8 +85,8 @@ fn convert_full16(input: Input, output: &mut dyn Write) -> Result<(), Error> {
|
|||
match ImageReader::new(Cursor::new(tool_helper::input_to_vec(input)?)).with_guessed_format()?.decode() {
|
||||
Ok(image) => {
|
||||
match image {
|
||||
DynamicImage::ImageRgb8(image) => encode(RgbImage::new(image), ClutAlignment::None, output),
|
||||
DynamicImage::ImageRgba8(image) => encode(RgbaImage::new(image), ClutAlignment::None, output),
|
||||
DynamicImage::ImageRgb8(image) => encode(RgbImage::new(image), ColorType::Full16, ClutAlignment::None, output),
|
||||
DynamicImage::ImageRgba8(image) => encode(RgbaImage::new(image), ColorType::Full16, ClutAlignment::None, output),
|
||||
|
||||
_ => Err(Error::from_str("Only RGB and RGBA images are supported for 16bit encoding"))
|
||||
}
|
||||
|
@ -98,7 +105,7 @@ fn convert_palette_based(input: Input, output: &mut dyn Write, color_type: Color
|
|||
_ => return Err(Error::from_str("ColorType not supported"))
|
||||
}
|
||||
};
|
||||
encode(IndexedImage::new(reader, output_type)?, clut_align, output)
|
||||
encode(IndexedImage::new(reader, output_type)?, color_type, clut_align, output)
|
||||
},
|
||||
Err(error) => Err(Error::from_error(error))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue