diff --git a/src/Tools/jaby_engine_fconv/Cargo.toml b/src/Tools/jaby_engine_fconv/Cargo.toml index 0877a876..023b2b6e 100644 --- a/src/Tools/jaby_engine_fconv/Cargo.toml +++ b/src/Tools/jaby_engine_fconv/Cargo.toml @@ -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 diff --git a/src/Tools/jaby_engine_fconv/src/images/reduced_tim/mod.rs b/src/Tools/jaby_engine_fconv/src/images/reduced_tim/mod.rs index 3e4c6715..53a80907 100644 --- a/src/Tools/jaby_engine_fconv/src/images/reduced_tim/mod.rs +++ b/src/Tools/jaby_engine_fconv/src/images/reduced_tim/mod.rs @@ -33,8 +33,15 @@ pub struct Arguments { clut_align: ClutAlignment } -fn encode(image: T, clut_align: ClutAlignment, output: &mut dyn Write) -> Result<(), Error> { - let width = image.width(); +fn encode(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)) }