- use css colors to convert color names into rgb values

This commit is contained in:
Wim Pomp
2025-08-21 22:11:45 +02:00
parent b09f804a3f
commit 067368e06c
7 changed files with 149 additions and 85 deletions

View File

@@ -183,7 +183,7 @@ impl PyIJTiffFile {
return Err(PyValueError::new_err(format!(
"Unknown compression {}",
compression
)))
)));
}
};
if let Some(ref mut ijtifffile) = self.ijtifffile {
@@ -203,14 +203,9 @@ impl PyIJTiffFile {
}
#[setter]
fn set_colors(&mut self, colors: PyReadonlyArray2<u8>) -> PyResult<()> {
fn set_colors(&mut self, colors: Vec<String>) -> PyResult<()> {
if let Some(ijtifffile) = &mut self.ijtifffile {
let a = colors.to_owned_array();
ijtifffile.colors = Colors::Colors(
(0..a.shape()[0])
.map(|i| Vec::from(a.slice(s![i, ..]).as_slice().unwrap()))
.collect(),
);
ijtifffile.set_colors(&colors)?;
}
Ok(())
}