Add harmonize utils

This commit is contained in:
Schluffe
2026-10-01 00:04:46 +02:00
parent 3b72cd5723
commit f9fee06d37
7 changed files with 1243 additions and 79 deletions
+7 -4
View File
@@ -122,12 +122,15 @@ impl ColorMappings {
self.0.last_mut().unwrap().target = target;
}
pub fn apply_rgba(&self, rgba: &[u8]) -> Vec<u8> {
let lookup: HashMap<_, _> = self
.0
pub fn lookup(&self) -> HashMap<[u8; 3], [u8; 3]> {
self.0
.iter()
.flat_map(|entry| entry.members.iter().map(move |&rgb| (rgb, entry.target)))
.collect();
.collect()
}
pub fn apply_rgba(&self, rgba: &[u8]) -> Vec<u8> {
let lookup = self.lookup();
let mut output = rgba.to_vec();
for pixel in output.as_chunks_mut::<4>().0 {
if pixel[3] != 0