Fix fconv for clut images
This commit is contained in:
parent
e2efa2283f
commit
7168d6b2d3
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "jaby_engine_fconv"
|
name = "jaby_engine_fconv"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# 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
|
clut_align: ClutAlignment
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode<T: PSXImageConverter>(image: T, clut_align: ClutAlignment, output: &mut dyn Write) -> Result<(), Error> {
|
fn encode<T: PSXImageConverter>(image: T, color_depth: ColorType, clut_align: ClutAlignment, output: &mut dyn Write) -> Result<(), Error> {
|
||||||
let width = image.width();
|
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 height = image.height();
|
||||||
let palette = image.get_palette();
|
let palette = image.get_palette();
|
||||||
let (pal_width, pal_height) = {
|
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() {
|
match ImageReader::new(Cursor::new(tool_helper::input_to_vec(input)?)).with_guessed_format()?.decode() {
|
||||||
Ok(image) => {
|
Ok(image) => {
|
||||||
match image {
|
match image {
|
||||||
DynamicImage::ImageRgb8(image) => encode(RgbImage::new(image), ClutAlignment::None, output),
|
DynamicImage::ImageRgb8(image) => encode(RgbImage::new(image), ColorType::Full16, ClutAlignment::None, output),
|
||||||
DynamicImage::ImageRgba8(image) => encode(RgbaImage::new(image), 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"))
|
_ => 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"))
|
_ => 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))
|
Err(error) => Err(Error::from_error(error))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue