Skip to content

Commit

Permalink
😁(NewQuant): add color_map_alpha for the tRNS trunc in the PNG format
Browse files Browse the repository at this point in the history
Signed-off-by: Benign X <[email protected]>
  • Loading branch information
W-Mai committed May 1, 2024
1 parent e2b938f commit 89fa562
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,16 @@ impl NeuQuant {
map
}

/// Return the Alpha channel of the color map calculated from the sample.
/// It's useful for transparency used in the tRNS chunk of the PNG format.
pub fn color_map_alpha(&self) -> Vec<u8> {
let mut map = Vec::with_capacity(self.netsize);
for entry in &self.colormap {
map.push(entry.a as u8);
}
map
}

/// Move neuron i towards biased (a,b,g,r) by factor alpha
fn salter_single(&mut self, alpha: f64, i: i32, quad: Quad<f64>) {
let n = &mut self.network[i as usize];
Expand Down

0 comments on commit 89fa562

Please sign in to comment.