refactor: try to integrate jpegxl_rs with hooks
The problem is, libjxl_rs does not offer a way to get metadata before decoding the entire image. As such, there is no reasonable way to implement ImageDecoder here; I think it's possible to make it decode the image on init, but that would lead to unexpected behavior performance-wise.
This commit is contained in:
parent
89b4639a69
commit
59ef65de70
2 changed files with 23 additions and 0 deletions
22
src/jxl.rs
Normal file
22
src/jxl.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
pub struct JxlDecoder<'a> {
|
||||
metadata: jpegxl_rs::decode::Metadata,
|
||||
inner: jpegxl_rs::decode::JxlDecoder<'a, 'a>,
|
||||
}
|
||||
|
||||
impl<'a> image::ImageDecoder for JxlDecoder<'a> {
|
||||
fn color_type(&self) -> image::ColorType {
|
||||
image::ColorType::Rgba8
|
||||
}
|
||||
fn icc_profile(&mut self) -> image::ImageResult<Option<Vec<u8>>> {
|
||||
Ok(self.metadata.icc_profile.clone())
|
||||
}
|
||||
fn dimensions(&self) -> (u32, u32) {}
|
||||
fn read_image(self, buf: &mut [u8]) -> image::ImageResult<()>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
}
|
||||
fn read_image_boxed(self: Box<Self>, buf: &mut [u8]) -> image::ImageResult<()> {
|
||||
self.read_image(buf)
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ use iced::{
|
|||
};
|
||||
use image::{EncodableLayout, RgbaImage, imageops};
|
||||
|
||||
mod jxl;
|
||||
mod utils;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue