Add harmonize utils
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user